Changeset 30276 in vbox
- Timestamp:
- Jun 17, 2010 8:56:53 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 62802
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/win/fs-win.cpp
r28918 r30276 40 40 #include <iprt/assert.h> 41 41 #include "internal/fs.h" 42 42 #include <iprt/stream.h> 43 44 /* from ntdef.h */ 45 typedef LONG NTSTATUS; 46 47 /* from ntddk.h */ 48 typedef struct _IO_STATUS_BLOCK { 49 union { 50 NTSTATUS Status; 51 PVOID Pointer; 52 }; 53 ULONG_PTR Information; 54 } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; 55 56 typedef enum _FSINFOCLASS { 57 FileFsAttributeInformation = 5, 58 } FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS; 59 60 /* from ntifs.h */ 61 62 typedef struct _FILE_FS_ATTRIBUTE_INFORMATION { 63 ULONG FileSystemAttributes; 64 LONG MaximumComponentNameLength; 65 ULONG FIleSystemNameLength; 66 WCHAR FileSystemName[1]; 67 } FILE_FS_ATTRIBUTE_INFORMATION, *PFILE_FS_ATTRIBUTE_INFORMATION; 68 69 extern "C" NTSTATUS NTAPI NtQueryVolumeInformationFile(HANDLE, PIO_STATUS_BLOCK, PVOID, ULONG, FS_INFORMATION_CLASS); 43 70 44 71 /** … … 308 335 } 309 336 337 RTR3DECL(int) RTFsQueryType(const char *pszFsPath, uint32_t *pu32Type) 338 { 339 int rc = VINF_SUCCESS; 340 341 *pu32Type = RTFS_FS_TYPE_UNKNOWN; 342 343 HANDLE hFile = CreateFile(pszFsPath, 344 GENERIC_READ, 345 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 346 NULL, 347 OPEN_EXISTING, 348 FILE_FLAG_BACKUP_SEMANTICS, 349 NULL); 350 if (hFile != INVALID_HANDLE_VALUE) 351 { 352 char abBuf[8192]; 353 IO_STATUS_BLOCK Ios; 354 NTSTATUS rcNt = NtQueryVolumeInformationFile(hFile, &Ios, 355 abBuf, sizeof(abBuf), 356 FileFsAttributeInformation); 357 if (rcNt >= 0) 358 { 359 PFILE_FS_ATTRIBUTE_INFORMATION pFsAttrInfo = (PFILE_FS_ATTRIBUTE_INFORMATION)abBuf; 360 if ( pFsAttrInfo->FileSystemName[0] == 'N' 361 && pFsAttrInfo->FileSystemName[1] == 'T' 362 && pFsAttrInfo->FileSystemName[2] == 'F' 363 && pFsAttrInfo->FileSystemName[3] == 'S' 364 && pFsAttrInfo->FileSystemName[4] == '\0') 365 *pu32Type = RTFS_FS_TYPE_NTFS; 366 else if ( pFsAttrInfo->FileSystemName[0] == 'F' 367 && pFsAttrInfo->FileSystemName[1] == 'A' 368 && pFsAttrInfo->FileSystemName[2] == 'T' 369 && ( ( pFsAttrInfo->FileSystemName[3] == '3' 370 && pFsAttrInfo->FileSystemName[4] == '2' 371 && pFsAttrInfo->FileSystemName[5] == '\0') 372 || pFsAttrInfo->FileSystemName[3] == '\0')) 373 /* This is either FAT32 or FAT12/16. IMO it doesn't make 374 * sense to distinguish more detailed because we cannot 375 * easily distinguish between these FAT types on Linux 376 * and users who put some image file on an FAT16 partition 377 * should know what they are doing. */ 378 *pu32Type = RTFS_FS_TYPE_FAT; 379 } 380 /* else: Is RTFS_FS_UNKNOWN suffient or should we return an error? */ 381 CloseHandle(hFile); 382 } 383 384 return rc; 385 }
Note:
See TracChangeset
for help on using the changeset viewer.