FSCTL_GET_VOLUME_BITMAP for FAT/FAT32 partitions from Kernel Mode

Hi,

I was trying using FSCTL_GET_VOLUME_BITMAP from a lower filter driver.

The call succeeds with NTFS volumes but it fails with status

STATUS_INVALID_DEVICE_REQUEST ((NTSTATUS)0xC0000010L)

on FAT and FAT32 devices. These calls work fine from User mode. Any
idea, is it supported, or I am doing something wrong?

Regards,
Avi

Here is the code i am using for getting Bitmap.

GetBitmap(
IN PFILE_OBJECT pFSFileObject,
OUT PVOLUME_BITMAP_BUFFER *ppVolBmpBuffer
)
{


IoAcquireVpbSpinLock( &kOldIrql );

pFSDeviceObject = pFSFileObject->DeviceObject->Vpb->DeviceObject;

IoReleaseVpbSpinLock( kOldIrql );

/////////////////////////////////////////////////////////////////

// Allocate memory for bitmap.

pVolBitmapBuff = ExAllocatePool(NonPagedPool, ulBitmapBufferSize);

if(!pVolBitmapBuff)

{

DebugPrint((1, "Failed to allocate internal buffer\n"));

return STATUS_INSUFFICIENT_RESOURCES;

}

RtlZeroMemory(pVolBitmapBuff, ulBitmapBufferSize);

oStartLCN.StartingLcn.QuadPart = 0;

///////////////////////////////////

// Issue FSCTL_GET_VOLUME_BITMAP.

KeInitializeEvent(&event, NotificationEvent, FALSE);

irp = IoBuildDeviceIoControlRequest(FSCTL_GET_VOLUME_BITMAP,

pFSDeviceObject,

&oStartLCN,

sizeof(STARTING_LCN_INPUT_BUFFER),

pVolBitmapBuff,

ulBitmapBufferSize,

FALSE,

&event,

&ioStatus);

if(!irp)

{

ExFreePool(pVolBitmapBuff);

return STATUS_INSUFFICIENT_RESOURCES;

}

pStack = IoGetNextIrpStackLocation(irp);

pStack->MajorFunction = IRP_MJ_FILE_SYSTEM_CONTROL;

pStack->MinorFunction = IRP_MN_KERNEL_CALL;

pStack->FileObject = pFSFileObject;

status = IoCallDriver(pFSDeviceObject, irp);

if(status == STATUS_PENDING)

{

KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);

status = ioStatus.Status;

}

if(status == STATUS_BUFFER_OVERFLOW)

{

ulBitmapSize = (ULONG)((pVolBitmapBuff->BitmapSize.QuadPart / 8) +
1);

ulBitmapBufferSize = (2*sizeof(ULONGLONG) + ulBitmapSize);

ExFreePool(pVolBitmapBuff);

pVolBitmapBuff = ExAllocatePool(NonPagedPool, ulBitmapBufferSize);

if(!pVolBitmapBuff)

{

return STATUS_INSUFFICIENT_RESOURCES;

}

RtlZeroMemory(pVolBitmapBuff, ulBitmapBufferSize);

oStartLCN.StartingLcn.QuadPart = 0;

KeInitializeEvent(&event, NotificationEvent, FALSE);

irp = IoBuildDeviceIoControlRequest(FSCTL_GET_VOLUME_BITMAP,

pFSDeviceObject,

&oStartLCN,

sizeof(STARTING_LCN_INPUT_BUFFER),

pVolBitmapBuff,

ulBitmapBufferSize,

FALSE,

&event,

&ioStatus);

if(!irp)

{

ExFreePool(pVolBitmapBuff);

return STATUS_INSUFFICIENT_RESOURCES;

}

pStack = IoGetNextIrpStackLocation(irp);

pStack->MajorFunction = IRP_MJ_FILE_SYSTEM_CONTROL;

pStack->MinorFunction = IRP_MN_KERNEL_CALL;

pStack->FileObject = pFSFileObject;

status = IoCallDriver(pFSDeviceObject, irp);

if(status == STATUS_PENDING)

{

KeWaitForSingleObject(&event, Executive, KernelMode, FALSE,
NULL);

status = ioStatus.Status;

}

}

if(!NT_SUCCESS(status))

{

ExFreePool(pVolBitmapBuff);

return status;

}



}

Regards,
Avi


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Avinash Kumar
Sent: Monday, August 09, 2004 1:27 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] FSCTL_GET_VOLUME_BITMAP for FAT/FAT32 partitions from
Kernel Mode

Hi,

I was trying using FSCTL_GET_VOLUME_BITMAP from a lower filter driver.

The call succeeds with NTFS volumes but it fails with status

STATUS_INVALID_DEVICE_REQUEST ((NTSTATUS)0xC0000010L)

