When un/locking a volume, also handle VPB state
svn path=/trunk/; revision=74047
PFILE_OBJECT FileObject;
PDEVICE_EXTENSION DeviceExt;
PVFATFCB Fcb;
PFILE_OBJECT FileObject;
PDEVICE_EXTENSION DeviceExt;
PVFATFCB Fcb;
DPRINT("VfatLockOrUnlockVolume(%p, %d)\n", IrpContext, Lock);
DeviceExt = IrpContext->DeviceExt;
FileObject = IrpContext->FileObject;
Fcb = FileObject->FsContext;
DPRINT("VfatLockOrUnlockVolume(%p, %d)\n", IrpContext, Lock);
DeviceExt = IrpContext->DeviceExt;
FileObject = IrpContext->FileObject;
Fcb = FileObject->FsContext;
+ Vpb = DeviceExt->FATFileObject->Vpb;
/* Only allow locking with the volume open */
if (!BooleanFlagOn(Fcb->Flags, FCB_IS_VOLUME))
/* Only allow locking with the volume open */
if (!BooleanFlagOn(Fcb->Flags, FCB_IS_VOLUME))
return STATUS_ACCESS_DENIED;
}
return STATUS_ACCESS_DENIED;
}
+ /* Bail out if it's already in the demanded state */
+ if ((BooleanFlagOn(Vpb->Flags, VPB_LOCKED) && Lock) ||
+ (!BooleanFlagOn(Vpb->Flags, VPB_LOCKED) && !Lock))
+ {
+ return STATUS_ACCESS_DENIED;
+ }
+
/* Deny locking if we're not alone */
if (Lock && DeviceExt->OpenHandleCount != 1)
{
/* Deny locking if we're not alone */
if (Lock && DeviceExt->OpenHandleCount != 1)
{
if (Lock)
{
DeviceExt->Flags |= VCB_VOLUME_LOCKED;
if (Lock)
{
DeviceExt->Flags |= VCB_VOLUME_LOCKED;
+ Vpb->Flags |= VPB_LOCKED;
}
else
{
DeviceExt->Flags &= ~VCB_VOLUME_LOCKED;
}
else
{
DeviceExt->Flags &= ~VCB_VOLUME_LOCKED;
+ Vpb->Flags &= ~VPB_LOCKED;