Subject: RE:FILE_READ_ONLY_DEVICE is Wrong on certain drives

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. Don’t
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 can’t get 1 CD to show up as read-only. Could you shed light
on this? Or do all CD’s just show up as writable?

Thanks!

Tom


Subject: RE:FILE_READ_ONLY_DEVICE is Wrong on certain drives

From: Dan Kyler

Newsgroups: ntfsd

To:

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

>

> >

>

> >

>

> >

>

>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


Subject: RE:FILE_READ_ONLY_DEVICE is Wrong on certain drives

From: Dan Kyler
>
>Newsgroups: ntfsd
>
>To:
>
>
>
>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
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
>
>—
>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