ReactOS  0.4.13-dev-247-g0f29b3f
fsutil.h File Reference
#include <fmifs/fmifs.h>
Include dependency graph for fsutil.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

BOOLEAN GetRegisteredFileSystems (IN ULONG Index, OUT PCWSTR *FileSystemName)
 
NTSTATUS GetFileSystemNameByHandle (IN HANDLE PartitionHandle, IN OUT PWSTR FileSystemName, IN SIZE_T FileSystemNameSize)
 
NTSTATUS GetFileSystemName_UStr (IN PUNICODE_STRING PartitionPath, IN OUT PWSTR FileSystemName, IN SIZE_T FileSystemNameSize)
 
NTSTATUS GetFileSystemName (IN PCWSTR Partition, IN OUT PWSTR FileSystemName, IN SIZE_T FileSystemNameSize)
 
NTSTATUS InferFileSystemByHandle (IN HANDLE PartitionHandle, IN UCHAR PartitionType, IN OUT PWSTR FileSystemName, IN SIZE_T FileSystemNameSize)
 
NTSTATUS InferFileSystem (IN PCWSTR Partition, IN UCHAR PartitionType, IN OUT PWSTR FileSystemName, IN SIZE_T FileSystemNameSize)
 
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)
 
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)
 
UCHAR FileSystemToPartitionType (IN PCWSTR FileSystem, IN PULARGE_INTEGER StartSector, IN PULARGE_INTEGER SectorCount)
 
BOOLEAN PreparePartitionForFormatting (IN struct _PARTENTRY *PartEntry, IN PCWSTR FileSystemName)
 

Function Documentation

◆ ChkdskFileSystem()

NTSTATUS ChkdskFileSystem ( IN PCWSTR  DriveRoot,
IN PCWSTR  FileSystemName,
IN BOOLEAN  FixErrors,
IN BOOLEAN  Verbose,
IN BOOLEAN  CheckOnlyIfDirty,
IN BOOLEAN  ScanDrive,
IN PFMIFSCALLBACK  Callback 
)

Definition at line 378 of file fsutil.c.

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 }
BOOL Verbose
Definition: chkdsk.c:72
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
BOOL FixErrors
Definition: chkdsk.c:69
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
LPFNPSPCALLBACK Callback
Definition: desk.c:111

◆ ChkdskFileSystem_UStr()

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 
)

ChkdskEx()

Definition at line 349 of file fsutil.c.

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 }
PWCHAR FileSystem
Definition: format.c:72
BOOL Verbose
Definition: chkdsk.c:72
static PFILE_SYSTEM GetFileSystemByName(IN PCWSTR FileSystemName)
Definition: fsutil.c:82
BOOL FixErrors
Definition: chkdsk.c:69
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
LPFNPSPCALLBACK Callback
Definition: desk.c:111

Referenced by ChkdskFileSystem(), and ChkdskPartition().

◆ FileSystemToPartitionType()

UCHAR FileSystemToPartitionType ( IN PCWSTR  FileSystem,
IN PULARGE_INTEGER  StartSector,
IN PULARGE_INTEGER  SectorCount 
)

Definition at line 457 of file fsutil.c.

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 }
#define PARTITION_FAT32
Definition: disk.h:95
PWCHAR FileSystem
Definition: format.c:72
#define PARTITION_XINT13
Definition: disk.h:97
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:86
#define PARTITION_HUGE
Definition: disk.h:92
#define PARTITION_IFS
Definition: disk.h:93
#define PARTITION_FAT_16
Definition: disk.h:90
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
ULONG SectorCount
Definition: part_xbox.c:32
#define wcsicmp
Definition: string.h:1152
#define PARTITION_LINUX
Definition: partlist.c:36
#define DPRINT1
Definition: precomp.h:8
#define PARTITION_FAT_12
Definition: disk.h:87
#define PARTITION_FAT32_XINT13
Definition: disk.h:96

Referenced by InitializePartitionEntry(), and PreparePartitionForFormatting().

◆ FormatFileSystem()

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 at line 431 of file fsutil.c.

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 }
BOOL QuickFormat
Definition: format.c:66
DWORD ClusterSize
Definition: format.c:67
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
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
PWCHAR Label
Definition: format.c:70
LPFNPSPCALLBACK Callback
Definition: desk.c:111

Referenced by InstallFatBootcodeToFloppy().

◆ FormatFileSystem_UStr()

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 
)

FormatEx()

Definition at line 402 of file fsutil.c.

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 }
PWCHAR FileSystem
Definition: format.c:72
BOOL QuickFormat
Definition: format.c:66
DWORD ClusterSize
Definition: format.c:67
static PFILE_SYSTEM GetFileSystemByName(IN PCWSTR FileSystemName)
Definition: fsutil.c:82
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
PWCHAR Label
Definition: format.c:70
LPFNPSPCALLBACK Callback
Definition: desk.c:111

Referenced by FormatFileSystem(), and FormatPartition().

◆ GetFileSystemName()

NTSTATUS GetFileSystemName ( IN PCWSTR  Partition,
IN OUT PWSTR  FileSystemName,
IN SIZE_T  FileSystemNameSize 
)

Definition at line 211 of file fsutil.c.

