Get information of the partitions disk

Hello,

To get this information on boot I’m using the IOCTL_DISK_GET_DRIVE_LAYOUT_EX with the IoBuildDeviceIoControlRequest.

But i need to know the size and the free space of the partition too. Anyone know any structure or function can I use?

Thanks

Hi Thiago,

As far as I know, a disk driver just offers a not structured storage space. The only thing a disk know about space is (roughly speaking) how much data it can store on the media. The partition manager interpret its partition table and divide the whole disk into partitions that might be used to form a volume or part of it. A partition also stores not structured data that File System Drivers use to organize it into files and folders. So, the information referring to the free space within a partition will depend on the File System attached to that volume, that in turn, uses the partition.

Regards,

Fernando Roberto da Silva
DriverEntry Kernel Development
http://www.driverentry.com.br/en

The file system is NTFS and I found this Control Code FSCTL_GET_NTFS_VOLUME_DATA. But I am having trouble using it, in kernel mode.

Volume free space information is at a higher level. See
IRP_MJ_QUERY_VOLUME_INFORMATION. Note that there is not a simple
mapping from ‘partition’ to volume as some volumes span partitions,
not all disks are MBR format, etc. However, while it isn’t simple it
is possible to build such a map and produce a reasonable estimate of
free space. For example Disk Manager does it.

Mark Roddy

On Mon, Feb 21, 2011 at 9:05 AM, wrote:
> Hello,
>
> To get this information on boot I’m using the IOCTL_DISK_GET_DRIVE_LAYOUT_EX with the IoBuildDeviceIoControlRequest.
>
> But i need to know the size and the free space of the partition too. Anyone know any structure or function can I use?
>
> Thanks
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>

I’ll try this!!! =D
Thiago Fabre
UNESP / Bauru, SP - Brazil
(14) 91096114

On Mon, Feb 21, 2011 at 11:58 AM, Mark Roddy wrote:

> Volume free space information is at a higher level. See
> IRP_MJ_QUERY_VOLUME_INFORMATION. Note that there is not a simple
> mapping from ‘partition’ to volume as some volumes span partitions,
> not all disks are MBR format, etc. However, while it isn’t simple it
> is possible to build such a map and produce a reasonable estimate of
> free space. For example Disk Manager does it.
>
> Mark Roddy
>
>
>
> On Mon, Feb 21, 2011 at 9:05 AM, wrote:
> > Hello,
> >
> > To get this information on boot I’m using the
> IOCTL_DISK_GET_DRIVE_LAYOUT_EX with the IoBuildDeviceIoControlRequest.
> >
> > But i need to know the size and the free space of the partition too.
> Anyone know any structure or function can I use?
> >
> > Thanks
> >
> >
> > —
> > NTDEV is sponsored by OSR
> >
> > For our schedule of WDF, WDM, debugging and other seminars visit:
> > http://www.osr.com/seminars
> >
> > To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
> >
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

> The file system is NTFS and I found this Control Code FSCTL_GET_NTFS_VOLUME_DATA

No, for free space, the call is NtQueryVolumeInformationFile, or handicraft the “query volume information” IRP and send it down.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

Thanks, I used ZwCreateFile + ZwQueryVolumeInformationFile and works. But
the ZwCreateFIle works after some time on the boot, I think that’s when the
filesystem is ready!!!

s,
Thiago Fabre
UNESP / Bauru
(14) 91096114

On Mon, Feb 21, 2011 at 4:03 PM, Maxim S. Shatskih
wrote:

> > The file system is NTFS and I found this Control Code
> FSCTL_GET_NTFS_VOLUME_DATA
>
> No, for free space, the call is NtQueryVolumeInformationFile, or handicraft
> the “query volume information” IRP and send it down.
>
> –
> Maxim S. Shatskih
> Windows DDK MVP
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>