FS Driver and removable devices

Hello all.

I have a fully functional IFS which automatically recognizes fixed disks
formatted with my custom FS type. Now I want to be able to
automatically recognize and mount removable disks (i.e. USB flashdrives
or USB /FireWire external HD’s).

Can you offer some pointers as to what I should look into? I.e.: what
APIs I should be looking at, what events the driver will be notified of,
how to initialize the handlers (i.e., which method pointers I should
set), etc…

Thanks

Diego

If your IFS is a registered filesystem, via IoRegisterFilesystem(), for the
appropriate device types, then all you need to monitor is the
IRP_MJ_FILE_SYSTEM_CONTROL/IRP_MN_MOUNT_VOLUME request. This will be issued
to all registered filesystems for the device type until one of the
filesystems recognizes the media format.

Pete

Kernel Drivers
Windows Filesystem and Device Driver Consulting
www.KernelDrivers.com
(303)546-0300

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Diego Rivera
Sent: Monday, March 21, 2005 2:11 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] FS Driver and removable devices

Hello all.

I have a fully functional IFS which automatically recognizes fixed disks
formatted with my custom FS type. Now I want to be able to
automatically recognize and mount removable disks (i.e. USB flashdrives
or USB /FireWire external HD’s).

Can you offer some pointers as to what I should look into? I.e.: what
APIs I should be looking at, what events the driver will be notified of,
how to initialize the handlers (i.e., which method pointers I should
set), etc…

Thanks

Diego


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

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

Yes, it’s a registered file system via IoRegisterFilesystem(). And the
driver does monitor for that request.

However, when I plug in a USB drive with 2 partitions (one FAT and one
with my own filesystem), only the FAT partition is mounted
automatically. The other one I have to mount manually using a command
line utility which in turn uses DefineDosDevice().

After some research, I found that GetVolumeNameForVolumeMountPoint()
returns the correct volume-GUID name for the FAT partition. However, if
the other partition (my custom FS) is mounted on G: (for instance), the
same call (to the corresponding drive letter/path) doesn’t return a
volume-GUID name.

Using WinOBJ I noticed that no volume object was being created to
correspond with that filesystem. Is the driver responsible for creating
this volume? If not, what could be missing?

Thanks for the quick response.

Best

Diego

Peter Scott wrote:

If your IFS is a registered filesystem, via IoRegisterFilesystem(), for the
appropriate device types, then all you need to monitor is the
IRP_MJ_FILE_SYSTEM_CONTROL/IRP_MN_MOUNT_VOLUME request. This will be issued
to all registered filesystems for the device type until one of the
filesystems recognizes the media format.

Pete

Kernel Drivers
Windows Filesystem and Device Driver Consulting
www.KernelDrivers.com
(303)546-0300

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Diego Rivera
Sent: Monday, March 21, 2005 2:11 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] FS Driver and removable devices

Hello all.

I have a fully functional IFS which automatically recognizes fixed disks
formatted with my custom FS type. Now I want to be able to
automatically recognize and mount removable disks (i.e. USB flashdrives
or USB /FireWire external HD’s).

Can you offer some pointers as to what I should look into? I.e.: what
APIs I should be looking at, what events the driver will be notified of,
how to initialize the handlers (i.e., which method pointers I should
set), etc…

Thanks

Diego


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

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


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

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

It does show up in the partition information. Currently I’m working on
a little program that uses that IOCTL to find the partitions in a
removable disk, identify those which have my FS on them, and auto-mount
them. However, the one remaining hurdle is that if I do that, the
volume objects won’t exist (the same case I explained earlier).

As for how it’s created, I believe IoCreateDevice() is called in the
driver, but for some reason the driver isn’t recognizing the second
(custom) partition as its FS type. The weird thing is that a manual
mount DOES work fine. Here’s the kicker: on Disk Management, I can see
the partition, correct size, but the FS is not recognized (listed as
“(unknown partition)”) and I can’t assign a drive letter or mount path
to it either. The fixed disk partitions ARE recognized and the correct
FS name is listed, can change drive letter/mount path assignments, etc.

So from this I would guess that for some reason, the driver is checking
(implicitly or explicitly) whether it’s a fixed disk or not, and thus
isn’t returining an “I recognize this FS” when asked by the OS. So,
which call is made by the OS to ask the driver about FS types it recognizes?