215 {
216  UNICODE_STRING PartitionPath;
217 
218  RtlInitUnicodeString(&PartitionPath, Partition);
219  return GetFileSystemName_UStr(&PartitionPath,
220  FileSystemName,
221  FileSystemNameSize);
222 }
NTSTATUS GetFileSystemName_UStr(IN PUNICODE_STRING PartitionPath, IN OUT PWSTR FileSystemName, IN SIZE_T FileSystemNameSize)
Definition: fsutil.c:168
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

◆ GetFileSystemName_UStr()

NTSTATUS GetFileSystemName_UStr ( IN PUNICODE_STRING  PartitionPath,
IN OUT PWSTR  FileSystemName,
IN SIZE_T  FileSystemNameSize 
)

Definition at line 168 of file fsutil.c.

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 }
#define FILE_GENERIC_READ
Definition: nt_native.h:653
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
LONG NTSTATUS
Definition: precomp.h:26
#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
#define FILE_SHARE_READ
Definition: compat.h:125
smooth NULL
Definition: ftsmooth.c:416
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
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define DPRINT1
Definition: precomp.h:8
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106

Referenced by GetFileSystemName().

◆ GetFileSystemNameByHandle()

NTSTATUS GetFileSystemNameByHandle ( IN HANDLE  PartitionHandle,
IN OUT PWSTR  FileSystemName,
IN SIZE_T  FileSystemNameSize 
)

Definition at line 137 of file fsutil.c.

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 }
LONG NTSTATUS
Definition: precomp.h:26
struct _FILE_FS_ATTRIBUTE_INFORMATION FILE_FS_ATTRIBUTE_INFORMATION
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
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
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
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MAX_PATH
Definition: compat.h:26
struct _FILE_FS_ATTRIBUTE_INFORMATION * PFILE_FS_ATTRIBUTE_INFORMATION
unsigned char UCHAR
Definition: xmlstorage.h:181
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define DPRINT1
Definition: precomp.h:8

Referenced by GetFileSystemName_UStr(), and InferFileSystemByHandle().

◆ GetRegisteredFileSystems()

BOOLEAN GetRegisteredFileSystems ( IN ULONG  Index,
OUT PCWSTR FileSystemName 
)

QueryAvailableFileSystemFormat()

Definition at line 67 of file fsutil.c.

70 {
72  return FALSE;
73 
74  *FileSystemName = RegisteredFileSystems[Index].FileSystemName;
75 
76  return TRUE;
77 }
#define TRUE
Definition: types.h:120
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
static FILE_SYSTEM RegisteredFileSystems[]
Definition: fsutil.c:42
static const UCHAR Index[8]
Definition: usbohci.c:18
PCWSTR FileSystemName
Definition: fsutil.c:36

Referenced by InitializeFileSystemList().

◆ InferFileSystem()

NTSTATUS InferFileSystem ( IN PCWSTR  Partition,
IN UCHAR  PartitionType,
IN OUT PWSTR  FileSystemName,
IN SIZE_T  FileSystemNameSize 
)

Definition at line 304 of file fsutil.c.

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 }
#define FILE_GENERIC_READ
Definition: nt_native.h:653
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:125
NTSTATUS InferFileSystemByHandle(IN HANDLE PartitionHandle, IN UCHAR PartitionType, IN OUT PWSTR FileSystemName, IN SIZE_T FileSystemNameSize)
Definition: fsutil.c:225
smooth NULL
Definition: ftsmooth.c:416
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
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define DPRINT1
Definition: precomp.h:8
CHAR PartitionType
Definition: part_xbox.c:33
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106

◆ InferFileSystemByHandle()

NTSTATUS InferFileSystemByHandle ( IN HANDLE  PartitionHandle,
IN UCHAR  PartitionType,
IN OUT PWSTR  FileSystemName,
IN SIZE_T  FileSystemNameSize 
)

Definition at line 225 of file fsutil.c.

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 }
#define PARTITION_FAT32
Definition: disk.h:95
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:179
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS GetFileSystemNameByHandle(IN HANDLE PartitionHandle, IN OUT PWSTR FileSystemName, IN SIZE_T FileSystemNameSize)
Definition: fsutil.c:137
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
#define PARTITION_XINT13
Definition: disk.h:97
#define PARTITION_HUGE
Definition: disk.h:92
#define PARTITION_IFS
Definition: disk.h:93
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define PARTITION_FAT_16
Definition: disk.h:90
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
#define PARTITION_LINUX
Definition: partlist.c:36
#define DPRINT1
Definition: precomp.h:8
CHAR PartitionType
Definition: part_xbox.c:33
#define PARTITION_FAT_12
Definition: disk.h:87
#define PARTITION_FAT32_XINT13
Definition: disk.h:96

Referenced by AddPartitionToDisk(), and InferFileSystem().

◆ PreparePartitionForFormatting()

BOOLEAN PreparePartitionForFormatting ( IN struct _PARTENTRY PartEntry,
IN PCWSTR  FileSystemName 
)

Definition at line 536 of file fsutil.c.

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 }
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:179
#define TRUE
Definition: types.h:120
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:86
unsigned char UCHAR
Definition: xmlstorage.h:181
VOID SetPartitionType(IN PPARTENTRY PartEntry, IN UCHAR PartitionType)
Definition: partlist.c:3981
#define DPRINT1
Definition: precomp.h:8
CHAR PartitionType
Definition: part_xbox.c:33
UCHAR FileSystemToPartitionType(IN PCWSTR FileSystem, IN PULARGE_INTEGER StartSector, IN PULARGE_INTEGER SectorCount)
Definition: fsutil.c:457

Referenced by FormatPartitionPage().