on FAT and FAT32 devices. These calls work fine from User mode. Any
idea, is it supported, or I am doing something wrong?

Regards,
Avi

Questions? First check the IFS FAQ at

You are currently subscribed to ntfsd as: xxxxx@commvault.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Make sure that the file object represents the volume.
-Kiran

“Avinash Kumar” wrote in message news:xxxxx@ntfsd…
Here is the code i am using for getting Bitmap.

GetBitmap(
IN PFILE_OBJECT pFSFileObject,
OUT PVOLUME_BITMAP_BUFFER ppVolBmpBuffer
)
{



IoAcquireVpbSpinLock( &kOldIrql );

pFSDeviceObject = pFSFileObject->DeviceObject->Vpb->DeviceObject;

IoReleaseVpbSpinLock( kOldIrql );

/////////////////////////////////////////////////////////////////

// Allocate memory for bitmap.

pVolBitmapBuff = ExAllocatePool(NonPagedPool, ulBitmapBufferSize);

if(!pVolBitmapBuff)

{

DebugPrint((1, “Failed to allocate internal buffer\n”));

return STATUS_INSUFFICIENT_RESOURCES;

}

RtlZeroMemory(pVolBitmapBuff, ulBitmapBufferSize);

oStartLCN.StartingLcn.QuadPart = 0;

///////////////////////////////////

// Issue FSCTL_GET_VOLUME_BITMAP.

KeInitializeEvent(&event, NotificationEvent, FALSE);

irp = IoBuildDeviceIoControlRequest(FSCTL_GET_VOLUME_BITMAP,

pFSDeviceObject,

&oStartLCN,

sizeof(STARTING_LCN_INPUT_BUFFER),

pVolBitmapBuff,

ulBitmapBufferSize,

FALSE,

&event,

&ioStatus);

if(!irp)

{

ExFreePool(pVolBitmapBuff);

return STATUS_INSUFFICIENT_RESOURCES;

}

pStack = IoGetNextIrpStackLocation(irp);

pStack->MajorFunction = IRP_MJ_FILE_SYSTEM_CONTROL;

pStack->MinorFunction = IRP_MN_KERNEL_CALL;

pStack->FileObject = pFSFileObject;

status = IoCallDriver(pFSDeviceObject, irp);

if(status == STATUS_PENDING)

{

KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);

status = ioStatus.Status;

}

if(status == STATUS_BUFFER_OVERFLOW)

{

ulBitmapSize = (ULONG)((pVolBitmapBuff->BitmapSize.QuadPart / 8) +
1);

ulBitmapBufferSize = (2
sizeof(ULONGLONG) + ulBitmapSize);

ExFreePool(pVolBitmapBuff);

pVolBitmapBuff = ExAllocatePool(NonPagedPool, ulBitmapBufferSize);

if(!pVolBitmapBuff)

{

return STATUS_INSUFFICIENT_RESOURCES;

}

RtlZeroMemory(pVolBitmapBuff, ulBitmapBufferSize);

oStartLCN.StartingLcn.QuadPart = 0;

KeInitializeEvent(&event, NotificationEvent, FALSE);

irp = IoBuildDeviceIoControlRequest(FSCTL_GET_VOLUME_BITMAP,

pFSDeviceObject,

&oStartLCN,

sizeof(STARTING_LCN_INPUT_BUFFER),

pVolBitmapBuff,

ulBitmapBufferSize,

FALSE,

&event,

&ioStatus);

if(!irp)

{

ExFreePool(pVolBitmapBuff);

return STATUS_INSUFFICIENT_RESOURCES;

}

pStack = IoGetNextIrpStackLocation(irp);

pStack->MajorFunction = IRP_MJ_FILE_SYSTEM_CONTROL;

pStack->MinorFunction = IRP_MN_KERNEL_CALL;

pStack->FileObject = pFSFileObject;

status = IoCallDriver(pFSDeviceObject, irp);

if(status == STATUS_PENDING)

{

KeWaitForSingleObject(&event, Executive, KernelMode, FALSE,
NULL);

status = ioStatus.Status;

}

}

if(!NT_SUCCESS(status))

{

ExFreePool(pVolBitmapBuff);

return status;

}



}

Regards,
Avi

________________________________

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Avinash Kumar
Sent: Monday, August 09, 2004 1:27 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] FSCTL_GET_VOLUME_BITMAP for FAT/FAT32 partitions from
Kernel Mode

Hi,

I was trying using FSCTL_GET_VOLUME_BITMAP from a lower filter driver.

The call succeeds with NTFS volumes but it fails with status

STATUS_INVALID_DEVICE_REQUEST ((NTSTATUS)0xC0000010L)

on FAT and FAT32 devices. These calls work fine from User mode. Any
idea, is it supported, or I am doing something wrong?

Regards,
Avi

Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@commvault.com
To unsubscribe send a blank email to xxxxx@lists.osr.com