I’m working on someone else’s code, so I’m not 100% familiar with
Windows FS programming, but I’ve learnt enough that I think I can handle
this modification. Worst case, removable devices won’t be supported for
auto-mount :).

Thanks for your help.

Diego

Peter Scott wrote:

How did you get your ‘volume’ created on this partition in the first place?
Does it actually show up in the partition layout information when requested
from a user mode service via the IOCTL_DISK_GET_PARTITION_INFO_EX?

Pete

Kernel Drivers
Windows Filesystem and Device Driver Consulting
www.KernelDrivers.com
(303)546-0300

-----Original Message-----
From: Diego Rivera [mailto:xxxxx@nomadic-solutions.com]
Sent: Monday, March 21, 2005 11:45 AM
To: xxxxx@KernelDrivers.com
Subject: Re: [ntfsd] FS Driver and removable devices

Yes, it’s a registered file system via IoRegisterFilesystem(). And the
driver does monitor for that request.

However, when I plug in a USB drive with 2 partitions (one FAT and one
with my own filesystem), only the FAT partition is mounted
automatically. The other one I have to mount manually using a command
line utility which in turn uses DefineDosDevice().

After some research, I found that GetVolumeNameForVolumeMountPoint()
returns the correct volume-GUID name for the FAT partition. However, if
the other partition (my custom FS) is mounted on G: (for instance), the
same call (to the corresponding drive letter/path) doesn’t return a
volume-GUID name.

Using WinOBJ I noticed that no volume object was being created to
correspond with that filesystem. Is the driver responsible for creating
this volume? If not, what could be missing?

Thanks for the quick response.

Best

Diego

The system knows which filesystems to call for mount processing based on the
types it registers for in the IoRegisterFilesystem() api.

If you are correctly registering your FSD’s devices in the driverentry()
routine, then you should be getting the mount request. It is here in the
mount processing entry point, obviously, that you call the IoCreateDevice()
and create a DO to ‘attach’ to the device stack via the VPB.

Have you actually set a breakpoint in the IRP_MJ_FILE_SYSTEM_CONTROL call
and are you certain you are not receiving the mount request for the volume?
Could you be manually starting your FSD too late in the game and the device
has already been mounted by the RAW FS?

Pete

Kernel Drivers
Windows Filesystem and Device Driver Consulting
www.KernelDrivers.com
(303)546-0300

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Diego Rivera
Sent: Monday, March 21, 2005 1:42 PM
To: Windows File Systems Devs Interest List
Cc: xxxxx@lists.osr.com
Subject: Re: [ntfsd] FS Driver and removable devices

It does show up in the partition information. Currently I’m working on
a little program that uses that IOCTL to find the partitions in a
removable disk, identify those which have my FS on them, and auto-mount
them. However, the one remaining hurdle is that if I do that, the
volume objects won’t exist (the same case I explained earlier).

As for how it’s created, I believe IoCreateDevice() is called in the
driver, but for some reason the driver isn’t recognizing the second
(custom) partition as its FS type. The weird thing is that a manual
mount DOES work fine. Here’s the kicker: on Disk Management, I can see
the partition, correct size, but the FS is not recognized (listed as
“(unknown partition)”) and I can’t assign a drive letter or mount path
to it either. The fixed disk partitions ARE recognized and the correct
FS name is listed, can change drive letter/mount path assignments, etc.

So from this I would guess that for some reason, the driver is checking
(implicitly or explicitly) whether it’s a fixed disk or not, and thus
isn’t returining an “I recognize this FS” when asked by the OS. So,
which call is made by the OS to ask the driver about FS types it recognizes?

I’m working on someone else’s code, so I’m not 100% familiar with
Windows FS programming, but I’ve learnt enough that I think I can handle
this modification. Worst case, removable devices won’t be supported for
auto-mount :).

Thanks for your help.

Diego

Peter Scott wrote:

How did you get your ‘volume’ created on this partition in the first place?
Does it actually show up in the partition layout information when requested
from a user mode service via the IOCTL_DISK_GET_PARTITION_INFO_EX?

Pete

Kernel Drivers
Windows Filesystem and Device Driver Consulting
www.KernelDrivers.com
(303)546-0300

