mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 12:22:22 +00:00
[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.
This commit is contained in:
parent
cdaa5d5fc7
commit
8d3e80e437
37 changed files with 742 additions and 414 deletions
|
@ -181,6 +181,7 @@ ULONG def_sector_size = 0, def_node_size = 0;
|
|||
uint64_t def_incompat_flags = BTRFS_INCOMPAT_FLAGS_EXTENDED_IREF | BTRFS_INCOMPAT_FLAGS_SKINNY_METADATA;
|
||||
uint16_t def_csum_type = CSUM_TYPE_CRC32C;
|
||||
|
||||
#ifndef __REACTOS__
|
||||
// the following definitions come from fmifs.h in ReactOS
|
||||
|
||||
typedef struct {
|
||||
|
@ -237,12 +238,32 @@ typedef enum {
|
|||
|
||||
typedef BOOLEAN (NTAPI* PFMIFSCALLBACK)(CALLBACKCOMMAND Command, ULONG SubAction, PVOID ActionInfo);
|
||||
|
||||
#else
|
||||
|
||||
#include <fmifs/fmifs.h>
|
||||
|
||||
#endif // __REACTOS__
|
||||
|
||||
#ifndef __REACTOS__
|
||||
NTSTATUS WINAPI ChkdskEx(PUNICODE_STRING DriveRoot, BOOLEAN FixErrors, BOOLEAN Verbose, BOOLEAN CheckOnlyIfDirty,
|
||||
#else
|
||||
NTSTATUS NTAPI BtrfsChkdskEx(PUNICODE_STRING DriveRoot, BOOLEAN FixErrors, BOOLEAN Verbose, BOOLEAN CheckOnlyIfDirty,
|
||||
#endif
|
||||
BOOLEAN ScanDrive, PFMIFSCALLBACK Callback) {
|
||||
#else
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
BtrfsChkdsk(
|
||||
IN PUNICODE_STRING DriveRoot,
|
||||
IN PFMIFSCALLBACK Callback,
|
||||
IN BOOLEAN FixErrors,
|
||||
IN BOOLEAN Verbose,
|
||||
IN BOOLEAN CheckOnlyIfDirty,
|
||||
IN BOOLEAN ScanDrive,
|
||||
IN PVOID pUnknown1,
|
||||
IN PVOID pUnknown2,
|
||||
IN PVOID pUnknown3,
|
||||
IN PVOID pUnknown4,
|
||||
IN PULONG ExitStatus)
|
||||
{
|
||||
#endif
|
||||
// STUB
|
||||
|
||||
if (Callback) {
|
||||
|
@ -254,7 +275,12 @@ NTSTATUS NTAPI BtrfsChkdskEx(PUNICODE_STRING DriveRoot, BOOLEAN FixErrors, BOOLE
|
|||
Callback(OUTPUT, 0, &TextOut);
|
||||
}
|
||||
|
||||
#ifndef __REACTOS__
|
||||
return STATUS_SUCCESS;
|
||||
#else
|
||||
*ExitStatus = (ULONG)STATUS_SUCCESS;
|
||||
return TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
static btrfs_root* add_root(LIST_ENTRY* roots, uint64_t id) {
|
||||
|
@ -1316,11 +1342,7 @@ static void check_cpu() {
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifndef __REACTOS__
|
||||
static NTSTATUS NTAPI FormatEx2(PUNICODE_STRING DriveRoot, FMIFS_MEDIA_FLAG MediaFlag, PUNICODE_STRING Label,
|
||||
#else
|
||||
NTSTATUS NTAPI BtrfsFormatEx(PUNICODE_STRING DriveRoot, FMIFS_MEDIA_FLAG MediaFlag, PUNICODE_STRING Label,
|
||||
#endif // __REACTOS__
|
||||
BOOLEAN QuickFormat, ULONG ClusterSize, PFMIFSCALLBACK Callback)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
@ -1479,14 +1501,44 @@ end:
|
|||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
#ifndef __REACTOS__
|
||||
if (Callback) {
|
||||
bool success = NT_SUCCESS(Status);
|
||||
Callback(DONE, 0, (PVOID)&success);
|
||||
}
|
||||
#endif
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
#ifdef __REACTOS__
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
BtrfsFormat(
|
||||
IN PUNICODE_STRING DriveRoot,
|
||||
IN PFMIFSCALLBACK Callback,
|
||||
IN BOOLEAN QuickFormat,
|
||||
IN BOOLEAN BackwardCompatible,
|
||||
IN MEDIA_TYPE MediaType,
|
||||
IN PUNICODE_STRING Label,
|
||||
IN ULONG ClusterSize)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
if (BackwardCompatible)
|
||||
{
|
||||
// DPRINT1("BackwardCompatible == TRUE is unsupported!\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Status = FormatEx2(DriveRoot, (FMIFS_MEDIA_FLAG)MediaType, Label, QuickFormat, ClusterSize, Callback);
|
||||
|
||||
return NT_SUCCESS(Status);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
BOOL __stdcall FormatEx(DSTRING* root, STREAM_MESSAGE* message, options* opts, uint32_t unk1) {
|
||||
UNICODE_STRING DriveRoot, Label;
|
||||
NTSTATUS Status;
|
||||
|
@ -1505,15 +1557,13 @@ BOOL __stdcall FormatEx(DSTRING* root, STREAM_MESSAGE* message, options* opts, u
|
|||
Label.Buffer = NULL;
|
||||
}
|
||||
|
||||
#ifndef __REACTOS__
|
||||
Status = FormatEx2(&DriveRoot, FMIFS_HARDDISK, &Label, opts && opts->flags & FORMAT_FLAG_QUICK_FORMAT, 0, NULL);
|
||||
#else
|
||||
Status = BtrfsFormatEx(&DriveRoot, FMIFS_HARDDISK, &Label, opts && opts->flags & FORMAT_FLAG_QUICK_FORMAT, 0, NULL);
|
||||
#endif
|
||||
|
||||
return NT_SUCCESS(Status);
|
||||
}
|
||||
|
||||
#endif // __REACTOS__
|
||||
|
||||
void __stdcall SetSizes(ULONG sector, ULONG node) {
|
||||
if (sector != 0)
|
||||
def_sector_size = sector;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue