FILE_READ_ONLY_DEVICE is Wrong on certain drives

Hi All,

I am currently writing a FSF and am having a problem. I need to
determine if a drive is read only or not. This is before it is mounted,
but during the mount IRP. I look at the Characteristics &
FILE_READ_ONLY_DEVICE bit, which works on about 90% of the drives that I
test, but once in awhile it reports writable on certain drives which are
CD-ROMs, which are obviously not writable.

These are not CD-Rs or RWs… I am not sure if this is a bug in the
driver code for that CD-ROM or if the firmware of the CD-ROM is
reporting writable for some reason?? I am baffled here… And
apparently this only happens on XP, not NT or 2000. Anyone run into
anything like this? I am stuck…

Thanks in advance

Tom

You should look at the way FAT does this. Instead of looking at the
characteristics, it sends an Ioctl: IOCTL_IS_WRITEABLE or some such
thing. If a device type may be writable sometimes, I would expect the
characteristics to indicate so. But if the current media is not writeable,
the Ioctl should indicate so.

  • Dan.

At 03:27 PM 1/19/2005 -0800, you wrote:

Hi All,

I am currently writing a FSF and am having a problem. I need to determine
if a drive is read only or not. This is before it is mounted, but during
the mount IRP. I look at the Characteristics & FILE_READ_ONLY_DEVICE bit,
which works on about 90% of the drives that I test, but once in awhile it
reports writable on certain drives which are CD-ROMs, which are obviously
not writable.

These are not CD-Rs or RWs& I am not sure if this is a bug in the driver
code for that CD-ROM or if the firmware of the CD-ROM is reporting
writable for some reason?? I am baffled here& And apparently this only
happens on XP, not NT or 2000. Anyone run into anything like this? I am stuck&

Thanks in advance

Tom


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

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

IOCTL_DISK_IS_WRITABLE

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

----- Original Message -----
From: Handal, Thomas
To: Windows File Systems Devs Interest List
Sent: Thursday, January 20, 2005 2:27 AM
Subject: [ntfsd] FILE_READ_ONLY_DEVICE is Wrong on certain drives

Hi All,

I am currently writing a FSF and am having a problem. I need to determine if a drive is read only or not. This is before it is mounted, but during the mount IRP. I look at the Characteristics & FILE_READ_ONLY_DEVICE bit, which works on about 90% of the drives that I test, but once in awhile it reports writable on certain drives which are CD-ROMs, which are obviously not writable.

These are not CD-Rs or RWs. I am not sure if this is a bug in the driver code for that CD-ROM or if the firmware of the CD-ROM is reporting writable for some reason?? I am baffled here. And apparently this only happens on XP, not NT or 2000. Anyone run into anything like this? I am stuck.

Thanks in advance

Tom


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

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Handal,

The READ_ONLY characteristic is not reliable and should not be used. Use the IOCTL described below. If you look at the SFILTER and FileSpy samples in the IFSKit they have a routine for detecting snapshot volumes which uses this IOCTL.

Snapshot volumes are a good example of this problem, they are readonly but do not set this flag. I wanted them to fix this but their response was that since no one used the flag why should they bother setting it.

The flag should be deprecated.

Neal Christiansen
Microsoft File System Filter Group Lead
This posting is provided “AS IS” with no warranties, and confers no rights


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
Sent: Friday, January 21, 2005 10:36 AM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] FILE_READ_ONLY_DEVICE is Wrong on certain drives

??? IOCTL_DISK_IS_WRITABLE
?
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From: Handal, Thomas
To: Windows File Systems Devs Interest List
Sent: Thursday, January 20, 2005 2:27 AM
Subject: [ntfsd] FILE_READ_ONLY_DEVICE is Wrong on certain drives

Hi All,

I am currently writing a FSF and am having a problem. I need to determine if a drive is read only or not. This is before it is mounted, but during the mount IRP.? I look at the Characteristics & FILE_READ_ONLY_DEVICE bit, which works on about 90% of the drives that I test, but once in awhile it reports writable on certain drives which are CD-ROMs, which are obviously not writable.
These are not CD-Rs or RWs… I am not sure if this is a bug in the driver code for that CD-ROM or if the firmware of the CD-ROM is reporting writable for some reason??? I am baffled here… And apparently this only happens on XP, not NT or 2000. ?Anyone run into anything like this? I am stuck…

