Detecting volume dismount failures

Hello,
I have a fs filter that on dismount, removes resources for the underlying
devices. However if the mount fails (ie, the volume is in use) I cant seem
to reliably detect this case. Sometimes, the request finishes with an
error, but usually it says success (Irp->IoStatus.Status) So I hijack the
file object and do a IsVolumeMounted ioctl. This works most of the time
(returns STATUS_VOLUME_NOT_MOUNTED), but every now and then it says the
volume is mounted when it isn’t (it returns status_success). On the next
file open, it trys to do a mount. Here is what I am doing… Thanks,

Status = ForwardIrpSynchronous(DeviceObject,Irp);

PutBack = TRUE;

if(Status==STATUS_SUCCESS) {
PFILE_OBJECT FO = irpSp->FileObject;
if(!FO) {
FO = Irp->Tail.Overlay.OriginalFileObject;
}
ASSERT(FO);
status2 = FS_IsVolumeMounted(FO);
// PutBack is TRUE only if volume is mounted
PutBack = (status2 == STATUS_SUCCESS);
} else {
status2 = Status;
}

if(PutBack) {
// dismount didnt really happen… undo remove
}

This is in the IRP_MJ_FILE_SYSTEM_CONTROL handling for FSCTL_DISMOUNT_VOLUME

thanks,
rob


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Some more info…

It only appears to not work correctly if on a volume that is controlled by
cluster server (this is on Win2k)…

rob

Hello,
I have a fs filter that on dismount, removes resources for the
underlying
devices. However if the mount fails (ie, the volume is in use) I
cant seem
to reliably detect this case. Sometimes, the request finishes with an
error, but usually it says success (Irp->IoStatus.Status) So I hijack the
file object and do a IsVolumeMounted ioctl. This works most of the time
(returns STATUS_VOLUME_NOT_MOUNTED), but every now and then it says the
volume is mounted when it isn’t (it returns status_success). On the next
file open, it trys to do a mount. Here is what I am doing… Thanks,

Status = ForwardIrpSynchronous(DeviceObject,Irp);

PutBack = TRUE;

if(Status==STATUS_SUCCESS) {
PFILE_OBJECT FO = irpSp->FileObject;
if(!FO) {
FO = Irp->Tail.Overlay.OriginalFileObject;
}
ASSERT(FO);
status2 = FS_IsVolumeMounted(FO);
// PutBack is TRUE only if volume is mounted
PutBack = (status2 == STATUS_SUCCESS);
} else {
status2 = Status;
}

if(PutBack) {
// dismount didnt really happen… undo remove
}

This is in the IRP_MJ_FILE_SYSTEM_CONTROL handling for
FSCTL_DISMOUNT_VOLUME

thanks,
rob


You are currently subscribed to ntfsd as: xxxxx@cdp.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com