-----Original Message-----
From: Diego Rivera [mailto:xxxxx@nomadic-solutions.com]
Sent: Monday, March 21, 2005 11:45 AM
To: xxxxx@KernelDrivers.com
Subject: Re: [ntfsd] FS Driver and removable devices

Yes, it’s a registered file system via IoRegisterFilesystem(). And the
driver does monitor for that request.

However, when I plug in a USB drive with 2 partitions (one FAT and one
with my own filesystem), only the FAT partition is mounted
automatically. The other one I have to mount manually using a command
line utility which in turn uses DefineDosDevice().

After some research, I found that GetVolumeNameForVolumeMountPoint()
returns the correct volume-GUID name for the FAT partition. However, if
the other partition (my custom FS) is mounted on G: (for instance), the
same call (to the corresponding drive letter/path) doesn’t return a
volume-GUID name.

Using WinOBJ I noticed that no volume object was being created to
correspond with that filesystem. Is the driver responsible for creating
this volume? If not, what could be missing?

Thanks for the quick response.

Best

Diego




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

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

MountMgr will not auto-assign drive letters for MBR partition types other
then FAT or NTFS.

So, set the MBR partition type to FAT, and let your FSD to mount. The MBR
partition type is not used at all while choosing the FSD to mount.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Diego Rivera”
To: “Windows File Systems Devs Interest List”
Cc:
Sent: Monday, March 21, 2005 11:41 PM
Subject: Re: [ntfsd] FS Driver and removable devices

> It does show up in the partition information. Currently I’m working on
> a little program that uses that IOCTL to find the partitions in a
> removable disk, identify those which have my FS on them, and auto-mount
> them. However, the one remaining hurdle is that if I do that, the
> volume objects won’t exist (the same case I explained earlier).
>
> As for how it’s created, I believe IoCreateDevice() is called in the
> driver, but for some reason the driver isn’t recognizing the second
> (custom) partition as its FS type. The weird thing is that a manual
> mount DOES work fine. Here’s the kicker: on Disk Management, I can see
> the partition, correct size, but the FS is not recognized (listed as
> “(unknown partition)”) and I can’t assign a drive letter or mount path
> to it either. The fixed disk partitions ARE recognized and the correct
> FS name is listed, can change drive letter/mount path assignments, etc.
>
> So from this I would guess that for some reason, the driver is checking
> (implicitly or explicitly) whether it’s a fixed disk or not, and thus
> isn’t returining an “I recognize this FS” when asked by the OS. So,
> which call is made by the OS to ask the driver about FS types it recognizes?
>
> I’m working on someone else’s code, so I’m not 100% familiar with
> Windows FS programming, but I’ve learnt enough that I think I can handle
> this modification. Worst case, removable devices won’t be supported for
> auto-mount :).
>
> Thanks for your help.
>
> Diego
>
> Peter Scott wrote:
>
> >How did you get your ‘volume’ created on this partition in the first place?
> >Does it actually show up in the partition layout information when requested
> >from a user mode service via the IOCTL_DISK_GET_PARTITION_INFO_EX?
> >
> >Pete
> >
> >Kernel Drivers
> >Windows Filesystem and Device Driver Consulting
> >www.KernelDrivers.com
> >(303)546-0300
> >
> >-----Original Message-----
> >From: Diego Rivera [mailto:xxxxx@nomadic-solutions.com]
> >Sent: Monday, March 21, 2005 11:45 AM
> >To: xxxxx@KernelDrivers.com
> >Subject: Re: [ntfsd] FS Driver and removable devices
> >
> >Yes, it’s a registered file system via IoRegisterFilesystem(). And the
> >driver does monitor for that request.
> >
> >However, when I plug in a USB drive with 2 partitions (one FAT and one
> >with my own filesystem), only the FAT partition is mounted
> >automatically. The other one I have to mount manually using a command
> >line utility which in turn uses DefineDosDevice().
> >
> >After some research, I found that GetVolumeNameForVolumeMountPoint()
> >returns the correct volume-GUID name for the FAT partition. However, if
> >the other partition (my custom FS) is mounted on G: (for instance), the
> >same call (to the corresponding drive letter/path) doesn’t return a
> >volume-GUID name.
> >
> >Using WinOBJ I noticed that no volume object was being created to
> >correspond with that filesystem. Is the driver responsible for creating
> >this volume? If not, what could be missing?
> >
> >Thanks for the quick response.
> >
> >Best
> >
> >Diego
> >
> >
> >
>
>
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