Thanks in advance
Tom
?


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

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
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: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Hi Neal!

Thanks for the input… I seem to be having a problem though… I
implemented the IOCTL and it seems to be mounting the drive to actually
check the media for read-only info. The problem is that the point of my
FSF is to BLOCK mounts. If the IOCTL is mounting, I have no control
over it, so it defeats the purpose. I need to check to see if the
device is writable or read-only without actually mounting it. That is
why the characteristics FILE_READ_ONLY_DEVICE would have been good. Do
you have any ideas?

Thanks!

Tom


Subject: RE: FILE_READ_ONLY_DEVICE is Wrong on certain drives

From: “Neal Christiansen”

Newsgroups: ntfsd

To: “Windows File Systems Devs Interest List”

Handal,

The READ_ONLY characteristic is not reliable and should not be used.
Use the IOCTL described below. If you look at the SFILTER and FileSpy
samples in the IFSKit they have a routine for detecting snapshot volumes
which uses this IOCTL.

Snapshot volumes are a good example of this problem, they are readonly
but do not set this flag. I wanted them to fix this but their response
was that since no one used the flag why should they bother setting it.

The flag should be deprecated.

Neal Christiansen

Microsoft File System Filter Group Lead

This posting is provided “AS IS” with no warranties, and confers no
rights

________________________________________

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih

Sent: Friday, January 21, 2005 10:36 AM

To: Windows File Systems Devs Interest List

Subject: Re: [ntfsd] FILE_READ_ONLY_DEVICE is Wrong on certain drives

IOCTL_DISK_IS_WRITABLE

Maxim Shatskih, Windows DDK MVP

StorageCraft Corporation

xxxxx@storagecraft.com

http://www.storagecraft.com

----- Original Message -----

From: Handal, Thomas

To: Windows File Systems Devs Interest List

Sent: Thursday, January 20, 2005 2:27 AM

Subject: [ntfsd] FILE_READ_ONLY_DEVICE is Wrong on certain drives

Hi All,

I am currently writing a FSF and am having a problem. I need to
determine if a drive is read only or not. This is before it is mounted,
but during the mount IRP. I look at the Characteristics &
FILE_READ_ONLY_DEVICE bit, which works on about 90% of the drives that I
test, but once in awhile it reports writable on certain drives which are
CD-ROMs, which are obviously not writable.

These are not CD-Rs or RWs… I am not sure if this is a bug in the
driver code for that CD-ROM or if the firmware of the CD-ROM is
reporting writable for some reason?? I am baffled here… And
apparently this only happens on XP, not NT or 2000. Anyone run into
anything like this? I am stuck…

Thanks in advance

Tom



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

You are currently subscribed to ntfsd as: unknown lmsubst tag argument:
‘’

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: unknown lmsubst tag argument:
‘’

To unsubscribe send a blank email to xxxxx@lists.osr.com

Handal,

Are you sending the request to the file system stack or the storage stack? You should be sending it directly to the storage stack.

At what point are you sending the request, while you are processing a mount or are you doing this at some other time like in a worker thread? It sounds to me like you were trying to do your own “open” to get this information.

The system supports the concept of a “Direct Device Open”. I looked at the IFSKit docs and they do not talk about this. I have filed a doc bug to get this fixed.

In the meantime:
If you do a volume open (volume name only) with no related file object and specify “FILE_READ_ATTRIBUTES” for the “Desired Access” parameter it will open the storage stack device directly and not mount the volume. You should then be able to do the query. You need to be careful because you are not talking to a file system, you are talking directly to the storage stack. This should work from both user mode and kernel mode.

Note that you can also specify the SYNCHORNIZE flag in the “Desired Access” parameter if you want to.

Neal Christiansen
Microsoft File System Filter Group Lead
This posting is provided “AS IS” with no warranties, and confers no rights


From: Handal, Thomas [mailto:xxxxx@websense.com]
Sent: Monday, January 24, 2005 4:37 PM
To: xxxxx@lists.osr.com
Cc: Neal Christiansen
Subject: RE: FILE_READ_ONLY_DEVICE is Wrong on certain drives

Hi Neal!

