[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
/*
* PROJECT : ReactOS Setup Library
* LICENSE : GPL - 2.0 + ( https : //spdx.org/licenses/GPL-2.0+)
* PURPOSE : Filesystem support functions
2018-05-27 19:33:07 +00:00
* COPYRIGHT : Copyright 2003 - 2018 Casper S . Hornstrup ( chorns @ users . sourceforge . net )
[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
* Copyright 2017 - 2018 Hermes Belusca - Maito
*/
//
// See also: https://git.reactos.org/?p=reactos.git;a=blob;f=reactos/dll/win32/fmifs/init.c;h=e895f5ef9cae4806123f6bbdd3dfed37ec1c8d33;hb=b9db9a4e377a2055f635b2fb69fef4e1750d219c
// for how to get FS providers in a dynamic way. In the (near) future we may
// consider merging some of this code with us into a fmifs / fsutil / fslib library...
//
/* INCLUDES *****************************************************************/
# include "precomp.h"
# include "fsutil.h"
# include "partlist.h"
# include <fslib/vfatlib.h>
2018-06-13 23:30:06 +00:00
# include <fslib/btrfslib.h>
2017-05-17 23:31:52 +00:00
// #include <fslib/ext2lib.h>
[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
// #include <fslib/ntfslib.h>
# define NDEBUG
# include <debug.h>
2018-11-12 23:13:45 +00:00
/* GLOBALS ******************************************************************/
/* The list of file systems on which we can install ReactOS */
[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
FILE_SYSTEM RegisteredFileSystems [ ] =
{
2017-12-23 19:17:38 +00:00
/* NOTE: The FAT formatter automatically determines
* whether it will use FAT - 16 or FAT - 32. */
[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
{ L " FAT " , VfatFormat , VfatChkdsk } ,
#if 0
2017-12-23 19:17:38 +00:00
{ L " FAT32 " , VfatFormat , VfatChkdsk } , // Do we support specific FAT sub-formats specifications?
2017-05-17 23:31:52 +00:00
{ L " FATX " , VfatxFormat , VfatxChkdsk } ,
{ L " NTFS " , NtfsFormat , NtfsChkdsk } ,
2018-06-13 23:30:06 +00:00
# endif
2017-05-17 23:31:52 +00:00
{ L " BTRFS " , BtrfsFormatEx , BtrfsChkdskEx } ,
2018-06-13 23:30:06 +00:00
#if 0
2018-11-12 23:13:45 +00:00
{ L " EXT2 " , Ext2Format , Ext2Chkdsk } ,
{ L " EXT3 " , Ext2Format , Ext2Chkdsk } ,
{ L " EXT4 " , Ext2Format , Ext2Chkdsk } ,
2017-05-17 23:31:52 +00:00
{ L " FFS " , FfsFormat , FfsChkdsk } ,
{ L " REISERFS " , ReiserfsFormat , ReiserfsChkdsk } ,
[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
# endif
} ;
/* FUNCTIONS ****************************************************************/
PFILE_SYSTEM
GetRegisteredFileSystems ( OUT PULONG Count )
{
* Count = ARRAYSIZE ( RegisteredFileSystems ) ;
return RegisteredFileSystems ;
}
PFILE_SYSTEM
GetFileSystemByName (
// IN PFILE_SYSTEM_LIST List,
IN PCWSTR FileSystemName )
{
#if 0 // Reenable when the list of registered FSes will again be dynamic
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 ;
}
# else
ULONG Count ;
PFILE_SYSTEM FileSystems ;
FileSystems = GetRegisteredFileSystems ( & Count ) ;
if ( ! FileSystems | | Count = = 0 )
return NULL ;
while ( Count - - )
{
if ( FileSystems - > FileSystemName & & wcsicmp ( FileSystemName , FileSystems - > FileSystemName ) = = 0 )
return FileSystems ;
+ + FileSystems ;
}
# endif
return NULL ;
}
//
// FileSystem recognition (using NT OS functionality)
//
/* NOTE: Ripped & adapted from base/system/autochk/autochk.c */
static NTSTATUS
_MyGetFileSystem (
IN struct _PARTENTRY * PartEntry ,
IN OUT PWSTR FileSystemName ,
IN SIZE_T FileSystemNameSize )
{
NTSTATUS Status ;
2018-11-12 23:13:45 +00:00
UNICODE_STRING PartitionRootPath ;
OBJECT_ATTRIBUTES ObjectAttributes ;
[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
HANDLE FileHandle ;
IO_STATUS_BLOCK IoStatusBlock ;
WCHAR PathBuffer [ MAX_PATH ] ;
2018-11-12 23:13:45 +00:00
UCHAR Buffer [ sizeof ( FILE_FS_ATTRIBUTE_INFORMATION ) + MAX_PATH * sizeof ( WCHAR ) ] ;
PFILE_FS_ATTRIBUTE_INFORMATION FileFsAttribute = ( PFILE_FS_ATTRIBUTE_INFORMATION ) Buffer ;
[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
/* Set PartitionRootPath */
2017-05-31 01:43:12 +00:00
RtlStringCchPrintfW ( PathBuffer , ARRAYSIZE ( PathBuffer ) ,
2018-11-12 23:13:45 +00:00
L " \\ Device \\ Harddisk%lu \\ Partition%lu " ,
2017-05-31 01:43:12 +00:00
PartEntry - > DiskEntry - > DiskNumber ,
PartEntry - > PartitionNumber ) ;
[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
RtlInitUnicodeString ( & PartitionRootPath , PathBuffer ) ;
DPRINT ( " PartitionRootPath: %wZ \n " , & PartitionRootPath ) ;
/* Open the partition */
InitializeObjectAttributes ( & ObjectAttributes ,
& PartitionRootPath ,
OBJ_CASE_INSENSITIVE ,
NULL ,
NULL ) ;
Status = NtOpenFile ( & FileHandle , // PartitionHandle,
FILE_GENERIC_READ /* | SYNCHRONIZE */ ,
& ObjectAttributes ,
& IoStatusBlock ,
2018-11-12 23:13:45 +00:00
FILE_SHARE_READ | FILE_SHARE_WRITE ,
[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
0 /* FILE_SYNCHRONOUS_IO_NONALERT */ ) ;
if ( ! NT_SUCCESS ( Status ) )
{
2018-11-12 23:13:45 +00:00
DPRINT1 ( " Failed to open partition '%wZ', Status 0x%08lx \n " , & PartitionRootPath , Status ) ;
[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
return Status ;
}
/* Retrieve the FS attributes */
Status = NtQueryVolumeInformationFile ( FileHandle ,
& IoStatusBlock ,
FileFsAttribute ,
sizeof ( Buffer ) ,
FileFsAttributeInformation ) ;
NtClose ( FileHandle ) ;
if ( ! NT_SUCCESS ( Status ) )
{
2018-11-12 23:13:45 +00:00
DPRINT1 ( " NtQueryVolumeInformationFile failed for partition '%wZ', Status 0x%08lx \n " ,
& PartitionRootPath , Status ) ;
[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
return Status ;
}
2018-11-12 23:13:45 +00:00
if ( FileSystemNameSize < FileFsAttribute - > FileSystemNameLength + sizeof ( WCHAR ) )
[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
return STATUS_BUFFER_TOO_SMALL ;
2018-11-12 23:13:45 +00:00
return RtlStringCbCopyNW ( FileSystemName , FileSystemNameSize ,
FileFsAttribute - > FileSystemName ,
FileFsAttribute - > FileSystemNameLength ) ;
[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
}
PFILE_SYSTEM
GetFileSystem (
// IN PFILE_SYSTEM_LIST FileSystemList,
IN struct _PARTENTRY * PartEntry )
{
PFILE_SYSTEM CurrentFileSystem ;
NTSTATUS Status ;
2018-11-12 23:13:45 +00:00
PWSTR FileSystemName = NULL ;
[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
WCHAR FsRecFileSystemName [ MAX_PATH ] ;
CurrentFileSystem = PartEntry - > FileSystem ;
/* We have a file system, return it */
if ( CurrentFileSystem ! = NULL & & CurrentFileSystem - > FileSystemName ! = NULL )
return CurrentFileSystem ;
DPRINT1 ( " File system not found, try to guess one... \n " ) ;
CurrentFileSystem = NULL ;
/*
* We don ' t have one . . .
*
2018-11-12 23:13:45 +00:00
* Try to infer a file system using NT file system recognition .
[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
*/
2018-11-12 23:13:45 +00:00
Status = _MyGetFileSystem ( PartEntry , FsRecFileSystemName , sizeof ( FsRecFileSystemName ) ) ;
[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
if ( NT_SUCCESS ( Status ) & & * FsRecFileSystemName )
{
/* Temporary HACK: map FAT32 back to FAT */
if ( wcscmp ( FsRecFileSystemName , L " FAT32 " ) = = 0 )
2018-11-12 23:13:45 +00:00
RtlStringCbCopyW ( FsRecFileSystemName , sizeof ( FsRecFileSystemName ) , L " FAT " ) ;
[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
FileSystemName = FsRecFileSystemName ;
goto Quit ;
}
/*
* 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 " ;
}
2018-06-13 23:30:06 +00:00
else if ( PartEntry - > PartitionType = = PARTITION_LINUX )
[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
{
// WARNING: See the warning above.
2018-11-12 23:13:45 +00:00
/* Could also be EXT2/3/4, ReiserFS, ... */
2018-06-13 23:30:06 +00:00
FileSystemName = L " BTRFS " ;
[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
}
else if ( PartEntry - > PartitionType = = PARTITION_IFS )
{
// WARNING: See the warning above.
2018-11-12 23:13:45 +00:00
/* Could also be HPFS */
FileSystemName = L " NTFS " ;
[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
}
2018-11-12 23:13:45 +00:00
Quit :
[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
// HACK: WARNING: We cannot write on this FS yet!
if ( FileSystemName )
{
2018-06-13 23:30:06 +00:00
if ( PartEntry - > PartitionType = = PARTITION_IFS )
[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
DPRINT1 ( " Recognized file system %S that doesn't support write support yet! \n " , FileSystemName ) ;
}
DPRINT1 ( " GetFileSystem -- PartitionType: 0x%02X ; FileSystemName (guessed): %S \n " ,
PartEntry - > PartitionType , FileSystemName ? FileSystemName : L " None " ) ;
2018-11-12 23:13:45 +00:00
if ( FileSystemName )
2017-05-17 23:31:52 +00:00
CurrentFileSystem = GetFileSystemByName ( FileSystemName ) ;
[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
return CurrentFileSystem ;
}
2017-05-17 23:31:52 +00:00
//
// Formatting routines
//
BOOLEAN
PreparePartitionForFormatting (
IN struct _PARTENTRY * PartEntry ,
IN PFILE_SYSTEM FileSystem )
{
if ( ! FileSystem )
{
DPRINT1 ( " No file system specified? \n " ) ;
return FALSE ;
}
if ( wcscmp ( FileSystem - > FileSystemName , L " FAT " ) = = 0 )
{
if ( PartEntry - > SectorCount . QuadPart < 8192 )
{
/* FAT12 CHS partition (disk is smaller than 4.1MB) */
SetPartitionType ( PartEntry , PARTITION_FAT_12 ) ;
}
else if ( PartEntry - > StartSector . QuadPart < 1450560 )
{
/* Partition starts below the 8.4GB boundary ==> CHS partition */
if ( PartEntry - > SectorCount . QuadPart < 65536 )
{
/* FAT16 CHS partition (partition size < 32MB) */
SetPartitionType ( PartEntry , PARTITION_FAT_16 ) ;
}
else if ( PartEntry - > SectorCount . QuadPart < 1048576 )
{
/* FAT16 CHS partition (partition size < 512MB) */
SetPartitionType ( PartEntry , PARTITION_HUGE ) ;
}
else
{
/* FAT32 CHS partition (partition size >= 512MB) */
SetPartitionType ( PartEntry , PARTITION_FAT32 ) ;
}
}
else
{
/* Partition starts above the 8.4GB boundary ==> LBA partition */
if ( PartEntry - > SectorCount . QuadPart < 1048576 )
{
/* FAT16 LBA partition (partition size < 512MB) */
SetPartitionType ( PartEntry , PARTITION_XINT13 ) ;
}
else
{
/* FAT32 LBA partition (partition size >= 512MB) */
SetPartitionType ( PartEntry , PARTITION_FAT32_XINT13 ) ;
}
}
}
2018-06-13 23:30:06 +00:00
else if ( wcscmp ( FileSystem - > FileSystemName , L " BTRFS " ) = = 0 )
{
SetPartitionType ( PartEntry , PARTITION_LINUX ) ;
}
2017-05-17 23:31:52 +00:00
#if 0
else if ( wcscmp ( FileSystem - > FileSystemName , L " EXT2 " ) = = 0 )
{
2018-10-28 12:28:56 +00:00
SetPartitionType ( PartEntry , PARTITION_LINUX ) ;
2017-05-17 23:31:52 +00:00
}
else if ( wcscmp ( FileSystem - > FileSystemName , L " NTFS " ) = = 0 )
{
SetPartitionType ( PartEntry , PARTITION_IFS ) ;
}
# endif
else
{
/* Unknown file system? */
DPRINT1 ( " Unknown file system \" %S \" ? \n " , FileSystem - > FileSystemName ) ;
return FALSE ;
}
//
// FIXME: Do this now, or after the partition was actually formatted??
//
/* Set the new partition's file system proper */
PartEntry - > FormatState = Formatted ; // Well... This may be set after the real formatting takes place (in which case we should change the FormatState to another value)
PartEntry - > FileSystem = FileSystem ;
return TRUE ;
}
[SETUPLIB][USETUP] Introduce a 'SetupLib' library. CORE-13544
- Create the beginnings of a "setuplib" library, whose aim is to be shared between the (currently existing) 1st-stage text-mode installer, and the (future) 1st-stage GUI installer.
- Finish to split the GenList and PartList codes into their UI part, which remain in usetup, and their algorithmic part, which go into setuplib.
- Move SetMountedDeviceValue into the PartList module.
- Split the FileSystem list code into its UI and the algorithmic part (which goes into setuplib under the name fsutil.c).
* The algo part is meant to be able to manage the filesystems available on the running system, similarly to what is mostly done (in scattered form) in fmifs, format, chkdsk / autochk codes...
It also manages the partition filesystem recognition, using OS routines.
* The UI part manages the FS list as it appears on screen, showing only the possible FSes that can be used to format the selected partition (a bit similar to what we do in the shell32's drive.c, etc...).
- Adapt the calling code to these changes.
- Remove some "host" code that was dating back from the dark old times.
svn path=/branches/setup_improvements/; revision=74570
svn path=/branches/setup_improvements/; revision=74659
2017-05-17 23:37:41 +00:00
/* EOF */