ReactOS 0.4.16-dev-297-gc569aee
fsrec.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

NTSTATUS GetFileSystemName_UStr (IN PUNICODE_STRING PartitionPath OPTIONAL, IN HANDLE PartitionHandle OPTIONAL, IN OUT PWSTR FileSystemName, IN SIZE_T FileSystemNameSize)
 
NTSTATUS GetFileSystemName (IN PCWSTR PartitionPath OPTIONAL, IN HANDLE PartitionHandle OPTIONAL, IN OUT PWSTR FileSystemName, IN SIZE_T FileSystemNameSize)
 
NTSTATUS InferFileSystem (IN PCWSTR PartitionPath OPTIONAL, IN HANDLE PartitionHandle OPTIONAL, IN OUT PWSTR FileSystemName, IN SIZE_T FileSystemNameSize)
 
UCHAR FileSystemToMBRPartitionType (IN PCWSTR FileSystem, IN ULONGLONG StartSector, IN ULONGLONG SectorCount)
 

Function Documentation

◆ FileSystemToMBRPartitionType()

UCHAR FileSystemToMBRPartitionType ( IN PCWSTR  FileSystem,
IN ULONGLONG  StartSector,
IN ULONGLONG  SectorCount 
)

Definition at line 333 of file fsrec.c.

337{
339
340 if (SectorCount == 0)
342
343 if (_wcsicmp(FileSystem, L"FAT") == 0 ||
344 _wcsicmp(FileSystem, L"FAT32") == 0 ||
345 _wcsicmp(FileSystem, L"RAW") == 0)
346 {
347 if (SectorCount < 8192ULL)
348 {
349 /* FAT12 CHS partition (disk is smaller than 4.1MB) */
350 return PARTITION_FAT_12;
351 }
352 else if (StartSector < 1450560ULL)
353 {
354 /* Partition starts below the 8.4GB boundary ==> CHS partition */
355
356 if (SectorCount < 65536ULL)
357 {
358 /* FAT16 CHS partition (partition size < 32MB) */
359 return PARTITION_FAT_16;
360 }
361 else if (SectorCount < 1048576ULL)
362 {
363 /* FAT16 CHS partition (partition size < 512MB) */
364 return PARTITION_HUGE;
365 }
366 else
367 {
368 /* FAT32 CHS partition (partition size >= 512MB) */
369 return PARTITION_FAT32;
370 }
371 }
372 else
373 {
374 /* Partition starts above the 8.4GB boundary ==> LBA partition */
375
376 if (SectorCount < 1048576ULL)
377 {
378 /* FAT16 LBA partition (partition size < 512MB) */
379 return PARTITION_XINT13;
380 }
381 else
382 {
383 /* FAT32 LBA partition (partition size >= 512MB) */
385 }
386 }
387 }
388 else if (_wcsicmp(FileSystem, L"NTFS") == 0)
389 {
390 return PARTITION_IFS;
391 }
392 else if (_wcsicmp(FileSystem, L"BTRFS") == 0 ||
393 _wcsicmp(FileSystem, L"EXT2") == 0 ||
394 _wcsicmp(FileSystem, L"EXT3") == 0 ||
395 _wcsicmp(FileSystem, L"EXT4") == 0)
396 {
397 return PARTITION_LINUX;
398 }
399 else
400 {
401 /* Unknown file system */
402 DPRINT1("Unknown file system '%S'\n", FileSystem);
404 }
405}
#define DPRINT1
Definition: precomp.h:8
PWCHAR FileSystem
Definition: format.c:72
#define PARTITION_IFS
Definition: disk.h:94
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:87
#define PARTITION_XINT13
Definition: disk.h:98
#define PARTITION_FAT32
Definition: disk.h:96
#define PARTITION_FAT_12
Definition: disk.h:88
#define PARTITION_HUGE
Definition: disk.h:93
#define PARTITION_FAT_16
Definition: disk.h:91
#define PARTITION_FAT32_XINT13
Definition: disk.h:97
#define ASSERT(a)
Definition: mode.c:44
#define L(x)
Definition: ntvdm.h:50
ULONG SectorCount
Definition: part_xbox.c:31
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define PARTITION_LINUX
Definition: partlist.c:36

Referenced by FormatPartition(), and InitializePartitionEntry().

◆ GetFileSystemName()

NTSTATUS GetFileSystemName ( IN PCWSTR PartitionPath  OPTIONAL,
IN HANDLE PartitionHandle  OPTIONAL,
IN OUT PWSTR  FileSystemName,
IN SIZE_T  FileSystemNameSize 
)

Definition at line 112 of file fsrec.c.

