diff --git a/inc/winfsp/fsctl.h b/inc/winfsp/fsctl.h index 38a1cd4e..8f9e737f 100644 --- a/inc/winfsp/fsctl.h +++ b/inc/winfsp/fsctl.h @@ -46,8 +46,8 @@ extern const __declspec(selectany) GUID FspFsvrtDeviceClassGuid = /* volume/file metadata */ typedef struct { - UINT64 TotalAllocationUnits; - UINT64 AvailableAllocationUnits; + UINT64 TotalSize; + UINT64 FreeSize; UINT64 VolumeCreationTime; UINT16 VolumeLabelLength; WCHAR VolumeLabel[32]; diff --git a/src/sys/volinfo.c b/src/sys/volinfo.c index b751b6c4..cd882ffb 100644 --- a/src/sys/volinfo.c +++ b/src/sys/volinfo.c @@ -123,10 +123,12 @@ static NTSTATUS FspFsvolQueryFsFullSizeInformation( FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(FsvolDeviceObject); PFILE_FS_FULL_SIZE_INFORMATION Info = (PFILE_FS_FULL_SIZE_INFORMATION)*PBuffer; + UINT64 AllocationUnit = FsvolDeviceExtension->VolumeParams.SectorSize * + FsvolDeviceExtension->VolumeParams.SectorsPerAllocationUnit; - Info->TotalAllocationUnits.QuadPart = VolumeInfo->TotalAllocationUnits; - Info->CallerAvailableAllocationUnits.QuadPart = VolumeInfo->AvailableAllocationUnits; - Info->ActualAvailableAllocationUnits.QuadPart = VolumeInfo->AvailableAllocationUnits; + Info->TotalAllocationUnits.QuadPart = VolumeInfo->TotalSize / AllocationUnit; + Info->CallerAvailableAllocationUnits.QuadPart = + Info->ActualAvailableAllocationUnits.QuadPart = VolumeInfo->FreeSize / AllocationUnit; Info->SectorsPerAllocationUnit = FsvolDeviceExtension->VolumeParams.SectorsPerAllocationUnit; Info->BytesPerSector = FsvolDeviceExtension->VolumeParams.SectorSize; @@ -148,9 +150,11 @@ static NTSTATUS FspFsvolQueryFsSizeInformation( FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(FsvolDeviceObject); PFILE_FS_SIZE_INFORMATION Info = (PFILE_FS_SIZE_INFORMATION)*PBuffer; + UINT64 AllocationUnit = FsvolDeviceExtension->VolumeParams.SectorSize * + FsvolDeviceExtension->VolumeParams.SectorsPerAllocationUnit; - Info->TotalAllocationUnits.QuadPart = VolumeInfo->TotalAllocationUnits; - Info->AvailableAllocationUnits.QuadPart = VolumeInfo->AvailableAllocationUnits; + Info->TotalAllocationUnits.QuadPart = VolumeInfo->TotalSize / AllocationUnit; + Info->AvailableAllocationUnits.QuadPart = VolumeInfo->FreeSize / AllocationUnit; Info->SectorsPerAllocationUnit = FsvolDeviceExtension->VolumeParams.SectorsPerAllocationUnit; Info->BytesPerSector = FsvolDeviceExtension->VolumeParams.SectorSize; diff --git a/tst/winfsp-tests/memfs.cpp b/tst/winfsp-tests/memfs.cpp index 400e218b..5cc74c2e 100644 --- a/tst/winfsp-tests/memfs.cpp +++ b/tst/winfsp-tests/memfs.cpp @@ -194,15 +194,14 @@ static NTSTATUS GetVolumeInfo(FSP_FILE_SYSTEM *FileSystem, { MEMFS *Memfs = (MEMFS *)FileSystem->UserContext; MEMFS_FILE_NODE *RootNode; - ULONG AllocationUnits = Memfs->MaxFileSize / (MEMFS_SECTOR_SIZE * MEMFS_SECTORS_PER_ALLOCATION_UNIT); RootNode = MemfsFileNodeMapGet(Memfs->FileNodeMap, L""); if (0 == RootNode) return STATUS_DISK_CORRUPT_ERROR; - VolumeInfo->TotalAllocationUnits = Memfs->MaxFileNodes * AllocationUnits; - VolumeInfo->AvailableAllocationUnits = - (Memfs->MaxFileNodes - MemfsFileNodeMapCount(Memfs->FileNodeMap)) * AllocationUnits; + VolumeInfo->TotalSize = Memfs->MaxFileNodes * Memfs->MaxFileSize; + VolumeInfo->FreeSize = + (Memfs->MaxFileNodes - MemfsFileNodeMapCount(Memfs->FileNodeMap)) * Memfs->MaxFileSize; VolumeInfo->VolumeCreationTime = RootNode->FileInfo.CreationTime; VolumeInfo->VolumeLabelLength = sizeof L"MEMFS" - sizeof(WCHAR); memcpy(VolumeInfo->VolumeLabel, L"MEMFS", VolumeInfo->VolumeLabelLength);