Changeset 64619 in vbox for trunk/src/VBox/Runtime/r3/nt/fs-nt.cpp
- Timestamp:
- Nov 9, 2016 5:03:40 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 111837
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/nt/fs-nt.cpp
r62584 r64619 33 33 34 34 #include <iprt/fs.h> 35 #include <iprt/file.h> 35 36 #include <iprt/path.h> 36 37 #include <iprt/string.h> … … 64 65 if (RT_SUCCESS(rc)) 65 66 { 66 /* 67 * Get the volume information. 68 */ 69 FILE_FS_SIZE_INFORMATION FsSizeInfo; 70 IO_STATUS_BLOCK Ios = RTNT_IO_STATUS_BLOCK_INITIALIZER; 71 NTSTATUS rcNt = NtQueryVolumeInformationFile(hFile, &Ios, &FsSizeInfo, sizeof(FsSizeInfo), FileFsSizeInformation); 72 if (NT_SUCCESS(rcNt)) 73 { 74 /* 75 * Calculate the return values. 76 */ 77 if (pcbTotal) 78 { 79 *pcbTotal = FsSizeInfo.TotalAllocationUnits.QuadPart 80 * FsSizeInfo.SectorsPerAllocationUnit 81 * FsSizeInfo.BytesPerSector; 82 if ( *pcbTotal / FsSizeInfo.SectorsPerAllocationUnit / FsSizeInfo.BytesPerSector 83 != FsSizeInfo.TotalAllocationUnits.QuadPart) 84 *pcbTotal = UINT64_MAX; 85 } 86 87 if (pcbFree) 88 { 89 *pcbFree = FsSizeInfo.AvailableAllocationUnits.QuadPart 90 * FsSizeInfo.SectorsPerAllocationUnit 91 * FsSizeInfo.BytesPerSector; 92 if ( *pcbFree / FsSizeInfo.SectorsPerAllocationUnit / FsSizeInfo.BytesPerSector 93 != FsSizeInfo.AvailableAllocationUnits.QuadPart) 94 *pcbFree = UINT64_MAX; 95 } 96 97 if (pcbBlock) 98 { 99 *pcbBlock = FsSizeInfo.SectorsPerAllocationUnit * FsSizeInfo.BytesPerSector; 100 if (*pcbBlock / FsSizeInfo.BytesPerSector != FsSizeInfo.SectorsPerAllocationUnit) 101 rc = VERR_OUT_OF_RANGE; 102 } 103 104 if (pcbSector) 105 *pcbSector = FsSizeInfo.BytesPerSector; 106 } 107 else 108 rc = RTErrConvertFromNtStatus(rcNt); 67 RTFILE hIprtFile = NIL_RTFILE; 68 rc = RTFileFromNative(&hIprtFile, (RTHCINTPTR)hFile); 69 AssertRC(rc); 70 if (RT_SUCCESS(rc)) 71 rc = RTFileQueryFsSizes(hIprtFile, pcbTotal, pcbFree, pcbBlock, pcbSector); 109 72 110 73 RTNtPathClose(hFile);
Note:
See TracChangeset
for help on using the changeset viewer.