[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+)
|
[FSLIB][FMIFS][AUTOCHK][SETUPLIB] Use more Windows-compatible (but not fully compatible yet) Format() and Chkdsk() ULIB functions.
[AUTOCHK] Add also support for scanning FATX volumes.
The Format(), FormatEx(), Chkdsk(), ChkdskEx() functions exposed by the
U*.DLL user-mode FS library dlls are different (and have different
prototypes) than the similarly-named functions exported by FMIFS.DLL .
In particular, what we used to call "xxxChkdskEx()" and "xxxFormatEx()"
in our U*.DLL libraries actually correspond more, from their arguments,
to the "Chkdsk()" and "Format()" functions in Windows' U*.DLL . Their
*Ex() counterparts instead take most of the parameters through a
structure passed by pointer.
On FMIFS.DLL side, while FMIFS!Chkdsk() calls U*.DLL!Chkdsk() and
FMIFS!ChkdskEx() calls U*.DLL!ChkdskEx() (and we do not implement these
*Ex() functions at the moment), both FMIFS!Format() and FMIFS!FormatEx()
call U*.DLL!Format() instead, while FMIFS!FormatEx2() calls
U*.DLL!FormatEx() (that we do not implement yet either) !!
To improve that, refactor the calls to these U*.DLL functions so as to
respect the more compatible prototypes: They contain the correct number
of parameters in a compatible order. However, some of the parameters do
not have the same types yet: the strings are kept here in PUNICODE_STRINGS,
while on Windows they are passed via an undocumented DSTRING struct, and
the FMIFS callback is instead a MESSAGE struct/class on Windows.
Finally, the MEDIA_TYPE parameter in U*.DLL!Format() is equivalent, yet
not fully 100% in 1-to-1 correspondence, with the FMIFS_MEDIA_FLAG used
in the corresponding FMIFS.DLL functions.
One thing to notice is that the U*.DLL!Format() (and the Ex) functions
support a BOOLEAN (a flag resp.) for telling that a backwards-compatible
FS version should be used instead of the (default) latest FS version.
This is used e.g. by the FAT FS, where by default FAT32 is selected
(depending also on other constraints like, the disk and the partition
sizes), unless that bit is set in which case, FAT16 (or 12) is used.
2020-11-22 04:35:37 +00:00
|
|
|
* PURPOSE: Filesystem Format and ChkDsk support functions.
|
2019-02-24 16:52:33 +00:00
|
|
|
* COPYRIGHT: Copyright 2003-2019 Casper S. Hornstrup (chorns@users.sourceforge.net)
|
2020-10-17 18:29:47 +00:00
|
|
|
* Copyright 2017-2020 Hermes Belusca-Maito
|
[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
|
|
|
*/
|
|
|
|
|
2017-08-26 11:42:32 +00:00
|
|
|
#pragma once
|
|
|
|
|
[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 <fmifs/fmifs.h>
|
|
|
|
|
2019-02-24 16:52:33 +00:00
|
|
|
/** QueryAvailableFileSystemFormat() **/
|
|
|
|
BOOLEAN
|
|
|
|
GetRegisteredFileSystems(
|
|
|
|
IN ULONG Index,
|
|
|
|
OUT PCWSTR* 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
|
|
|
|
2019-02-24 16:52:33 +00:00
|
|
|
|
|
|
|
/** ChkdskEx() **/
|
|
|
|
NTSTATUS
|
|
|
|
ChkdskFileSystem_UStr(
|
|
|
|
IN PUNICODE_STRING DriveRoot,
|
|
|
|
IN PCWSTR FileSystemName,
|
|
|
|
IN BOOLEAN FixErrors,
|
|
|
|
IN BOOLEAN Verbose,
|
|
|
|
IN BOOLEAN CheckOnlyIfDirty,
|
|
|
|
IN BOOLEAN ScanDrive,
|
|
|
|
IN PFMIFSCALLBACK Callback);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ChkdskFileSystem(
|
|
|
|
IN PCWSTR DriveRoot,
|
|
|
|
IN PCWSTR FileSystemName,
|
|
|
|
IN BOOLEAN FixErrors,
|
|
|
|
IN BOOLEAN Verbose,
|
|
|
|
IN BOOLEAN CheckOnlyIfDirty,
|
|
|
|
IN BOOLEAN ScanDrive,
|
|
|
|
IN PFMIFSCALLBACK Callback);
|
[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
|
|
|
|
|
|
|
|
2019-02-24 16:52:33 +00:00
|
|
|
/** FormatEx() **/
|
|
|
|
NTSTATUS
|
|
|
|
FormatFileSystem_UStr(
|
|
|
|
IN PUNICODE_STRING DriveRoot,
|
|
|
|
IN PCWSTR FileSystemName,
|
|
|
|
IN FMIFS_MEDIA_FLAG MediaFlag,
|
|
|
|
IN PUNICODE_STRING Label,
|
|
|
|
IN BOOLEAN QuickFormat,
|
|
|
|
IN ULONG ClusterSize,
|
|
|
|
IN PFMIFSCALLBACK Callback);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
FormatFileSystem(
|
|
|
|
IN PCWSTR DriveRoot,
|
|
|
|
IN PCWSTR FileSystemName,
|
|
|
|
IN FMIFS_MEDIA_FLAG MediaFlag,
|
|
|
|
IN PCWSTR Label,
|
|
|
|
IN BOOLEAN QuickFormat,
|
|
|
|
IN ULONG ClusterSize,
|
|
|
|
IN PFMIFSCALLBACK Callback);
|
|
|
|
|
|
|
|
|
2020-10-17 18:29:47 +00:00
|
|
|
//
|
|
|
|
// Bootsector routines
|
|
|
|
//
|
|
|
|
|
|
|
|
#define FAT_BOOTSECTOR_SIZE (1 * SECTORSIZE)
|
|
|
|
#define FAT32_BOOTSECTOR_SIZE (1 * SECTORSIZE) // Counts only the primary sector.
|
|
|
|
#define BTRFS_BOOTSECTOR_SIZE (3 * SECTORSIZE)
|
|
|
|
|
|
|
|
typedef NTSTATUS
|
|
|
|
(/*NTAPI*/ *PFS_INSTALL_BOOTCODE)(
|
|
|
|
IN PCWSTR SrcPath, // Bootsector source file (on the installation medium)
|
|
|
|
IN HANDLE DstPath, // Where to save the bootsector built from the source + partition information
|
|
|
|
IN HANDLE RootPartition); // Partition holding the (old) bootsector data information
|
|
|
|
|
|
|
|
NTSTATUS
|
2020-10-19 21:49:26 +00:00
|
|
|
InstallFatBootCode(
|
2020-10-17 18:29:47 +00:00
|
|
|
IN PCWSTR SrcPath,
|
|
|
|
IN HANDLE DstPath,
|
|
|
|
IN HANDLE RootPartition);
|
|
|
|
|
2020-10-19 21:49:26 +00:00
|
|
|
#define InstallFat12BootCode InstallFatBootCode
|
|
|
|
#define InstallFat16BootCode InstallFatBootCode
|
2020-10-17 18:29:47 +00:00
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
InstallFat32BootCode(
|
|
|
|
IN PCWSTR SrcPath,
|
|
|
|
IN HANDLE DstPath,
|
|
|
|
IN HANDLE RootPartition);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
InstallBtrfsBootCode(
|
|
|
|
IN PCWSTR SrcPath,
|
|
|
|
IN HANDLE DstPath,
|
|
|
|
IN HANDLE RootPartition);
|
|
|
|
|
|
|
|
|
2019-02-24 16:52:33 +00:00
|
|
|
//
|
|
|
|
// Formatting routines
|
|
|
|
//
|
|
|
|
|
2020-11-24 01:26:52 +00:00
|
|
|
NTSTATUS
|
|
|
|
ChkdskPartition(
|
|
|
|
IN PPARTENTRY PartEntry,
|
|
|
|
IN BOOLEAN FixErrors,
|
|
|
|
IN BOOLEAN Verbose,
|
|
|
|
IN BOOLEAN CheckOnlyIfDirty,
|
|
|
|
IN BOOLEAN ScanDrive,
|
|
|
|
IN PFMIFSCALLBACK Callback);
|
2017-05-17 23:31:52 +00:00
|
|
|
|
2020-11-24 01:26:52 +00:00
|
|
|
NTSTATUS
|
|
|
|
FormatPartition(
|
|
|
|
IN PPARTENTRY PartEntry,
|
|
|
|
IN PCWSTR FileSystemName,
|
|
|
|
IN FMIFS_MEDIA_FLAG MediaFlag,
|
|
|
|
IN PCWSTR Label,
|
|
|
|
IN BOOLEAN QuickFormat,
|
|
|
|
IN ULONG ClusterSize,
|
|
|
|
IN PFMIFSCALLBACK Callback);
|
2017-05-17 23:31:52 +00:00
|
|
|
|
[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 */
|