Thanks for the input… I seem to be having a problem though… I implemented the IOCTL and it seems to be mounting the drive to actually check the media for read-only info.? The problem is that the point of my FSF is to BLOCK mounts.? If the IOCTL is mounting, I have no control over it, so it defeats the purpose.? I need to check to see if the device is writable or read-only without actually mounting it. That is why the characteristics FILE_READ_ONLY_DEVICE would have been good. ??Do you have any ideas?

Thanks!
Tom


Subject: RE: FILE_READ_ONLY_DEVICE is Wrong on certain drives
From: “Neal Christiansen”
Newsgroups: ntfsd
To: “Windows File Systems Devs Interest List”

Handal,

The READ_ONLY characteristic is not reliable and should not be used.? Use the IOCTL described below.? If you look at the SFILTER and FileSpy samples in the IFSKit they have a routine for detecting snapshot volumes which uses this IOCTL.

Snapshot volumes are a good example of this problem, they are readonly but do not set this flag.? I wanted them to fix this but their response was that since no one used the flag why should they bother setting it.

The flag should be deprecated.

Neal Christiansen
Microsoft File System Filter Group Lead
This posting is provided “AS IS” with no warranties, and confers no rights

________________________________________
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
Sent: Friday, January 21, 2005 10:36 AM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] FILE_READ_ONLY_DEVICE is Wrong on certain drives

??? IOCTL_DISK_IS_WRITABLE
?
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From: Handal, Thomas
To: Windows File Systems Devs Interest List
Sent: Thursday, January 20, 2005 2:27 AM
Subject: [ntfsd] FILE_READ_ONLY_DEVICE is Wrong on certain drives

Hi All,

I am currently writing a FSF and am having a problem. I need to determine if a drive is read only or not. This is before it is mounted, but during the mount IRP.? I look at the Characteristics & FILE_READ_ONLY_DEVICE bit, which works on about 90% of the drives that I test, but once in awhile it reports writable on certain drives which are CD-ROMs, which are obviously not writable.
These are not CD-Rs or RWs… I am not sure if this is a bug in the driver code for that CD-ROM or if the firmware of the CD-ROM is reporting writable for some reason??? I am baffled here… And apparently this only happens on XP, not NT or 2000. ?Anyone run into anything like this? I am stuck…

Thanks in advance
Tom
?


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

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
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: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Hi Neal!

I am doing this during the IRP_MN_MOUNT_VOLUME. It is during the actual
request, not in the worker thread, because I have to block the mount if
necessary. I am not sure if I am sending the request to the storage
stack. I have never heard of “Direct Device Open,” (probably cause
it’s not documented… thanks for looking into that)…

How do you do a “volume open”? I am not sure that I have done that
before in the kernel. Am I going to do this with a “CreateFile” type of
call? How do I send this request specifically to the “Storage Stack,”
which DeviceObject is this? I am sorry if these are stupid questions,
but I am normally a UNIX Kernel guy, just been working in the Windows
kernel world for about 5 months or so…

I appreciate your help! You are my only hope! :slight_smile:

Tom


Subject: RE: FILE_READ_ONLY_DEVICE is Wrong on certain drives

From: “Neal Christiansen”

Newsgroups: ntfsd

To:

Handal,

Are you sending the request to the file system stack or the storage
stack? You should be sending it directly to the storage stack.

At what point are you sending the request, while you are processing a
mount or are you doing this at some other time like in a worker thread?
It sounds to me like you were trying to do your own “open” to get this
information.

The system supports the concept of a “Direct Device Open”. I looked at
the IFSKit docs and they do not talk about this. I have filed a doc bug
to get this fixed.

In the meantime:

If you do a volume open (volume name only) with no related file object
and specify “FILE_READ_ATTRIBUTES” for the “Desired Access” parameter it
will open the storage stack device directly and not mount the volume.
You should then be able to do the query. You need to be careful because
you are not talking to a file system, you are talking directly to the
storage stack. This should work from both user mode and kernel mode.

Note that you can also specify the SYNCHORNIZE flag in the “Desired
Access” parameter if you want to.

Neal Christiansen

Microsoft File System Filter Group Lead

This posting is provided “AS IS” with no warranties, and confers no
rights



From: Handal, Thomas [mailto:xxxxx@websense.com]

Sent: Monday, January 24, 2005 4:37 PM

To: xxxxx@lists.osr.com

