FW: RE:FILE_READ_ONLY_DEVICE is Wrong on certain drives

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. 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. I need a way to tell if the DEVICE is a
writable device or not. The media doesn’t 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.

Is this possible?

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