sys: IRP_MJ_CLEANUP

This commit is contained in:
Bill Zissimopoulos 2016-01-04 14:30:02 -08:00
parent 3abc2dbdf1
commit 162fd3e8c8
4 changed files with 31 additions and 11 deletions

View File

@ -45,10 +45,30 @@ static NTSTATUS FspFsvrtCleanup(
}
static NTSTATUS FspFsvolCleanup(
PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
PDEVICE_OBJECT FsvolDeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
{
PAGED_CODE();
/* is this a valid FileObject? */
if (!FspFileContextIsValid(IrpSp->FileObject->FsContext))
return STATUS_SUCCESS;
PFILE_OBJECT FileObject = IrpSp->FileObject;
FSP_FILE_CONTEXT *FsContext = FileObject->FsContext;
LONG OpenCount;
/* all handles on this FileObject are gone; close the FileObject */
OpenCount = FspFileContextClose(FsContext);
/* is the FsContext going away as well? */
if (0 == OpenCount)
{
/* remove the FsContext from the volume device generic table */
FspFsvolDeviceLockContextTable(FsvolDeviceObject);
FspFsvolDeviceDeleteContext(FsvolDeviceObject, FsContext->UserContext, 0);
FspFsvolDeviceUnlockContextTable(FsvolDeviceObject);
}
Irp->IoStatus.Information = 0;
return STATUS_SUCCESS;
}

View File

@ -392,7 +392,7 @@ VOID FspFsvolCreateComplete(
* If an FsContext with the same UserContext already exists, then use that
* FsContext instead.
*/
FspFsvolDeviceLockContext(FsvolDeviceObject);
FspFsvolDeviceLockContextTable(FsvolDeviceObject);
FsContext = FspFsvolDeviceInsertContext(FsvolDeviceObject,
FsContext->UserContext, FsContext, &FsContext->ElementStorage, &Inserted);
ASSERT(0 != FsContext);
@ -409,7 +409,7 @@ VOID FspFsvolCreateComplete(
*/
FspFileContextRetain(FsContext);
FspFileContextOpen(FsContext);
FspFsvolDeviceUnlockContext(FsvolDeviceObject);
FspFsvolDeviceUnlockContextTable(FsvolDeviceObject);
/* set up share access on FileObject; user-mode file system assumed to have done share check */
IoSetShareAccess(Response->Rsp.Create.Opened.GrantedAccess, IrpSp->Parameters.Create.ShareAccess,

View File

@ -27,10 +27,10 @@ static IO_TIMER_ROUTINE FspFsvolDeviceTimerRoutine;
static WORKER_THREAD_ROUTINE FspFsvolDeviceExpirationRoutine;
_IRQL_raises_(APC_LEVEL)
_IRQL_saves_global_(OldIrql, DeviceObject)
VOID FspFsvolDeviceLockContext(PDEVICE_OBJECT DeviceObject);
VOID FspFsvolDeviceLockContextTable(PDEVICE_OBJECT DeviceObject);
_IRQL_requires_(APC_LEVEL)
_IRQL_restores_global_(OldIrql, DeviceObject)
VOID FspFsvolDeviceUnlockContext(PDEVICE_OBJECT DeviceObject);
VOID FspFsvolDeviceUnlockContextTable(PDEVICE_OBJECT DeviceObject);
PVOID FspFsvolDeviceLookupContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier);
PVOID FspFsvolDeviceInsertContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier, PVOID Context,
FSP_DEVICE_GENERIC_TABLE_ELEMENT *ElementStorage, PBOOLEAN PInserted);
@ -52,8 +52,8 @@ VOID FspDeviceDeleteAll(VOID);
#pragma alloc_text(PAGE, FspDeviceDelete)
#pragma alloc_text(PAGE, FspFsvolDeviceInit)
#pragma alloc_text(PAGE, FspFsvolDeviceFini)
#pragma alloc_text(PAGE, FspFsvolDeviceLockContext)
#pragma alloc_text(PAGE, FspFsvolDeviceUnlockContext)
#pragma alloc_text(PAGE, FspFsvolDeviceLockContextTable)
#pragma alloc_text(PAGE, FspFsvolDeviceUnlockContextTable)
#pragma alloc_text(PAGE, FspFsvolDeviceLookupContext)
#pragma alloc_text(PAGE, FspFsvolDeviceInsertContext)
#pragma alloc_text(PAGE, FspFsvolDeviceDeleteContext)
@ -414,7 +414,7 @@ static VOID FspFsvolDeviceExpirationRoutine(PVOID Context)
_IRQL_raises_(APC_LEVEL)
_IRQL_saves_global_(OldIrql, DeviceObject)
VOID FspFsvolDeviceLockContext(PDEVICE_OBJECT DeviceObject)
VOID FspFsvolDeviceLockContextTable(PDEVICE_OBJECT DeviceObject)
{
PAGED_CODE();
@ -424,7 +424,7 @@ VOID FspFsvolDeviceLockContext(PDEVICE_OBJECT DeviceObject)
_IRQL_requires_(APC_LEVEL)
_IRQL_restores_global_(OldIrql, DeviceObject)
VOID FspFsvolDeviceUnlockContext(PDEVICE_OBJECT DeviceObject)
VOID FspFsvolDeviceUnlockContextTable(PDEVICE_OBJECT DeviceObject)
{
PAGED_CODE();

View File

@ -451,10 +451,10 @@ BOOLEAN FspDeviceRetain(PDEVICE_OBJECT DeviceObject);
VOID FspDeviceRelease(PDEVICE_OBJECT DeviceObject);
_IRQL_raises_(APC_LEVEL)
_IRQL_saves_global_(OldIrql, DeviceObject)
VOID FspFsvolDeviceLockContext(PDEVICE_OBJECT DeviceObject);
VOID FspFsvolDeviceLockContextTable(PDEVICE_OBJECT DeviceObject);
_IRQL_requires_(APC_LEVEL)
_IRQL_restores_global_(OldIrql, DeviceObject)
VOID FspFsvolDeviceUnlockContext(PDEVICE_OBJECT DeviceObject);
VOID FspFsvolDeviceUnlockContextTable(PDEVICE_OBJECT DeviceObject);
PVOID FspFsvolDeviceLookupContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier);
PVOID FspFsvolDeviceInsertContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier, PVOID Context,
FSP_DEVICE_GENERIC_TABLE_ELEMENT *ElementStorage, PBOOLEAN PInserted);