Cc: Neal Christiansen

Subject: RE: FILE_READ_ONLY_DEVICE is Wrong on certain drives

Hi Neal!

Thanks for the input… I seem to be having a problem though… I
implemented the IOCTL and it seems to be mounting the drive to actually
check the media for read-only info. The problem is that the point of my
FSF is to BLOCK mounts. If the IOCTL is mounting, I have no control
over it, so it defeats the purpose. I need to check to see if the
device is writable or read-only without actually mounting it. That is
why the characteristics FILE_READ_ONLY_DEVICE would have been good. Do
you have any ideas?

Thanks!

Tom

----------------

Subject: RE: FILE_READ_ONLY_DEVICE is Wrong on certain drives

From: “Neal Christiansen”

Newsgroups: ntfsd

To: “Windows File Systems Devs Interest List”

Handal,

The READ_ONLY characteristic is not reliable and should not be used.
Use the IOCTL described below. If you look at the SFILTER and FileSpy
samples in the IFSKit they have a routine for detecting snapshot volumes
which uses this IOCTL.

Snapshot volumes are a good example of this problem, they are readonly
but do not set this flag. I wanted them to fix this but their response
was that since no one used the flag why should they bother setting it.

The flag should be deprecated.

Neal Christiansen

Microsoft File System Filter Group Lead

This posting is provided “AS IS” with no warranties, and confers no
rights



From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih

Sent: Friday, January 21, 2005 10:36 AM

To: Windows File Systems Devs Interest List

Subject: Re: [ntfsd] FILE_READ_ONLY_DEVICE is Wrong on certain drives

IOCTL_DISK_IS_WRITABLE

Maxim Shatskih, Windows DDK MVP

StorageCraft Corporation

xxxxx@storagecraft.com

http://www.storagecraft.com

----- Original Message -----

From: Handal, Thomas

To: Windows File Systems Devs Interest List

Sent: Thursday, January 20, 2005 2:27 AM

Subject: [ntfsd] FILE_READ_ONLY_DEVICE is Wrong on certain drives

Hi All,

I am currently writing a FSF and am having a problem. I need to
determine if a drive is read only or not. This is before it is mounted,
but during the mount IRP. I look at the Characteristics &
FILE_READ_ONLY_DEVICE bit, which works on about 90% of the drives that I
test, but once in awhile it reports writable on certain drives which are
CD-ROMs, which are obviously not writable.

These are not CD-Rs or RWs… I am not sure if this is a bug in the
driver code for that CD-ROM or if the firmware of the CD-ROM is
reporting writable for some reason?? I am baffled here… And
apparently this only happens on XP, not NT or 2000. Anyone run into
anything like this? I am stuck…

Thanks in advance

Tom



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

You are currently subscribed to ntfsd as: unknown lmsubst tag argument:
‘’

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: unknown lmsubst tag argument:
‘’

To unsubscribe send a blank email to xxxxx@lists.osr.com

I’m going to risk my reputation (if any), and disagree with Neal. :slight_smile:

I don’t think you should do a direct device open. You want to build a
IRP_MJ_DEVICE_CONTROL Irp with IoBuildDeviceIoControlRequest(), and send it
to Vpb->RealDevice.

Again, see the FastFat sample, specifically routine
FatIsMediaWriteProtected in fsctrl.c. It is a perfect example of what you
need to do.

  • Dan.

At 09:25 AM 1/26/2005 -0800, you wrote:

Hi Neal!

I am doing this during the IRP_MN_MOUNT_VOLUME. It is during the actual
request, not in the worker thread, because I have to block the mount if
necessary. I am not sure if I am sending the request to the storage
stack. I have never heard of Direct Device Open, (probably cause its not
documented& thanks for looking into that)&

How do you do a volume open? I am not sure that I have done that before
in the kernel. Am I going to do this with a CreateFiletype of call? How
do I send this request specifically to the Storage Stack,which
DeviceObject is this? I am sorry if these are stupid questions, but I am
normally a UNIX Kernel guy, just been working in the Windows kernel world
for about 5 months or so&

I appreciate your help! You are my only hope! J

Tom


Subject: RE: FILE_READ_ONLY_DEVICE is Wrong on certain drives

