[Wine-Dev]NtQueryVolumeInformation对FileFsFullSizeInformation的支持

[Wine-Dev]NtQueryVolumeInformation对FileFsFullSizeInformation的支持

1.结构体FILE_FS_FULL_SIZE_INFORMATION的几个属性的含义

参见MSDN

https://msdn.microsoft.com/en-us/library/windows/hardware/ff540267(v=vs.85).aspx

结构体定义如下:

typedef struct _FILE_FS_FULL_SIZE_INFORMATION {
  LARGE_INTEGER TotalAllocationUnits;
  LARGE_INTEGER CallerAvailableAllocationUnits;
  LARGE_INTEGER ActualAvailableAllocationUnits;
  ULONG         SectorsPerAllocationUnit;
  ULONG         BytesPerSector;
} FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION;

对磁盘的相关知识,参考下图

 

Figure 1: Disk structures:

  1. Track
  2. Geometrical sector
  3. Track sector
  4. Cluster

图片摘自wikipedia http://en.wikipedia.org/wiki/Disk_sector

其中

SectorsPerAllocationUnit 和 BytesPerSector 的值通过名字就可以看出来

下面是对TotalAllocationUnit,CallerAllocationUnit,ActualAllocationUnit的具体表达的含义的研究

2.实验过程

实验基本环境:Windows XP 32bit 磁盘实际大小 9.98GB 分区仅有C: 一个分区

VOID用户使用的磁盘份额为8.40GB 剩余空间为 1.58(未开启磁盘份额)

Newbee用户使用的磁盘份额为4.82MB 剩余空间为295MB(已开启磁盘份额)

分割线右侧的数据为在相应条件下右键打开磁盘的属性菜单的三个值,分别为:已用空间 可用空间  容量

实验1.

不开启配额限制 使用用户VOID(Admin)

==========1===========8.40GB 1.58GB 9.98GB===============
file.c:1228: TotalAllocationUnits(Human Readable) 0 9.989117GB
file.c:1229: CallerAvailableAllocationUnits 00000000 000652e6
file.c:1230: CallerAvailableAllocationUnits(Human Readable) 0 1.580956GB
file.c:1231: ActualAvailableAllocationUnits 00000000 000652e6
file.c:1232: ActualAvailableAllocationUnits(Human Readable) 0 1.580956GB
file.c:1233: SectorsPerAllocationUnit 00000008
file.c:1234: SectorsPerAllocationUnit(Human Readable) 8
file.c:1235: BytesPerSector(Human Readable) 512

实验2.开启配额限制 配额限制为 Newbee:500MB 使用用户Newbee

==========2===========4.87MB 295MB 300MB==================
file.c:1228: TotalAllocationUnits(Human Readable) 0 0.292969GB
file.c:1229: CallerAvailableAllocationUnits 00000000 0001272e
file.c:1230: CallerAvailableAllocationUnits(Human Readable) 0 0.288261GB
file.c:1231: ActualAvailableAllocationUnits 00000000 000652dc
file.c:1232: ActualAvailableAllocationUnits(Human Readable) 0 1.580917GB
file.c:1233: SectorsPerAllocationUnit 00000008
file.c:1234: SectorsPerAllocationUnit(Human Readable) 8
file.c:1235: BytesPerSector(Human Readable) 512

实验3.开启配额限制 配额限制为 VOID : 8.5G 使用用户为VOID

==========3===========6.91GB 1.58GB 8.50GB=================
file.c:1228: TotalAllocationUnits(Human Readable) 0 8.500000GB
file.c:1229: CallerAvailableAllocationUnits 00000000 000652cf
file.c:1230: CallerAvailableAllocationUnits(Human Readable) 0 1.580868GB
file.c:1231: ActualAvailableAllocationUnits 00000000 000652cf
file.c:1232: ActualAvailableAllocationUnits(Human Readable) 0 1.580868GB
file.c:1233: SectorsPerAllocationUnit 00000008
file.c:1234: SectorsPerAllocationUnit(Human Readable) 8
file.c:1235: BytesPerSector(Human Readable) 512

实验4.开启配额限制 配额限制为 VOID 5.0G 使用用户为VOID

==========4===========4.65GB 357MB 5.0GB=====================
file.c:1228: TotalAllocationUnits(Human Readable) 0 5.000000GB
file.c:1229: CallerAvailableAllocationUnits 00000000 000165b4
file.c:1230: CallerAvailableAllocationUnits(Human Readable) 0 0.349319GB
file.c:1231: ActualAvailableAllocationUnits 00000000 000652cf
file.c:1232: ActualAvailableAllocationUnits(Human Readable) 0 1.580868GB
file.c:1233: SectorsPerAllocationUnit 00000008
file.c:1234: SectorsPerAllocationUnit(Human Readable) 8
file.c:1235: BytesPerSector(Human Readable) 512

 

因此可以看出 TotalAllocationUnit和该用户总共可以使用的配额相等

CallerAvailableAllocationUnit和该用户当前可以使用的空间,即”总可用空间-实际已用空间” 相等

ActualAvailableAllocationUnit和该磁盘在未开启磁盘配额时,当前可用的空间相等

Leave a Reply

Your email address will not be published. Required fields are marked *

4 − one =

This site uses Akismet to reduce spam. Learn how your comment data is processed.