Mount point problems....

Hi everyone!

For a couple days now I’m looking into this problem, and every bit of
information I gather seems to only increase my confusion (Nirwhana seems
close at times…)

Here is my problem/question:

How can I add my own partition device objects (type FILE_DEVICE_DISK; not
attached to any specific hardware) as sub directories on NTFS volumes, and
what requests do I need to handle so it really works?

The current situation:

My driver has a ‘master’ control device. At run time, it can create
multiple ‘disk’ devices and for each ‘disk’ device there will be a number
of ‘partition’ devices. It is no PnP driver [would not be sensible without
any associated hardware me thinks].

Up to now I was happy to create drive letters with DefineDosDevice() to
access the partition devices [works fine], but now I’m supposed to ‘mount’
those partitions to a sub directory of a NTFS volume, so instead of, say,
having drive letters K:, L:, M: I should get D:\Virt\P1, D:\Virt\P2,
D:\Virt\P3 as root directories for the three partitions. So I created a
GUID for each partition device and a symbolic link named
Volume{…guid…}.

There is no real disk or other specific hardware behind the driver, the
data for the disk/partition devices is obtained from special files
scattered around everywhere, and it’s uncommon to see the same source
‘mounted’ more than 1-2 times [so I don’t want anything persistent]

Now, when calling SetVolumeMountPoint( “F:\EMPTY\”,
“\\?\Volume{…guid…}\”) it always fails. (when I pick an existing
Volume{…} from an unassigned partition from a normal hard disk, it
works, just my device won’t work. When calling SetVolumeMountPoint(), my
partition device receives the following requests in this order:

IRP_MJ_CREATE [returns STATUS_SUCCESS, info=1]
IRP_MJ_CLEANUP [returns STATUS_SUCCESS, info=0]
IOCTL_MOUNTDEV_QUERY_DEVICE_NAME [returns STATUS_BUFFER_OVERFLOW, info=4]
IOCTL_MOUNTDEV_QUERY_DEVICE_NAME [returns STATUS_SUCCESS, info=66, device
name returned ‘\Device\VogonVirtualVolume_D1_P2’
IRP_MJ_CLOSE

After the partition device has received those requests,
SetVolumeMountPoint() returns an error.

While trying to solve this problem, I’ve read about the mount manager and
other stuff and tried to use IoRegisterDeviceInterface(). Since my device
object is no PDO this failed every time of course, so I used
IoReportDetectedDevice() with an empty resource list (counter==0) to get a
PDO and then IoAttachDeviceToDeviceStack() to attach my partition device
object to the newly created PDO.

This was a bad mistake as now I get a “windows detected new
hardware”-message for each mounted partition on each windows startup. And
even worse, the SetVolumeMountPoint still fails.

Could someone please point me in the right direction how to do this
properly? I can’t believe that it is/can be so difficult to just let my
own partition devices show up as sub directories…

Cheers,
Michael


Vogon International GmbH
http://www.vogon-international.com

According to your description, we have very similar software and I had to solve the same problem few years before. However, the request was to support both FAT and NTFS so I could avoid trying to convince MountManager to do something useful with my driver and used different solution from the start: filesystem filter and STATUS_REPARSE. Works like a charm and was relatively easy to implement (in terms of FS filters development). The result with some custom support has about 150 kB of code now whereas virtual disk driver has three times more. It was possible to use one binary for w2k and above, the real challenge was w9x support.

I also played with MountManager for different reasons but with similarly miserable results. I’m affraid driver has to really support PnP which doesn’t make sense for this kind of driver. Maybe there is a solution but I guess it may be easier to write FS filter than trying to find it :slight_smile:

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]


From: xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com] on behalf of xxxxx@vogon.de[SMTP:xxxxx@vogon.de]
Reply To: Windows System Software Devs Interest List
Sent: Friday, April 29, 2005 2:34 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Mount point problems…

Hi everyone!

For a couple days now I’m looking into this problem, and every bit of information I gather seems to only increase my confusion (Nirwhana seems close at times…)

Here is my problem/question:

How can I add my own partition device objects (type FILE_DEVICE_DISK; not attached to any specific hardware) as sub directories on NTFS volumes, and what requests do I need to handle so it really works?

The current situation:

My driver has a ‘master’ control device. At run time, it can create multiple ‘disk’ devices and for each ‘disk’ device there will be a number of ‘partition’ devices. It is no PnP driver [would not be sensible without any associated hardware me thinks].

Up to now I was happy to create drive letters with DefineDosDevice() to access the partition devices [works fine], but now I’m supposed to ‘mount’ those partitions to a sub directory of a NTFS volume, so instead of, say, having drive letters K:, L:, M: I should get D:\Virt\P1, D:\Virt\P2, D:\Virt\P3 as root directories for the three partitions. So I created a GUID for each partition device and a symbolic link named Volume{…guid…}.

There is no real disk or other specific hardware behind the driver, the data for the disk/partition devices is obtained from special files scattered around everywhere, and it’s uncommon to see the same source ‘mounted’ more than 1-2 times [so I don’t want anything persistent]