From: “Neal Christiansen”
>
>Newsgroups: ntfsd
>
>To:
>
>
>
>Handal,
>
>
>
>Are you sending the request to the file system stack or the storage
>stack? You should be sending it directly to the storage stack.
>
>
>
>At what point are you sending the request, while you are processing a
>mount or are you doing this at some other time like in a worker
>thread? It sounds to me like you were trying to do your own “open” to get
>this information.
>
>
>
>The system supports the concept of a “Direct Device Open”. I looked at
>the IFSKit docs and they do not talk about this. I have filed a doc bug
>to get this fixed.
>
>
>
>In the meantime:
>
>If you do a volume open (volume name only) with no related file object and
>specify “FILE_READ_ATTRIBUTES” for the “Desired Access” parameter it will
>open the storage stack device directly and not mount the volume. You
>should then be able to do the query. You need to be careful because you
>are not talking to a file system, you are talking directly to the storage
>stack. This should work from both user mode and kernel mode.
>
>
>
>Note that you can also specify the SYNCHORNIZE flag in the “Desired
>Access” parameter if you want to.
>
>
>
>Neal Christiansen
>
>Microsoft File System Filter Group Lead
>
>This posting is provided “AS IS” with no warranties, and confers no rights
>
>
>
>
>
>From: Handal, Thomas [mailto:xxxxx@websense.com]
>
>Sent: Monday, January 24, 2005 4:37 PM
>
>To: xxxxx@lists.osr.com
>
>Cc: Neal Christiansen
>
>Subject: RE: FILE_READ_ONLY_DEVICE is Wrong on certain drives
>
>
>
>Hi Neal!
>
>
>
>Thanks for the input… I seem to be having a problem though… I
>implemented the IOCTL and it seems to be mounting the drive to actually
>check the media for read-only info. The problem is that the point of my
>FSF is to BLOCK mounts. If the IOCTL is mounting, I have no control over
>it, so it defeats the purpose. I need to check to see if the device is
>writable or read-only without actually mounting it. That is why the
>characteristics FILE_READ_ONLY_DEVICE would have been good. Do you have
>any ideas?
>
>
>
>Thanks!
>
>Tom
>
>
>
>----------------
>
>
>
>Subject: RE: FILE_READ_ONLY_DEVICE is Wrong on certain drives
>
>From: “Neal Christiansen”
>
>Newsgroups: ntfsd
>
>To: “Windows File Systems Devs Interest List”
>
>
>
>Handal,
>
>
>
>The READ_ONLY characteristic is not reliable and should not be used. Use
>the IOCTL described below. If you look at the SFILTER and FileSpy samples
>in the IFSKit they have a routine for detecting snapshot volumes which
>uses this IOCTL.
>
>
>
>Snapshot volumes are a good example of this problem, they are readonly but
>do not set this flag. I wanted them to fix this but their response was
>that since no one used the flag why should they bother setting it.
>
>
>
>The flag should be deprecated.
>
>
>
>Neal Christiansen
>
>Microsoft File System Filter Group Lead
>
>This posting is provided “AS IS” with no warranties, and confers no rights
>
>
>
>

