If this really is a storage device driver:
- whether the device is mounted or not is irrelevant to the function of
this IOCTL
- returning a static value of “1” defeats the purpose of the IOCTL
CHECK_VERIFY exists to allow a filesystem to discover if media state may
have changed such that the media in a removable device underneath the
storage stack it attached to is no longer present (i.e., needs to be
verified). There are three correct things to do here:
- check the device state - is it indicating a media change event?
- set the DO_VERIFY_VOLUME flag on the DO which a filesystem mounts on
(i.e., the one you have the OB namespace link to) whenever state has
changed, in the course of #1 or otherwise.
- in your device extension, maintain a count of the number of times
state has changed. Return this in the output buffer (ULONG).
- if media change was detected in the course of the IOCTL, return
STATUS_VERIFY_REQUIRED, otherwise STATUS_SUCCESS.
Filesystems use that media change count to figure out if they need to do
expensive checks to see if the media they mounted is still in the
device. DO_VERIFY_VOLUME came first, but was found to be insufficient on
its own (though it is still required).
I would strongly suggest understanding how a removable media filesystem
uses this. The FASTFAT and CDFS code in the IFSKIT are both examples of
removable media filesystems which depend on this working properly.
Dan Lovinger
Microsoft Corporation
This posting is provided “AS IS” with no warranties and confers no
rights.
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of David J. Craig
Sent: Friday, July 11, 2003 5:47 PM
To: File Systems Developers
Subject: [ntfsd] Re: Removable device and disk check verify question
OK, I guess I had to read the DDK docs about how to handle this request,
as
you apparently have not done. You are not doing it correctly. There
are
three cases involved. You are not checking that the OutputBufferLength
is
= sizeof(ULONG). You are not checking the VPB for the mounted flag.
You
have some internal flag that duplicates the data, which is a violation
of
good programming practices. There error(s) being returned are not those
required to be returned for this request.
You will get a lot of these to protect each read and write, but
returning
the correct data will help.
“ChuBun” wrote in message news:xxxxx@ntfsd…
>
> Yes. At the end of the routine,
> ////
> Irp->IoStatus.Status = status;
> IoCompleteRequest(Irp, IO_NO_INCREMENT);
> return status;
> ////
>
> “David J. Craig” wrote in message
> news:xxxxx@ntfsd…
> >
> > Is status being copied to the IoStatus structure? You will get a
lot of
> > verifies normally.
> >
> > “ChuBun” wrote in message news:xxxxx@ntfsd…
> > >
> > > Hello,
> > > I’m writing a driver for a removable disk device. There are
excessive
> > > disk check verify IOCTLs when I try to open a file on the disk.
> > > Does anybody knows what could be the reason for this.
> > > Following is how the IOCTL is handled
> > >
> > > case IOCTL_DISK_CHECK_VERIFY:
> > > case IOCTL_STORAGE_CHECK_VERIFY:
> > > {
> > >
> > > if(pDevExt->IsMounted)
> > > {
> > > if(irpStack->Parameters.DeviceIoControl.OutputBufferLength)
> > > {
> > > // this part will repeats for 10-50 times at a time
> > > *((PULONG)Irp->AssociatedIrp.SystemBuffer) = 1; //0;
> > > Irp->IoStatus.Information = sizeof(ULONG);
> > > }
> > > else
> > > {
> > > Irp->IoStatus.Information = 0;
> > > }
> > > status = STATUS_SUCCESS;
> > > }
> > > else
> > > {
> > > Irp->IoStatus.Information = 0;
> > > status = STATUS_INVALID_DEVICE_STATE;
> > > }
> > > break;
> > > }
> > >
> > > Thank you for your help.
> > >
> > > Chu Bun
> > >
> > >
> > >
> > >
> >
> >
> >
> >
>
>
>
>
—
You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com