117{
118 UNICODE_STRING PartitionPathU;
119
120 if (PartitionPath && PartitionHandle)
122
123 if (PartitionPath)
124 RtlInitUnicodeString(&PartitionPathU, PartitionPath);
125
126 return GetFileSystemName_UStr(PartitionPath ? &PartitionPathU : NULL,
127 PartitionPath ? NULL : PartitionHandle,
128 FileSystemName,
129 FileSystemNameSize);
130}
#define NULL
Definition: types.h:112
NTSTATUS GetFileSystemName_UStr(IN PUNICODE_STRING PartitionPath OPTIONAL, IN HANDLE PartitionHandle OPTIONAL, IN OUT PWSTR FileSystemName, IN SIZE_T FileSystemNameSize)
Definition: fsrec.c:55
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

◆ GetFileSystemName_UStr()

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

Definition at line 55 of file fsrec.c.

60{
64
65 if (PartitionPath && PartitionHandle)
67
68 /* Open the partition if a path has been given;
69 * otherwise just use the provided handle. */
70 if (PartitionPath)
71 {
73 PartitionPath,
75 NULL,
76 NULL);
77 Status = NtOpenFile(&PartitionHandle,
78 FILE_GENERIC_READ /* | SYNCHRONIZE */,
82 0 /* FILE_SYNCHRONOUS_IO_NONALERT */);
83 if (!NT_SUCCESS(Status))
84 {
85 DPRINT1("Failed to open partition '%wZ', Status 0x%08lx\n",
86 PartitionPath, Status);
87 return Status;
88 }
89 }
90
91 /* Retrieve the FS attributes */
92 Status = GetFileSystemNameWorker(PartitionHandle,
94 FileSystemName,
95 FileSystemNameSize);
96 if (!NT_SUCCESS(Status))
97 {
98 DPRINT1("GetFileSystemName() failed for partition '%wZ' (0x%p), Status 0x%08lx\n",
99 PartitionPath, PartitionHandle, Status);
100 }
101
102 if (PartitionPath)
103 {
104 /* Close the partition */
105 NtClose(PartitionHandle);
106 }
107
108 return Status;
109}
LONG NTSTATUS
Definition: precomp.h:26
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define FILE_SHARE_READ
Definition: compat.h:136
static NTSTATUS GetFileSystemNameWorker(IN HANDLE PartitionHandle, OUT PIO_STATUS_BLOCK IoStatusBlock, IN OUT PWSTR FileSystemName, IN SIZE_T FileSystemNameSize)
Definition: fsrec.c:24
Status
Definition: gdiplustypes.h:25
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
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:3952
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define FILE_GENERIC_READ
Definition: nt_native.h:653

Referenced by GetFileSystemName(), InferFileSystemWorker(), and InstallBootManagerAndBootEntries().

◆ InferFileSystem()

NTSTATUS InferFileSystem ( IN PCWSTR PartitionPath  OPTIONAL,
IN HANDLE PartitionHandle  OPTIONAL,
IN OUT PWSTR  FileSystemName,
IN SIZE_T  FileSystemNameSize 
)

Definition at line 269 of file fsrec.c.

274{
276 UNICODE_STRING PartitionPathU;
279
280 if (PartitionPath && PartitionHandle)
282
283 /* Open the partition if a path has been given;
284 * otherwise just use the provided handle. */
285 if (PartitionPath)
286 {
287 RtlInitUnicodeString(&PartitionPathU, PartitionPath);
289 &PartitionPathU,
291 NULL,
292 NULL);
293 Status = NtOpenFile(&PartitionHandle,
294 FILE_GENERIC_READ /* | SYNCHRONIZE */,
298 0 /* FILE_SYNCHRONOUS_IO_NONALERT */);
299 if (!NT_SUCCESS(Status))
300 {
301 DPRINT1("Failed to open partition '%S', Status 0x%08lx\n",
302 PartitionPath, Status);
303 return Status;
304 }
305 }
306
307 /* Retrieve the FS */
308 Status = InferFileSystemWorker(PartitionHandle,
310 FileSystemName,
311 FileSystemNameSize);
312 if (!NT_SUCCESS(Status))
313 {
314 DPRINT1("InferFileSystem() failed for partition '%S' (0x%p), Status 0x%08lx\n",
315 PartitionPath, PartitionHandle, Status);
316 }
317 else
318 {
319 DPRINT1("InferFileSystem(): FileSystem (guessed): %S\n",
320 *FileSystemName ? FileSystemName : L"None");
321 }
322
323 if (PartitionPath)
324 {
325 /* Close the partition */
326 NtClose(PartitionHandle);
327 }
328
329 return Status;
330}
static NTSTATUS InferFileSystemWorker(IN HANDLE PartitionHandle, OUT PIO_STATUS_BLOCK IoStatusBlock, IN OUT PWSTR FileSystemName, IN SIZE_T FileSystemNameSize)
Definition: fsrec.c:134

Referenced by MountVolume().