Using IoQueryVolumeInformation()...

I am trying to use IoQueryVolumeInformation() to get available space on a
volume (based upon a previous NTFSD post). This call requires a file
object. How should one go about setting this up? How do I create the
proper file object to pass to this call - let’s say for finding out how much
space is on the ‘C:’ volume?

thanks in advance! - jb

============================================
Jonathan Borden
xxxxx@earthlink.net


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

RtlInitUnicodeString(&UniName,VolumeName);

InitializeObjectAttributes ( &ObjectAttributes,
&UniName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL );

Status = ZwCreateFile( &FileHandle,
GENERIC_READ, // desired access
&ObjectAttributes, // object
attributes
&IoStatus,
NULL, // alloc size
FILE_ATTRIBUTE_NORMAL, // file attributes
FILE_SHARE_WRITE | FILE_SHARE_READ, // share
access
FILE_OPEN, // create disposition
0, // create options
NULL, // eabuffer
0 ); // ealength

Status = ObReferenceObjectByHandle(
FileHandle, // IN HANDLE Handle,
GENERIC_READ,
NULL, // IN POBJECT_TYPE ObjectType, //
optional
(KPROCESSOR_MODE)KernelMode, // IN KPROCESSOR_MODE
AccessMode,
(PVOID *)&FileObject, // OUT PVOID *Object,
NULL // OUT POBJECT_HANDLE_INFORMATION
HandleInformation // optional
);

Status = IoQueryVolumeInformation(
FileObject, // IN PFILE_OBJECT FileObject,
FileFsSizeInformation, // IN FS_INFORMATION_CLASS FsInformationClass,
sizeof(FsSize), // IN ULONG Length,
&FsSize, // OUT PVOID FsInformation,
&Returned // OUT PULONG ReturnedLength
);

ObDereferenceObject(FileObject);
ZwClose(FileHandle);

where VolumeName is something like “??\C:” or “\Device\HarddiskVolume1”.

rob

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Jonathan Borden
Sent: Tuesday, March 27, 2001 8:31 PM
To: File Systems Developers
Subject: [ntfsd] Using IoQueryVolumeInformation()…

I am trying to use IoQueryVolumeInformation() to get available space on a
volume (based upon a previous NTFSD post). This call requires a file
object. How should one go about setting this up? How do I create the
proper file object to pass to this call - let’s say for finding
out how much
space is on the ‘C:’ volume?

thanks in advance! - jb

============================================
Jonathan Borden
xxxxx@earthlink.net


You are currently subscribed to ntfsd as: xxxxx@cdp.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com