>
>From: xxxxx@lists.osr.com
>[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
>
>Sent: Friday, January 21, 2005 10:36 AM
>
>To: Windows File Systems Devs Interest List
>
>Subject: Re: [ntfsd] FILE_READ_ONLY_DEVICE is Wrong on certain drives
>
>
>
> IOCTL_DISK_IS_WRITABLE
>
>
>
>Maxim Shatskih, Windows DDK MVP
>
>StorageCraft Corporation
>
>xxxxx@storagecraft.com
>
>http://www.storagecraft.com
>
>----- Original Message -----
>
>From: Handal, Thomas
>
>To: Windows File Systems Devs Interest List
>
>Sent: Thursday, January 20, 2005 2:27 AM
>
>Subject: [ntfsd] FILE_READ_ONLY_DEVICE is Wrong on certain drives
>
>
>
>Hi All,
>
>
>
>I am currently writing a FSF and am having a problem. I need to determine
>if a drive is read only or not. This is before it is mounted, but during
>the mount IRP. I look at the Characteristics & FILE_READ_ONLY_DEVICE bit,
>which works on about 90% of the drives that I test, but once in awhile it
>reports writable on certain drives which are CD-ROMs, which are obviously
>not writable.
>
>These are not CD-Rs or RWs… I am not sure if this is a bug in the driver
>code for that CD-ROM or if the firmware of the CD-ROM is reporting
>writable for some reason?? I am baffled here… And apparently this only
>happens on XP, not NT or 2000. Anyone run into anything like this? I am
>stuck…
>
>
>
>Thanks in advance
>
>Tom
>
>
>
>
>
>—
>
>Questions? First check the IFS FAQ at
>https://www.osronline.com/article.cfm?id=17
>
>
>
>You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
>
>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: unknown lmsubst tag argument: ‘’
>
>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: unknown lmsubst tag argument: ‘’
>To unsubscribe send a blank email to xxxxx@lists.osr.com

At 01:00 PM 1/26/2005 -0800, Handal, Thomas wrote:

Hi Dan

Thanks for the input. I am sure this works and I found the example
in fscntl.c. The only thing is that this call seems to be mounting the
actual device to determine if the media is writable.

As Neal said, this should not cause a mount if sent to the storage
stack. Are you sending the ioctl to the device object at Vpb->RealDevice?

I am in the middle of processing an IRP_MN_MOUNT_VOLUME, which needs to be
blocked if necessary. If I call this IOCTL, then the drive gets mounted,
which makes my driver useless.

This makes me wonder what you mean by “gets mounted”. If you are in the
middle of a volume mount request in a file system filter driver, then Mount
Manager is holding a global ERESOURCE exclusive, and there is no way the
volume will be mounted. Instead, if IO Manager attempts to mount the
volume, you would deadlock.

I need a way to tell if the DEVICE is a writable device or not. The media
doesnt really matter. This is only for removable media devices, of
course. So, I need to find a way if the device is read-only or writable
and without mounting the actual disk.

So you are saying you want the following to be considered writable:

  • A CDRW drive containing CDROM media
  • A zip or floppy drive containing write protected media

Is this possible?

If I understand your requirements, it might not be.

Thanks

Tom


Subject: RE:FILE_READ_ONLY_DEVICE is Wrong on certain drives

From: Dan Kyler
>
>Newsgroups: ntfsd
>
>To: “Windows File Systems Devs Interest List”
>
>
>
>I’m going to risk my reputation (if any), and disagree with Neal. :slight_smile:
>
>
>
>I don’t think you should do a direct device open. You want to build a
>
>IRP_MJ_DEVICE_CONTROL Irp with IoBuildDeviceIoControlRequest(), and send it
>
>to Vpb->RealDevice.
>
>
>
>Again, see the FastFat sample, specifically routine
>
>FatIsMediaWriteProtected in fsctrl.c. It is a perfect example of what you
>
>need to do.
>
>
>
>- Dan.
>
>
>
>At 09:25 AM 1/26/2005 -0800, you wrote:
>
>
>
> >Hi Neal!
>
> >
>
> >
>
> >
>
> >I am doing this during the IRP_MN_MOUNT_VOLUME. It is during the actual
>
> >request, not in the worker thread, because I have to block the mount if
>
> >necessary. I am not sure if I am sending the request to the storage
>
> >stack. I have never heard of Direct Device Open, (probably cause its not
>
> >documented& thanks for looking into that)&
>
> >
>
> >
>
> >
>
> >How do you do a volume open? I am not sure that I have done that before
>
> >in the kernel. Am I going to do this with a CreateFiletype of call? How
>
> >do I send this request specifically to the Storage Stack,which
>
> >DeviceObject is this? I am sorry if these are stupid questions, but I am
>
> >normally a UNIX Kernel guy, just been working in the Windows kernel world
>
> >for about 5 months or so&
>
> >
>
> >
>
> >
>
> >I appreciate your help! You are my only hope! J
>
> >
>
> >Tom
>
> >
>
> >
>
> >
>
> >----------------------
>
> >
>
> >Subject: RE: FILE_READ_ONLY_DEVICE is Wrong on certain drives
>
> >
>
> >From: “Neal Christiansen”
>
> >
>
> >Newsgroups: ntfsd
>
> >
>
> >To:
>
> >
>
> >
>
> >
>
> >Handal,
>
> >
>
> >
>
> >
>
> >Are you sending the request to the file system stack or the storage
>
> >stack? You should be sending it directly to the storage stack.
>
> >
>
> >
>
> >
>
> >At what point are you sending the request, while you are processing a
>
> >mount or are you doing this at some other time like in a worker
>
> >thread? It sounds to me like you were trying to do your own “open” to get
>
> >this information.
>
> >
>
> >
>
> >
>
> >The system supports the concept of a “Direct Device Open”. I looked at
>
> >the IFSKit docs and they do not talk about this. I have filed a doc bug
>
> >to get this fixed.
>
> >
>
> >
>
> >
>
> >In the meantime:
>
> >
>
> >If you do a volume open (volume name only) with no related file object and
>
> >specify “FILE_READ_ATTRIBUTES” for the “Desired Access” parameter it will
>
> >open the storage stack device directly and not mount the volume. You
>
> >should then be able to do the query. You need to be careful because you
>
> >are not talking to a file system, you are talking directly to the storage
>
> >stack. This should work from both user mode and kernel mode.
>
> >
>
> >
>
> >
>
> >Note that you can also specify the SYNCHORNIZE flag in the “Desired
>
> >Access” parameter if you want to.
>
> >
>
> >
>
> >
>
> >Neal Christiansen
>
> >
>
> >Microsoft File System Filter Group Lead
>
> >
>
> >This posting is provided “AS IS” with no warranties, and confers no rights
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >From: Handal, Thomas [mailto:xxxxx@websense.com]
>
> >
>
> >Sent: Monday, January 24, 2005 4:37 PM
>
> >
>
> >To: xxxxx@lists.osr.com
>
> >
>
> >Cc: Neal Christiansen
>
> >
>
> >Subject: RE: FILE_READ_ONLY_DEVICE is Wrong on certain drives
>
> >
>
> >
>
> >
>
> >Hi Neal!
>
> >
>
> >
>
> >
>
> >Thanks for the input… I seem to be having a problem though… I
>
> >implemented the IOCTL and it seems to be mounting the drive to actually
>
> >check the media for read-only info. The problem is that the point of my
>
> >FSF is to BLOCK mounts. If the IOCTL is mounting, I have no control over
>
> >it, so it defeats the purpose. I need to check to see if the device is
>
> >writable or read-only without actually mounting it. That is why the
>
> >characteristics FILE_READ_ONLY_DEVICE would have been good. Do you have
>
> >any ideas?
>
> >
>
> >
>
> >
>
> >Thanks!
>
> >
>
> >Tom
>
> >
>
> >
>
> >
>
> >----------------
>
> >
>
> >
>
> >
>
> >Subject: RE: FILE_READ_ONLY_DEVICE is Wrong on certain drives
>
> >
>
> >From: “Neal Christiansen”
>
> >
>
> >Newsgroups: ntfsd
>
> >
>
> >To: “Windows File Systems Devs Interest List”
>
> >
>
> >
>
> >
>
> >Handal,
>
> >
>
> >
>
> >
>
> >The READ_ONLY characteristic is not reliable and should not be used. Use
>
> >the IOCTL described below. If you look at the SFILTER and FileSpy samples
>
> >in the IFSKit they have a routine for detecting snapshot volumes which
>
> >uses this IOCTL.
>
> >
>
> >
>
> >
>
> >Snapshot volumes are a good example of this problem, they are readonly but
>
> >do not set this flag. I wanted them to fix this but their response was
>
> >that since no one used the flag why should they bother setting it.
>
> >
>
> >
>
> >
>
> >The flag should be deprecated.
>
> >
>
> >
>
> >
>
> >Neal Christiansen
>
> >
>
> >Microsoft File System Filter Group Lead
>
> >
>
> >This posting is provided “AS IS” with no warranties, and confers no rights
>
> >
>
> >
>
> >
>
> >

>
> >
>
> >From: xxxxx@lists.osr.com
>
> >[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
>
> >
>
> >Sent: Friday, January 21, 2005 10:36 AM
>
> >
>
> >To: Windows File Systems Devs Interest List
>
> >
>
> >Subject: Re: [ntfsd] FILE_READ_ONLY_DEVICE is Wrong on certain drives
>
> >
>
> >
>
> >
>
> > IOCTL_DISK_IS_WRITABLE
>
> >
>
> >
>
> >
>
> >Maxim Shatskih, Windows DDK MVP
>
> >
>
> >StorageCraft Corporation
>
> >
>
> >xxxxx@storagecraft.com
>
> >
>
> >http://www.storagecraft.com
>
> >
>
> >----- Original Message -----
>
> >
>
> >From: Handal, Thomas
>
> >
>
> >To: Windows File Systems Devs Interest List
>
> >
>
> >Sent: Thursday, January 20, 2005 2:27 AM
>
> >
>
> >Subject: [ntfsd] FILE_READ_ONLY_DEVICE is Wrong on certain drives
>
> >
>
> >
>
> >
>
> >Hi All,
>
> >
>
> >
>
> >
>
> >I am currently writing a FSF and am having a problem. I need to determine
>
> >if a drive is read only or not. This is before it is mounted, but during
>
> >the mount IRP. I look at the Characteristics & FILE_READ_ONLY_DEVICE bit,
>
> >which works on about 90% of the drives that I test, but once in awhile it
>
> >reports writable on certain drives which are CD-ROMs, which are obviously
>
> >not writable.
>
> >
>
> >These are not CD-Rs or RWs… I am not sure if this is a bug in the driver
>
> >code for that CD-ROM or if the firmware of the CD-ROM is reporting
>
> >writable for some reason?? I am baffled here… And apparently this only
>
> >happens on XP, not NT or 2000. Anyone run into anything like this? I am
>
> >stuck…
>
> >
>
> >
>
> >
>
> >Thanks in advance
>
> >
>
> >Tom
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >—
>
> >
>
> >Questions? First check the IFS FAQ at
>
> >https://www.osronline.com/article.cfm?id=17
>
> >
>
> >
>
> >
>
> >You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
>
> >
>
> >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: unknown lmsubst tag argument: ‘’
>
> >
>
> >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: unknown lmsubst tag argument: ‘’
>
> >To unsubscribe send a blank email to xxxxx@lists.osr.com

Dan and Neil

I appreciate all of your help on this problem. I will continue to
work on it to see if I can ultimately figure it out. You have both been
a great help and I appreciate it.

Thanks!

Tom

Subject: Re: Subject: RE:FILE_READ_ONLY_DEVICE is Wrong on certain
drives

From: Dan Kyler

Newsgroups: ntfsd

To: “Windows File Systems Devs Interest List”

>Now, on the other hand, any CD I try in any CD drive shows up as

writable. Every single CD I try. I cant get 1 CD to show up as

read-only. Could you shed light on this? Or do all CDs just show up as

writable?

I don’t really do CD’s, but I think I can shed some light on it. But

you’re not going to like the answer. The following comment is in the

SFilter sample, before it’s IOCTL_IS_DISK_WRITABLE call:

//

// It has the correct device type, see if it is marked as read
only.

//

// NOTE: You need to be careful which device types you do
this

operation

// on. It is accurate for this type but for other
device

// types it may return misleading information. For

example the

// current microsoft cdrom driver always returns CD
media as

// readonly, even if the media may be writable. On
other

types

// this state may change.

//

Although you have a file system filter driver, this particular question

(how the CDROM driver responds to this Ioctl), may be better asked on
the

NTDEV list. Also, the CDROM driver does appear to be included in the

DDK. You might look at how it handles the ioctl, and see if there’s

anything that might help you (or perhaps there’s another Ioctl that will

give you info about media type: CDROM/CDRW.)

Sorry I couldn’t help more…

- Dan.

At 03:34 PM 1/26/2005 -0800, you wrote:

>Hi Dan

>

>

>

> You were right; it is not mounting the drive. The problem was
that I

> was using an Audio CD to test and I guess audio can still play without

> the file system being mounted (because that just uses IOCTLs to tell
the

> drive to start, stop, etc.). I tried a data CD, and it worked. Dont

> worry; I hit myself in the face with my mouse for that one&

>

>

>

>Now, on to the next problem: The IOCTL works, for instance, I tried a

>floppy disk. I write-protected it and it showed up as write-protected.
I

>put it back to writable and it showed writable. Now, on the other hand,

>any CD I try in any CD drive shows up as writable. Every single CD I

>try. I cant get 1 CD to show up as read-only. Could you shed light
on

>this? Or do all CDs just show up as writable?

>

>

>

>Thanks!

>

>Tom

>