Author: hbelusca Date: Sun Feb 28 16:01:54 2016 New Revision: 70798
URL: http://svn.reactos.org/svn/reactos?rev=70798&view=rev Log: [USETUP]: Isolate the recognition of the filesystem of a partition into its own function.
Modified: trunk/reactos/base/setup/usetup/fslist.c trunk/reactos/base/setup/usetup/fslist.h trunk/reactos/base/setup/usetup/interface/usetup.c
Modified: trunk/reactos/base/setup/usetup/fslist.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/fslist.c?... ============================================================================== --- trunk/reactos/base/setup/usetup/fslist.c [iso-8859-1] (original) +++ trunk/reactos/base/setup/usetup/fslist.c [iso-8859-1] Sun Feb 28 16:01:54 2016 @@ -66,6 +66,93 @@ }
+PFILE_SYSTEM_ITEM +GetFileSystemByName( + IN PFILE_SYSTEM_LIST List, + IN LPWSTR FileSystemName) +{ + PLIST_ENTRY ListEntry; + PFILE_SYSTEM_ITEM Item; + + ListEntry = List->ListHead.Flink; + while (ListEntry != &List->ListHead) + { + Item = CONTAINING_RECORD(ListEntry, FILE_SYSTEM_ITEM, ListEntry); + if (Item->FileSystemName && wcsicmp(FileSystemName, Item->FileSystemName) == 0) + return Item; + + ListEntry = ListEntry->Flink; + } + + return NULL; +} + + +PFILE_SYSTEM_ITEM +GetFileSystem( + IN PFILE_SYSTEM_LIST FileSystemList, + IN PPARTENTRY PartEntry) +{ + PFILE_SYSTEM_ITEM CurrentFileSystem; + LPWSTR FileSystemName = NULL; + + CurrentFileSystem = PartEntry->FileSystem; + + /* We have a file system, return it */ + if (CurrentFileSystem != NULL && CurrentFileSystem->FileSystemName != NULL) + return CurrentFileSystem; + + CurrentFileSystem = NULL; + + /* + * We don't have one... + * + * Try to infer a preferred file system for this partition, given its ID. + * + * WARNING: This is partly a hack, since partitions with the same ID can + * be formatted with different file systems: for example, usual Linux + * partitions that are formatted in EXT2/3/4, ReiserFS, etc... have the + * same partition ID 0x83. + * + * The proper fix is to make a function that detects the existing FS + * from a given partition (not based on the partition ID). + * On the contrary, for unformatted partitions with a given ID, the + * following code is OK. + */ + if ((PartEntry->PartitionType == PARTITION_FAT_12) || + (PartEntry->PartitionType == PARTITION_FAT_16) || + (PartEntry->PartitionType == PARTITION_HUGE) || + (PartEntry->PartitionType == PARTITION_XINT13) || + (PartEntry->PartitionType == PARTITION_FAT32) || + (PartEntry->PartitionType == PARTITION_FAT32_XINT13)) + { + FileSystemName = L"FAT"; + } + else if (PartEntry->PartitionType == PARTITION_EXT2) + { + // WARNING: See the warning above. + FileSystemName = L"EXT2"; + } + else if (PartEntry->PartitionType == PARTITION_IFS) + { + // WARNING: See the warning above. + FileSystemName = L"NTFS"; /* FIXME: Not quite correct! */ + } + + // WARNING: We cannot write on this FS yet! + if (PartEntry->PartitionType == PARTITION_EXT2 || PartEntry->PartitionType == PARTITION_IFS) + DPRINT1("Recognized FileSystem %S that doesn't support write support yet!\n", FileSystemName); + + DPRINT1("GetFileSystem -- PartitionType: 0x%02X ; FileSystemName (guessed): %S\n", + PartEntry->PartitionType, FileSystemName); + + if (FileSystemName != NULL) + CurrentFileSystem = GetFileSystemByName(FileSystemList, FileSystemName); + + return CurrentFileSystem; +} + + PFILE_SYSTEM_LIST CreateFileSystemList( IN SHORT Left, @@ -210,26 +297,4 @@ } }
- -PFILE_SYSTEM_ITEM -GetFileSystemByName( - IN PFILE_SYSTEM_LIST List, - IN LPWSTR FileSystemName) -{ - PLIST_ENTRY ListEntry; - PFILE_SYSTEM_ITEM Item; - - ListEntry = List->ListHead.Flink; - while (ListEntry != &List->ListHead) - { - Item = CONTAINING_RECORD(ListEntry, FILE_SYSTEM_ITEM, ListEntry); - if (Item->FileSystemName && wcsicmp(FileSystemName, Item->FileSystemName) == 0) - return Item; - - ListEntry = ListEntry->Flink; - } - - return NULL; -} - /* EOF */
Modified: trunk/reactos/base/setup/usetup/fslist.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/fslist.h?... ============================================================================== --- trunk/reactos/base/setup/usetup/fslist.h [iso-8859-1] (original) +++ trunk/reactos/base/setup/usetup/fslist.h [iso-8859-1] Sun Feb 28 16:01:54 2016 @@ -52,6 +52,16 @@ IN FORMATEX FormatFunc, IN CHKDSKEX ChkdskFunc);
+PFILE_SYSTEM_ITEM +GetFileSystemByName( + IN PFILE_SYSTEM_LIST List, + IN LPWSTR FileSystemName); + +PFILE_SYSTEM_ITEM +GetFileSystem( + IN PFILE_SYSTEM_LIST FileSystemList, + IN PPARTENTRY PartEntry); + PFILE_SYSTEM_LIST CreateFileSystemList( IN SHORT Left, @@ -75,9 +85,4 @@ ScrollUpFileSystemList( IN PFILE_SYSTEM_LIST List);
-PFILE_SYSTEM_ITEM -GetFileSystemByName( - IN PFILE_SYSTEM_LIST List, - IN LPWSTR FileSystemName); - /* EOF */
Modified: trunk/reactos/base/setup/usetup/interface/usetup.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/interface... ============================================================================== --- trunk/reactos/base/setup/usetup/interface/usetup.c [iso-8859-1] (original) +++ trunk/reactos/base/setup/usetup/interface/usetup.c [iso-8859-1] Sun Feb 28 16:01:54 2016 @@ -2786,8 +2786,7 @@ { if (UnattendFormatPartition) { - PartEntry->FileSystem = GetFileSystemByName(FileSystemList, - L"FAT"); + PartEntry->FileSystem = GetFileSystemByName(FileSystemList, L"FAT"); return FORMAT_PARTITION_PAGE; }
@@ -3076,7 +3075,6 @@ UNICODE_STRING PartitionRootPath; WCHAR PathBuffer[MAX_PATH]; CHAR Buffer[MAX_PATH]; - LPWSTR FileSystemName = NULL; PDISKENTRY DiskEntry; PPARTENTRY PartEntry; NTSTATUS Status; @@ -3087,9 +3085,7 @@ return QUIT_PAGE; }
- if (!GetNextUncheckedPartition(PartitionList, - &DiskEntry, - &PartEntry)) + if (!GetNextUncheckedPartition(PartitionList, &DiskEntry, &PartEntry)) { return INSTALL_DIRECTORY_PAGE; } @@ -3106,50 +3102,7 @@
CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT));
- CurrentFileSystem = PartEntry->FileSystem; - if (CurrentFileSystem == NULL || CurrentFileSystem->FileSystemName == NULL) - { - /* - * Try to infer a preferred file system for this partition, given its ID. - * - * WARNING: This is partly a hack, since partitions with the same ID can - * be formatted with different file systems: for example, usual Linux - * partitions that are formatted in EXT2/3/4, ReiserFS, etc... have the - * same partition ID 0x83. - * - * The proper fix is to make a function that detects the existing FS - * from a given partition (not based on the partition ID). - * On the contrary, for unformatted partitions with a given ID, the - * following code is OK. - */ - if ((PartEntry->PartitionType == PARTITION_FAT_12) || - (PartEntry->PartitionType == PARTITION_FAT_16) || - (PartEntry->PartitionType == PARTITION_HUGE) || - (PartEntry->PartitionType == PARTITION_XINT13) || - (PartEntry->PartitionType == PARTITION_FAT32) || - (PartEntry->PartitionType == PARTITION_FAT32_XINT13)) - { - FileSystemName = L"FAT"; - } - else if (PartEntry->PartitionType == PARTITION_EXT2) - { - // WARNING: See the warning above. - FileSystemName = L"EXT2"; - } - else if (PartEntry->PartitionType == PARTITION_IFS) - { - // WARNING: See the warning above. - FileSystemName = L"NTFS"; /* FIXME: Not quite correct! */ - } - - DPRINT1("CheckFileSystemPage -- PartitionType: 0x%02X ; FileSystemName (guessed): %S\n", - PartEntry->PartitionType, FileSystemName); - - if (FileSystemName != NULL) - CurrentFileSystem = GetFileSystemByName(FileSystemList, - FileSystemName); - } - + CurrentFileSystem = GetFileSystem(FileSystemList, PartEntry); DPRINT1("CheckFileSystemPage -- PartitionType: 0x%02X ; FileSystemName: %S\n", PartEntry->PartitionType, (CurrentFileSystem ? CurrentFileSystem->FileSystemName : L"n/a"));