Is this true for both removable devices and fixed devices? Or just
removables? MountMgr has correctly assigned a drive letter
automatically for a fixed partition using my FSD.

Not so with the removable…hence my dilemma.

Thanks

Diego

Maxim S. Shatskih wrote:

MountMgr will not auto-assign drive letters for MBR partition types other
then FAT or NTFS.

So, set the MBR partition type to FAT, and let your FSD to mount. The MBR
partition type is not used at all while choosing the FSD to mount.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Diego Rivera”
>To: “Windows File Systems Devs Interest List”
>Cc:
>Sent: Monday, March 21, 2005 11:41 PM
>Subject: Re: [ntfsd] FS Driver and removable devices
>
>

Thank you very much!! This did indeed work and solved the problem in the
interim. However: is this behavior hardwired into Windows? Or is there
another way to do this without having to mark the partition as a FAT
partition?

Thanks for your help!

Best

Diego

Maxim S. Shatskih wrote:

MountMgr will not auto-assign drive letters for MBR partition types other
then FAT or NTFS.

So, set the MBR partition type to FAT, and let your FSD to mount. The MBR
partition type is not used at all while choosing the FSD to mount.

> interim. However: is this behavior hardwired into Windows?

Yes, at least to some versions (w2k gold, and possibly w2k SPs).

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

By default,the storage class driver disk.sys creates ONLY ONE volume device object for the removable storage device,using the first partition table entry retured by IoReadPartitionTableEx,if there were no partition table at all,IoReadPartitionTable called by IoReadPartitionTableEx will build a partition list that contiains one partition spanning the entire disk which is the common situation.

----- Original Message -----
From: Diego Rivera
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] FS Driver and removable devices
Sent: Tue Mar 22 02:39:55 CST 2005

Yes, it’s a registered file system via IoRegisterFilesystem(). And the
driver does monitor for that request.

However, when I plug in a USB drive with 2 partitions (one FAT and one
with my own filesystem), only the FAT partition is mounted
automatically. The other one I have to mount manually using a command
line utility which in turn uses DefineDosDevice().

After some research, I found that GetVolumeNameForVolumeMountPoint()
returns the correct volume-GUID name for the FAT partition. However, if
the other partition (my custom FS) is mounted on G: (for instance), the
same call (to the corresponding drive letter/path) doesn’t return a
volume-GUID name.

Using WinOBJ I noticed that no volume object was being created to
correspond with that filesystem. Is the driver responsible for creating
this volume? If not, what could be missing?

Thanks for the quick response.

Best

Diego

Peter Scott wrote:

>If your IFS is a registered filesystem, via IoRegisterFilesystem(), for the
>appropriate device types, then all you need to monitor is the
>IRP_MJ_FILE_SYSTEM_CONTROL/IRP_MN_MOUNT_VOLUME request. This will be issued
>to all registered filesystems for the device type until one of the
>filesystems recognizes the media format.
>
>Pete
>
>Kernel Drivers
>Windows Filesystem and Device Driver Consulting
>www.KernelDrivers.com
>(303)546-0300
>
>
>-----Original Message-----
>From: xxxxx@lists.osr.com
>[mailto:xxxxx@lists.osr.com] On Behalf Of Diego Rivera
>Sent: Monday, March 21, 2005 2:11 AM
>To: Windows File Systems Devs Interest List
>Subject: [ntfsd] FS Driver and removable devices
>
>Hello all.
>
>I have a fully functional IFS which automatically recognizes fixed disks
>formatted with my custom FS type. Now I want to be able to
>automatically recognize and mount removable disks (i.e. USB flashdrives
>or USB /FireWire external HD’s).
>
>Can you offer some pointers as to what I should look into? I.e.: what
>APIs I should be looking at, what events the driver will be notified of,
>how to initialize the handlers (i.e., which method pointers I should
>set), etc…
>
>Thanks
>
>Diego
>
>
>—
>Questions? First check the IFS FAQ at
>https://www.osronline.com/article.cfm?id=17
>
>You are currently subscribed to ntfsd as: xxxxx@kerneldrivers.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
>—
>Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17
>
>You are currently subscribed to ntfsd as: xxxxx@nomadic-solutions.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>


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

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

