Re: What is way to mount Virtual file system with Virtual Disk

The mount manager need you to return the exact right error code, if the
buffer is to small to fit the structure you must return
STATUS_INVALID_PARAMETER however if the buffer fits the structure but not
all of the name string you must return STATUS_BUFFER_OVERFLOW and also
set the name lenght in the structure itself to what is needed so the mount
manager can make a new call with a bigger buffer. Make also sure that you
set the IoStatus.Information field to the right value. Note also that all
length’s is in bytes so it is two times the number of unicode characters.
Below is an example that surly works from the popular drivers FileDisk and
HttpDisk:

/Bo Branten

case IOCTL_MOUNTDEV_QUERY_DEVICE_NAME:
{
PMOUNTDEV_NAME name;

if (io_stack->Parameters.DeviceIoControl.OutputBufferLength <
sizeof(MOUNTDEV_NAME))
{
status = STATUS_INVALID_PARAMETER;
Irp->IoStatus.Information = 0;
break;
}

name = (PMOUNTDEV_NAME) Irp->AssociatedIrp.SystemBuffer;
name->NameLength = device_extension->device_name.Length *
sizeof(WCHAR);

if (io_stack->Parameters.DeviceIoControl.OutputBufferLength <
name->NameLength + sizeof(USHORT))
{
status = STATUS_BUFFER_OVERFLOW;
Irp->IoStatus.Information = sizeof(MOUNTDEV_NAME);
break;
}

RtlCopyMemory(name->Name,
device_extension->device_name.Buffer, name->NameLength);

status = STATUS_SUCCESS;
Irp->IoStatus.Information = name->NameLength + sizeof(USHORT);

break;
}

I tried this code as per your suggetion. But so far same problem. I think your solution is irrelavent because alog with the IOCTL for mount manager there is one more thin to notice that volume root directory is getting opened closed without any reason. Can you think some thing else or can you tell me the correct way to implement mouniting of virtual disk and file system.

Thanks

> however if the buffer fits the structure but not

all of the name string you must return STATUS_BUFFER_OVERFLOW and also
set the name lenght in the structure itself to what is needed so the mount
manager can make a new call with a bigger buffer.

This is true for maybe ALL calls in the FSD/FSF world :slight_smile:


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com