Now, when calling SetVolumeMountPoint( “F:\EMPTY\”, “\\?\Volume{…guid…}\”) it always fails. (when I pick an existing Volume{…} from an unassigned partition from a normal hard disk, it works, just my device won’t work. When calling SetVolumeMountPoint(), my partition device receives the following requests in this order:

IRP_MJ_CREATE [returns STATUS_SUCCESS, info=1]
IRP_MJ_CLEANUP [returns STATUS_SUCCESS, info=0]
IOCTL_MOUNTDEV_QUERY_DEVICE_NAME [returns STATUS_BUFFER_OVERFLOW, info=4]
IOCTL_MOUNTDEV_QUERY_DEVICE_NAME [returns STATUS_SUCCESS, info=66, device name returned ‘\Device\VogonVirtualVolume_D1_P2’
IRP_MJ_CLOSE

After the partition device has received those requests, SetVolumeMountPoint() returns an error.

While trying to solve this problem, I’ve read about the mount manager and other stuff and tried to use IoRegisterDeviceInterface(). Since my device object is no PDO this failed every time of course, so I used IoReportDetectedDevice() with an empty resource list (counter==0) to get a PDO and then IoAttachDeviceToDeviceStack() to attach my partition device object to the newly created PDO.>

This was a bad mistake as now I get a “windows detected new hardware”-message for each mounted partition on each windows startup. And even worse, the SetVolumeMountPoint still fails.

Could someone please point me in the right direction how to do this properly? I can’t believe that it is/can be so difficult to just let my own partition devices show up as sub directories…

Cheers,
Michael


Vogon International GmbH
http://www.vogon-international.com — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’ To unsubscribe send a blank email to xxxxx@lists.osr.com

Hi!

Thanks for your reply!

The very moment I decided to give your filter driver approach a try and
just forget about my old tries/tests, I stumbled uppon a device io control
code that I just had to try/test:
IOCTL_MOUNTMGR_VOLUME_ARRIVAL_NOTIFICATION :

Now, in the call to my driver where I assign the GUID that should be used,
I send that arrival – IOCTL to the mount manager. While that IOCTL is
processed, my partition device receives a couple IOCTLs from the mount
manager. From the requests I got [apart from open/cleanup/close] , I
handle the following three properly:

IOCTL_DISK_GET_PARTITION_INFO, IOCTL_MOUNTDEV_QUERY_DEVICE_NAME and
IOCTL_MOUNTDEV_QUERY_UNIQUE_ID

I also received IOCTL_MOUNTDEV_QUERY_SUGGESTED_LINK_NAME, 0x004D0010 (??),
IOCTL_VOLUME_ONLINE. Those I just fail.

Now I can use SetVolumeMountPoint() to attach the partition device to a
NTFS directory without having to support PnP.

I still have to take care that the mount points are removed on system
shutdown [they’re persistent], but I didn’t get any annoying ‘found new
hardware’-messages so far. And if all else fails, I can manually delete
the directories that were assigned earlier.

I have to do some more testing (check if the registry gets clobbered up
with useless entries that way, check if there are some side effects, …),
but I think this should work.

Cheers,
Michael

“Michal Vodicka”
Sent by: xxxxx@lists.osr.com
29.04.2005 20:29
Please respond to
“Windows System Software Devs Interest List”

To
“Windows System Software Devs Interest List”
cc

Subject
RE: [ntdev] Mount point problems…

According to your description, we have very similar software and I had to
solve the same problem few years before. However, the request was to
support both FAT and NTFS so I could avoid trying to convince MountManager
to do something useful with my driver and used different solution from the
start: filesystem filter and STATUS_REPARSE. Works like a charm and was
relatively easy to implement (in terms of FS filters development). The
result with some custom support has about 150 kB of code now whereas
virtual disk driver has three times more. It was possible to use one
binary for w2k and above, the real challenge was w9x support.

I also played with MountManager for different reasons but with similarly
miserable results. I’m affraid driver has to really support PnP which
doesn’t make sense for this kind of driver. Maybe there is a solution but
I guess it may be easier to write FS filter than trying to find it :slight_smile:

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]

> ----------
> From:
xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com]
on behalf of xxxxx@vogon.de[SMTP:xxxxx@vogon.de]
> Reply To: Windows System Software Devs Interest List
> Sent: Friday, April 29, 2005 2:34 PM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] Mount point problems…
>
>
> Hi everyone!
>
> For a couple days now I’m looking into this problem, and every bit of
information I gather seems to only increase my confusion (Nirwhana seems
close at times…)
>
>
> Here is my problem/question:
>
> How can I add my own partition device objects (type FILE_DEVICE_DISK;
not attached to any specific hardware) as sub directories on NTFS volumes,
and what requests do I need to handle so it really works?
>

[…]

---------------------------------------------------------------
Vogon International GmbH
http://www.vogon-international.com