So why is it working now that I’ve set the partition type to FAT (albeit
the filesystem contained in the partition is NOT FAT)?

According to what you’re saying, I should be out of luck still, but I’m
not. Can you account for this behavior?

I’m just asking so we have a clear picture of what’s happening, and
reconcile what has been said and established so far, with what is
actually observable and happening.

Thanks

Diego

xxxxx@sohu.com wrote:

By default,the storage class driver disk.sys creates ONLY ONE volume device object for the removable storage device,using the first partition table entry retured by IoReadPartitionTableEx,if there were no partition table at all,IoReadPartitionTable called by IoReadPartitionTableEx will build a partition list that contiains one partition spanning the entire disk which is the common situation.

MountMgr has a code path which checks the MBR partition type to be “sane” -
i.e. FAT or NTFS.
It will not assign drive letters to partitions with another partition
types. Stupid but really so. I think this is a measure to avoid assigning
letters to software RAIDs.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Diego Rivera”
To: “Windows File Systems Devs Interest List”
Sent: Saturday, March 26, 2005 11:40 PM
Subject: Re: [ntfsd] FS Driver and removable devices

> So why is it working now that I’ve set the partition type to FAT (albeit
> the filesystem contained in the partition is NOT FAT)?
>
> According to what you’re saying, I should be out of luck still, but I’m
> not. Can you account for this behavior?
>
> I’m just asking so we have a clear picture of what’s happening, and
> reconcile what has been said and established so far, with what is
> actually observable and happening.
>
> Thanks
>
> Diego
>
> xxxxx@sohu.com wrote:
>
> >By default,the storage class driver disk.sys creates ONLY ONE volume device
object for the removable storage device,using the first partition table entry
retured by IoReadPartitionTableEx,if there were no partition table at
all,IoReadPartitionTable called by IoReadPartitionTableEx will build a
partition list that contiains one partition spanning the entire disk which is
the common situation.
> >
> >
>
>
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

This makes a lot of sense. And is good enough for the time being.
Let’s hope MS heals its severe case of cranial-rectalitis and implements
the correct behavior soon :slight_smile:

Thanks

Diego

Maxim S. Shatskih wrote:

MountMgr has a code path which checks the MBR partition type to be “sane” -
i.e. FAT or NTFS.
It will not assign drive letters to partitions with another partition
types. Stupid but really so. I think this is a measure to avoid assigning
letters to software RAIDs.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

Change the behavior by building a port or disk level filter driver;
years ago we implemented a parallel disk class driver that mounted
Macintosh disk drives, interpreting the partition table information and
converting it into a compatible Windows format. The modern equivalent
is to do this in a filter driver.

I’m not sure I see why Microsoft would want to support non-Windows
recognized disk format.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Diego Rivera
Sent: Saturday, March 26, 2005 4:28 PM
To: ntfsd redirect
Subject: Re: [ntfsd] FS Driver and removable devices

This makes a lot of sense. And is good enough for the time being.
Let’s hope MS heals its severe case of cranial-rectalitis and implements

the correct behavior soon :slight_smile:

Thanks

Diego

Maxim S. Shatskih wrote:

MountMgr has a code path which checks the MBR partition type to be
“sane” -
i.e. FAT or NTFS.
It will not assign drive letters to partitions with another
partition
types. Stupid but really so. I think this is a measure to avoid
assigning
letters to software RAIDs.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com


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

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

Tony Mason wrote:

I’m not sure I see why Microsoft would want to support non-Windows
recognized disk format.

If MS doesn’t want Windows to handle custom FS implementations, why
permit the development of IFS drivers in the first place? Basically, if
you’re going to support something like IFS, then support it fully, not
halfway.

But that’s an ideological question, and that’s not what this thread is
about :slight_smile:

Best

Diego

> If MS doesn’t want Windows to handle custom FS implementations, why

permit the development of IFS drivers in the first place? Basically, if

Mark the custom filesystems as FAT in your MBR partition table.

BTW - the read IRP generated by IoReadPartitionTable cannot be filtered, to add
to the fun :slight_smile: you can filter IOCTL_DISK_GET_DRIVE_LAYOUT and friends though to
patch the partition type values.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com