ReactOS  0.4.13-dev-242-g611e6d7
fsutil.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Setup Library
3  * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE: Filesystem support functions
5  * COPYRIGHT: Copyright 2003-2019 Casper S. Hornstrup (chorns@users.sourceforge.net)
6  * Copyright 2017-2019 Hermes Belusca-Maito
7  */
8 
9 //
10 // See also: https://git.reactos.org/?p=reactos.git;a=blob;f=reactos/dll/win32/fmifs/init.c;h=e895f5ef9cae4806123f6bbdd3dfed37ec1c8d33;hb=b9db9a4e377a2055f635b2fb69fef4e1750d219c
11 // for how to get FS providers in a dynamic way. In the (near) future we may
12 // consider merging some of this code with us into a fmifs / fsutil / fslib library...
13 //
14 
15 /* INCLUDES *****************************************************************/
16 
17 #include "precomp.h"
18 
19 #include "fsutil.h"
20 #include "partlist.h"
21 
22 #include <fslib/vfatlib.h>
23 #include <fslib/btrfslib.h>
24 // #include <fslib/ext2lib.h>
25 // #include <fslib/ntfslib.h>
26 
27 #define NDEBUG
28 #include <debug.h>
29 
30 
31 /* LOCALS *******************************************************************/
32 
34 typedef struct _FILE_SYSTEM
35 {
40 
41 /* The list of file systems on which we can install ReactOS */
43 {
44  /* NOTE: The FAT formatter automatically determines
45  * whether it will use FAT-16 or FAT-32. */
46  { L"FAT" , VfatFormat, VfatChkdsk },
47 #if 0
48  { L"FAT32", VfatFormat, VfatChkdsk }, // Do we support specific FAT sub-formats specifications?
49  { L"FATX" , VfatxFormat, VfatxChkdsk },
50  { L"NTFS" , NtfsFormat, NtfsChkdsk },
51 #endif
52  { L"BTRFS", BtrfsFormatEx, BtrfsChkdskEx },
53 #if 0
54  { L"EXT2" , Ext2Format, Ext2Chkdsk },
55  { L"EXT3" , Ext2Format, Ext2Chkdsk },
56  { L"EXT4" , Ext2Format, Ext2Chkdsk },
57  { L"FFS" , FfsFormat , FfsChkdsk },
58  { L"REISERFS", ReiserfsFormat, ReiserfsChkdsk },
59 #endif
60 };
61 
62 
63 /* FUNCTIONS ****************************************************************/
64 
66 BOOLEAN
68  IN ULONG Index,
69  OUT PCWSTR* FileSystemName)
70 {
72  return FALSE;
73 
74  *FileSystemName = RegisteredFileSystems[Index].FileSystemName;
75 
76  return TRUE;
77 }
78 
79 
81 static PFILE_SYSTEM
83  IN PCWSTR FileSystemName)
84 {
85 #if 0 // Reenable when the list of registered FSes will again be dynamic
86 
87  PLIST_ENTRY ListEntry;
88  PFILE_SYSTEM_ITEM Item;
89 
90  ListEntry = List->ListHead.Flink;
91  while (ListEntry != &List->ListHead)
92  {
93  Item = CONTAINING_RECORD(ListEntry, FILE_SYSTEM_ITEM, ListEntry);
94  if (Item->FileSystemName &&
95  (wcsicmp(FileSystemName, Item->FileSystemName) == 0 ||
96  /* Map FAT32 back to FAT */
97  (wcsicmp(FileSystemName, L"FAT32") == 0 && wcsicmp(Item->FileSystemName, L"FAT") == 0)))
98  {
99  return Item;
100  }
101 
102  ListEntry = ListEntry->Flink;
103  }
104 
105 #else
106 
109 
110  ASSERT(FileSystems && Count != 0);
111 
112  while (Count--)
113  {
114  if (FileSystems->FileSystemName &&
115  (wcsicmp(FileSystemName, FileSystems->FileSystemName) == 0 ||
116  /* Map FAT32 back to FAT */
117  (wcsicmp(FileSystemName, L"FAT32") == 0 && wcsicmp(FileSystems->FileSystemName, L"FAT") == 0)))
118  {
119  return FileSystems;
120  }
121 
122  ++FileSystems;
123  }
124 
125 #endif
126 
127  return NULL;
128 }
129 
130 
131 //
132 // FileSystem recognition, using NT OS functionality
133 //
134 
135 /* NOTE: Ripped & adapted from base/system/autochk/autochk.c */
136 NTSTATUS
138  IN HANDLE PartitionHandle,
139  IN OUT PWSTR FileSystemName,
140  IN SIZE_T FileSystemNameSize)
141 {
146 
147  /* Retrieve the FS attributes */
148  Status = NtQueryVolumeInformationFile(PartitionHandle,
149  &IoStatusBlock,
150  FileFsAttribute,
151  sizeof(Buffer),
153  if (!NT_SUCCESS(Status))
154  {
155  DPRINT1("NtQueryVolumeInformationFile failed, Status 0x%08lx\n", Status);
156  return Status;
157  }
158 
159  if (FileSystemNameSize < FileFsAttribute->FileSystemNameLength + sizeof(WCHAR))
161 
162  return RtlStringCbCopyNW(FileSystemName, FileSystemNameSize,
163  FileFsAttribute->FileSystemName,
164  FileFsAttribute->FileSystemNameLength);
165 }
166 
167 NTSTATUS
169  IN PUNICODE_STRING PartitionPath,
170  IN OUT PWSTR FileSystemName,
171  IN SIZE_T FileSystemNameSize)
172 {
175  HANDLE PartitionHandle;
177 
178  /* Open the partition */
180  PartitionPath,
182  NULL,
183  NULL);
184  Status = NtOpenFile(&PartitionHandle,
185  FILE_GENERIC_READ /* | SYNCHRONIZE */,
187  &IoStatusBlock,
189  0 /* FILE_SYNCHRONOUS_IO_NONALERT */);
190  if (!NT_SUCCESS(Status))
191  {
192  DPRINT1("Failed to open partition '%wZ', Status 0x%08lx\n", PartitionPath, Status);
193  return Status;
194  }
195 
196  /* Retrieve the FS attributes */
197  Status = GetFileSystemNameByHandle(PartitionHandle, FileSystemName, FileSystemNameSize);
198  if (!NT_SUCCESS(Status))
199  {
200  DPRINT1("GetFileSystemNameByHandle() failed for partition '%wZ', Status 0x%08lx\n",
201  PartitionPath, Status);
202  }
203 
204  /* Close the partition */
205  NtClose(PartitionHandle);
206 
207  return Status;
208 }
209 
210 NTSTATUS
212  IN PCWSTR Partition,
213  IN OUT PWSTR FileSystemName,
214  IN SIZE_T FileSystemNameSize)
215 {
216  UNICODE_STRING PartitionPath;
217 
218  RtlInitUnicodeString(&PartitionPath, Partition);
219  return GetFileSystemName_UStr(&PartitionPath,
220  FileSystemName,
221  FileSystemNameSize);
222 }
223 
224 NTSTATUS
226  IN HANDLE PartitionHandle,
228  IN OUT PWSTR FileSystemName,
229  IN SIZE_T FileSystemNameSize)
230 {
232 
233  if (FileSystemNameSize < sizeof(WCHAR))
235 
236  *FileSystemName = L'\0';
237 
238  /* Try to infer a file system using NT file system recognition */
239  Status = GetFileSystemNameByHandle(PartitionHandle,
240  FileSystemName,
241  FileSystemNameSize);
242  if (NT_SUCCESS(Status) && *FileSystemName)
243  {
244  goto Quit;
245  }
246 
247  /*
248  * Try to infer a preferred file system for this partition, given its ID.
249  *
250  * WARNING: This is partly a hack, since partitions with the same ID can
251  * be formatted with different file systems: for example, usual Linux
252  * partitions that are formatted in EXT2/3/4, ReiserFS, etc... have the
253  * same partition ID 0x83.
254  *
255  * The proper fix is to make a function that detects the existing FS
256  * from a given partition (not based on the partition ID).
257  * On the contrary, for unformatted partitions with a given ID, the
258  * following code is OK.
259  */
260  if ((PartitionType == PARTITION_FAT_12) ||
264  {
265  /* FAT12 or FAT16 */
266  Status = RtlStringCbCopyW(FileSystemName, FileSystemNameSize, L"FAT");
267  }
268  else if ((PartitionType == PARTITION_FAT32) ||
270  {
271  Status = RtlStringCbCopyW(FileSystemName, FileSystemNameSize, L"FAT32");
272  }
273  else if (PartitionType == PARTITION_LINUX)
274  {
275  // WARNING: See the warning above.
276  /* Could also be EXT2/3/4, ReiserFS, ... */
277  Status = RtlStringCbCopyW(FileSystemName, FileSystemNameSize, L"BTRFS");
278  }
279  else if (PartitionType == PARTITION_IFS)
280  {
281  // WARNING: See the warning above.
282  /* Could also be HPFS */
283  Status = RtlStringCbCopyW(FileSystemName, FileSystemNameSize, L"NTFS");
284  }
285 
286 Quit:
287  if (*FileSystemName)
288  {
289  // WARNING: We cannot write on this FS yet!
291  {
292  DPRINT1("Recognized file system '%S' that doesn't have write support yet!\n",
293  FileSystemName);
294  }
295  }
296 
297  DPRINT1("InferFileSystem -- PartitionType: 0x%02X ; FileSystem (guessed): %S\n",
298  PartitionType, *FileSystemName ? FileSystemName : L"None");
299 
300  return Status;
301 }
302 
303 NTSTATUS
305  IN PCWSTR Partition,
307  IN OUT PWSTR FileSystemName,
308  IN SIZE_T FileSystemNameSize)
309 {
311  UNICODE_STRING PartitionPath;
313  HANDLE PartitionHandle;
315 
316  /* Open the partition */
317  RtlInitUnicodeString(&PartitionPath, Partition);
319  &PartitionPath,
321  NULL,
322  NULL);
323  Status = NtOpenFile(&PartitionHandle,
324  FILE_GENERIC_READ /* | SYNCHRONIZE */,
326  &IoStatusBlock,
328  0 /* FILE_SYNCHRONOUS_IO_NONALERT */);
329  if (!NT_SUCCESS(Status))
330  {
331  DPRINT1("Failed to open partition '%wZ', Status 0x%08lx\n", &PartitionPath, Status);
332  return Status;
333  }
334 
335  /* Retrieve the FS */
336  Status = InferFileSystemByHandle(PartitionHandle,
338  FileSystemName,
339  FileSystemNameSize);
340 
341  /* Close the partition */
342  NtClose(PartitionHandle);
343 
344  return Status;
345 }
346 
348 NTSTATUS
350  IN PUNICODE_STRING DriveRoot,
351  IN PCWSTR FileSystemName,
354  IN BOOLEAN CheckOnlyIfDirty,
355  IN BOOLEAN ScanDrive,
357 {
359 
360  FileSystem = GetFileSystemByName(FileSystemName);
361 
362  if (!FileSystem || !FileSystem->ChkdskFunc)
363  {
364  // BOOLEAN Argument = FALSE;
365  // Callback(DONE, 0, &Argument);
366  return STATUS_NOT_SUPPORTED;
367  }
368 
369  return FileSystem->ChkdskFunc(DriveRoot,
370  FixErrors,
371  Verbose,
372  CheckOnlyIfDirty,
373  ScanDrive,
374  Callback);
375 }
376 
377 NTSTATUS
379  IN PCWSTR DriveRoot,
380  IN PCWSTR FileSystemName,
383  IN BOOLEAN CheckOnlyIfDirty,
384  IN BOOLEAN ScanDrive,
386 {
387  UNICODE_STRING DriveRootU;
388 
389  RtlInitUnicodeString(&DriveRootU, DriveRoot);
390  return ChkdskFileSystem_UStr(&DriveRootU,
391  FileSystemName,
392  FixErrors,
393  Verbose,
394  CheckOnlyIfDirty,
395  ScanDrive,
396  Callback);
397 }
398 
399 
401 NTSTATUS
403  IN PUNICODE_STRING DriveRoot,
404  IN PCWSTR FileSystemName,
405  IN FMIFS_MEDIA_FLAG MediaFlag,
410 {
412 
413  FileSystem = GetFileSystemByName(FileSystemName);
414 
415  if (!FileSystem || !FileSystem->FormatFunc)
416  {
417  // BOOLEAN Argument = FALSE;
418  // Callback(DONE, 0, &Argument);
419  return STATUS_NOT_SUPPORTED;
420  }
421 
422  return FileSystem->FormatFunc(DriveRoot,
423  MediaFlag,
424  Label,
425  QuickFormat,
426  ClusterSize,
427  Callback);
428 }
429 
430 NTSTATUS
432  IN PCWSTR DriveRoot,
433  IN PCWSTR FileSystemName,
434  IN FMIFS_MEDIA_FLAG MediaFlag,
435  IN PCWSTR Label,
439 {
440  UNICODE_STRING DriveRootU;
441  UNICODE_STRING LabelU;
442 
443  RtlInitUnicodeString(&DriveRootU, DriveRoot);
444  RtlInitUnicodeString(&LabelU, Label);
445 
446  return FormatFileSystem_UStr(&DriveRootU,
447  FileSystemName,
448  MediaFlag,
449  &LabelU,
450  QuickFormat,
451  ClusterSize,
452  Callback);
453 }
454 
455 
456 UCHAR
459  IN PULARGE_INTEGER StartSector,
461 {
462  ASSERT(FileSystem && StartSector && SectorCount);
463 
464  if (wcsicmp(FileSystem, L"FAT") == 0 ||
465  wcsicmp(FileSystem, L"FAT32") == 0 ||
466  wcsicmp(FileSystem, L"RAW") == 0)
467  {
468  if (SectorCount->QuadPart < 8192)
469  {
470  /* FAT12 CHS partition (disk is smaller than 4.1MB) */
471  return PARTITION_FAT_12;
472  }
473  else if (StartSector->QuadPart < 1450560)
474  {
475  /* Partition starts below the 8.4GB boundary ==> CHS partition */
476 
477  if (SectorCount->QuadPart < 65536)
478  {
479  /* FAT16 CHS partition (partition size < 32MB) */
480  return PARTITION_FAT_16;
481  }
482  else if (SectorCount->QuadPart < 1048576)
483  {
484  /* FAT16 CHS partition (partition size < 512MB) */
485  return PARTITION_HUGE;
486  }
487  else
488  {
489  /* FAT32 CHS partition (partition size >= 512MB) */
490  return PARTITION_FAT32;
491  }
492  }
493  else
494  {
495  /* Partition starts above the 8.4GB boundary ==> LBA partition */
496 
497  if (SectorCount->QuadPart < 1048576)
498  {
499  /* FAT16 LBA partition (partition size < 512MB) */
500  return PARTITION_XINT13;
501  }
502  else
503  {
504  /* FAT32 LBA partition (partition size >= 512MB) */
505  return PARTITION_FAT32_XINT13;
506  }
507  }
508  }
509  else if (wcsicmp(FileSystem, L"NTFS") == 0)
510  {
511  return PARTITION_IFS;
512  }
513  else if (wcsicmp(FileSystem, L"BTRFS") == 0 ||
514  wcsicmp(FileSystem, L"EXT2") == 0 ||
515  wcsicmp(FileSystem, L"EXT3") == 0 ||
516  wcsicmp(FileSystem, L"EXT4") == 0 ||
517  wcsicmp(FileSystem, L"FFS") == 0 ||
518  wcsicmp(FileSystem, L"REISERFS") == 0)
519  {
520  return PARTITION_LINUX;
521  }
522  else
523  {
524  /* Unknown file system */
525  DPRINT1("Unknown file system '%S'\n", FileSystem);
526  return PARTITION_ENTRY_UNUSED;
527  }
528 }
529 
530 
531 //
532 // Formatting routines
533 //
534 
535 BOOLEAN
537  IN struct _PARTENTRY* PartEntry,
538  IN PCWSTR FileSystemName)
539 {
541 
542  if (!FileSystemName || !*FileSystemName)
543  {
544  DPRINT1("No file system specified?\n");
545  return FALSE;
546  }
547 
548  PartitionType = FileSystemToPartitionType(FileSystemName,
549  &PartEntry->StartSector,
550  &PartEntry->SectorCount);
552  {
553  /* Unknown file system */
554  DPRINT1("Unknown file system '%S'\n", FileSystemName);
555  return FALSE;
556  }
557 
558  SetPartitionType(PartEntry, PartitionType);
559 
560 //
561 // FIXME: Do this now, or after the partition was actually formatted??
562 //
563  /* Set the new partition's file system proper */
564  RtlStringCbCopyW(PartEntry->FileSystem,
565  sizeof(PartEntry->FileSystem),
566  FileSystemName);
567 
568  return TRUE;
569 }
570 
571 /* EOF */
#define PARTITION_FAT32
Definition: disk.h:95
#define FILE_GENERIC_READ
Definition: nt_native.h:653
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:179
NTSTATUS GetFileSystemName_UStr(IN PUNICODE_STRING PartitionPath, IN OUT PWSTR FileSystemName, IN SIZE_T FileSystemNameSize)
Definition: fsutil.c:168
NTSTATUS NTAPI VfatxChkdsk(IN PUNICODE_STRING DriveRoot, IN BOOLEAN FixErrors, IN BOOLEAN Verbose, IN BOOLEAN CheckOnlyIfDirty, IN BOOLEAN ScanDrive, IN PFMIFSCALLBACK Callback)
Definition: vfatxlib.c:156
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
struct _FILE_SYSTEM FILE_SYSTEM
const uint16_t * PCWSTR
Definition: typedefs.h:55
#define IN
Definition: typedefs.h:38
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI NtfsChkdsk(IN PUNICODE_STRING DriveRoot, IN BOOLEAN FixErrors, IN BOOLEAN Verbose, IN BOOLEAN CheckOnlyIfDirty, IN BOOLEAN ScanDrive, IN PFMIFSCALLBACK Callback)
Definition: ntfslib.c:27
PWCHAR FileSystem
Definition: format.c:72
NTSTATUS(NTAPI * CHKDSKEX)(IN PUNICODE_STRING DriveRoot, IN BOOLEAN FixErrors, IN BOOLEAN Verbose, IN BOOLEAN CheckOnlyIfDirty, IN BOOLEAN ScanDrive, IN PFMIFSCALLBACK Callback)
Definition: fmifs.h:207
NTSTATUS NTAPI FfsFormat(IN PUNICODE_STRING DriveRoot, IN FMIFS_MEDIA_FLAG MediaFlag, IN PUNICODE_STRING Label, IN BOOLEAN QuickFormat, IN ULONG ClusterSize, IN PFMIFSCALLBACK Callback)
Definition: ffslib.c:14
BOOL Verbose
Definition: chkdsk.c:72
uint16_t * PWSTR
Definition: typedefs.h:54
NTSTATUS NTAPI ReiserfsChkdsk(IN PUNICODE_STRING DriveRoot, IN BOOLEAN FixErrors, IN BOOLEAN Verbose, IN BOOLEAN CheckOnlyIfDirty, IN BOOLEAN ScanDrive, IN PFMIFSCALLBACK Callback)
Definition: reiserfslib.c:27
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS GetFileSystemName(IN PCWSTR Partition, IN OUT PWSTR FileSystemName, IN SIZE_T FileSystemNameSize)
Definition: fsutil.c:211
NTSTATUS(NTAPI * FORMATEX)(IN PUNICODE_STRING DriveRoot, IN FMIFS_MEDIA_FLAG MediaFlag, IN PUNICODE_STRING Label, IN BOOLEAN QuickFormat, IN ULONG ClusterSize, IN PFMIFSCALLBACK Callback)
Definition: fmifs.h:198
NTSTATUS NTAPI ReiserfsFormat(IN PUNICODE_STRING DriveRoot, IN FMIFS_MEDIA_FLAG MediaFlag, IN PUNICODE_STRING Label, IN BOOLEAN QuickFormat, IN ULONG ClusterSize, IN PFMIFSCALLBACK Callback)
Definition: reiserfslib.c:14
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
NTSTATUS GetFileSystemNameByHandle(IN HANDLE PartitionHandle, IN OUT PWSTR FileSystemName, IN SIZE_T FileSystemNameSize)
Definition: fsutil.c:137
NTSTATUS NTAPI NtfsFormat(IN PUNICODE_STRING DriveRoot, IN FMIFS_MEDIA_FLAG MediaFlag, IN PUNICODE_STRING Label, IN BOOLEAN QuickFormat, IN ULONG ClusterSize, IN PFMIFSCALLBACK Callback)
Definition: ntfslib.c:14
struct _FILE_FS_ATTRIBUTE_INFORMATION FILE_FS_ATTRIBUTE_INFORMATION
#define FILE_SHARE_READ
Definition: compat.h:125
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
NTSTATUS NTAPI VfatxFormat(PUNICODE_STRING DriveRoot, FMIFS_MEDIA_FLAG MediaFlag, PUNICODE_STRING Label, BOOLEAN QuickFormat, ULONG ClusterSize, 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)
Definition: fsutil.c:378
#define PARTITION_XINT13
Definition: disk.h:97
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:86
NTSTATUS NTAPI BtrfsFormatEx(IN PUNICODE_STRING DriveRoot, IN FMIFS_MEDIA_FLAG MediaFlag, IN PUNICODE_STRING Label, IN BOOLEAN QuickFormat, IN ULONG ClusterSize, IN PFMIFSCALLBACK Callback)
NTSTATUS InferFileSystemByHandle(IN HANDLE PartitionHandle, IN UCHAR PartitionType, IN OUT PWSTR FileSystemName, IN SIZE_T FileSystemNameSize)
Definition: fsutil.c:225
#define PARTITION_HUGE
Definition: disk.h:92
NTSTRSAFEAPI RtlStringCbCopyNW(_Out_writes_bytes_(cbDest) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_reads_bytes_(cbToCopy) STRSAFE_LPCWSTR pszSrc, _In_ size_t cbToCopy)
Definition: ntstrsafe.h:411
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
FORMATEX FormatFunc
Definition: fsutil.c:37
NTSTATUS NTAPI NtQueryVolumeInformationFile(IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock, OUT PVOID FsInformation, IN ULONG Length, IN FS_INFORMATION_CLASS FsInformationClass)
Definition: iofunc.c:4084
Definition: bufpool.h:45
#define PARTITION_IFS
Definition: disk.h:93
BOOL QuickFormat
Definition: format.c:66
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
NTSTATUS NTAPI BtrfsChkdskEx(IN PUNICODE_STRING DriveRoot, IN BOOLEAN FixErrors, IN BOOLEAN Verbose, IN BOOLEAN CheckOnlyIfDirty, IN BOOLEAN ScanDrive, IN PFMIFSCALLBACK Callback)
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3951
LIST_ENTRY List
Definition: psmgr.c:57
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static FILE_SYSTEM RegisteredFileSystems[]
Definition: fsutil.c:42
#define MAX_PATH
Definition: compat.h:26
DWORD ClusterSize
Definition: format.c:67
static const UCHAR Index[8]
Definition: usbohci.c:18
struct _FILE_FS_ATTRIBUTE_INFORMATION * PFILE_FS_ATTRIBUTE_INFORMATION
#define PARTITION_FAT_16
Definition: disk.h:90
FILESYSTEM_CHKDSK FileSystems[10]
Definition: autochk.c:48
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
unsigned char UCHAR
Definition: xmlstorage.h:181
BOOLEAN GetRegisteredFileSystems(IN ULONG Index, OUT PCWSTR *FileSystemName)
Definition: fsutil.c:67
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)
Definition: fsutil.c:349
static const WCHAR L[]
Definition: oid.c:1250
NTSTATUS NTAPI VfatFormat(IN PUNICODE_STRING DriveRoot, IN FMIFS_MEDIA_FLAG MediaFlag, IN PUNICODE_STRING Label, IN BOOLEAN QuickFormat, IN ULONG ClusterSize, IN PFMIFSCALLBACK Callback)
Definition: vfatlib.c:50
Definition: typedefs.h:117
ULONG SectorCount
Definition: part_xbox.c:32
#define wcsicmp
Definition: string.h:1152
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)
Definition: fsutil.c:431
VOID SetPartitionType(IN PPARTENTRY PartEntry, IN UCHAR PartitionType)
Definition: partlist.c:3981
Status
Definition: gdiplustypes.h:24
static PFILE_SYSTEM GetFileSystemByName(IN PCWSTR FileSystemName)
Definition: fsutil.c:82
NTSTATUS NTAPI FfsChkdsk(IN PUNICODE_STRING DriveRoot, IN BOOLEAN FixErrors, IN BOOLEAN Verbose, IN BOOLEAN CheckOnlyIfDirty, IN BOOLEAN ScanDrive, IN PFMIFSCALLBACK Callback)
Definition: ffslib.c:27
ULONG_PTR SIZE_T
Definition: typedefs.h:78
CHKDSKEX ChkdskFunc
Definition: fsutil.c:38
BOOLEAN(NTAPI * PFMIFSCALLBACK)(IN CALLBACKCOMMAND Command, IN ULONG SubAction, IN PVOID ActionInfo)
Definition: fmifs.h:89
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
NTSTATUS InferFileSystem(IN PCWSTR Partition, IN UCHAR PartitionType, IN OUT PWSTR FileSystemName, IN SIZE_T FileSystemNameSize)
Definition: fsutil.c:304
NTSTATUS NTAPI Ext2Chkdsk(IN PUNICODE_STRING DriveRoot, IN BOOLEAN FixErrors, IN BOOLEAN Verbose, IN BOOLEAN CheckOnlyIfDirty, IN BOOLEAN ScanDrive, IN PFMIFSCALLBACK Callback)
Definition: Mke2fs.c:1008
struct _FILE_SYSTEM * PFILE_SYSTEM
#define PARTITION_LINUX
Definition: partlist.c:36
BOOL FixErrors
Definition: chkdsk.c:69
#define DPRINT1
Definition: precomp.h:8
#define OUT
Definition: typedefs.h:39
CHAR PartitionType
Definition: part_xbox.c:33
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)
Definition: fsutil.c:402
#define PARTITION_FAT_12
Definition: disk.h:87
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
PWCHAR Label
Definition: format.c:70
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
UCHAR FileSystemToPartitionType(IN PCWSTR FileSystem, IN PULARGE_INTEGER StartSector, IN PULARGE_INTEGER SectorCount)
Definition: fsutil.c:457
#define PARTITION_FAT32_XINT13
Definition: disk.h:96
PCWSTR FileSystemName
Definition: fsutil.c:36
LPFNPSPCALLBACK Callback
Definition: desk.c:111
NTSTATUS NTAPI VfatChkdsk(IN PUNICODE_STRING DriveRoot, IN BOOLEAN FixErrors, IN BOOLEAN Verbose, IN BOOLEAN CheckOnlyIfDirty, IN BOOLEAN ScanDrive, IN PFMIFSCALLBACK Callback)
Definition: vfatlib.c:375
BOOLEAN PreparePartitionForFormatting(IN struct _PARTENTRY *PartEntry, IN PCWSTR FileSystemName)
Definition: fsutil.c:536
NTSTATUS NTAPI Ext2Format(IN PUNICODE_STRING DriveRoot, IN FMIFS_MEDIA_FLAG MediaFlag, IN PUNICODE_STRING Label, IN BOOLEAN QuickFormat, IN ULONG ClusterSize, IN PFMIFSCALLBACK Callback)
Definition: Mke2fs.c:803
FMIFS_MEDIA_FLAG
Definition: fmifs.h:37