mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-23 00:43:00 -05:00
sys: FspFsvolCreateClose, FspFsvolCleanup, FspFsvolClose
This commit is contained in:
parent
fa2ab4f8f7
commit
25154ca7c1
@ -60,6 +60,8 @@ static NTSTATUS FspFsvolCleanup(
|
||||
FspFsvrtDeviceExtension(FsvrtDeviceObject);
|
||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||
FSP_FILE_CONTEXT *FsContext = FileObject->FsContext;
|
||||
UINT64 UserContext = FsContext->UserContext;
|
||||
UINT64 UserContext2 = (UINT_PTR)FileObject->FsContext2;
|
||||
BOOLEAN FileNameRequired = 0 != FsvrtDeviceExtension->VolumeParams.FileNameRequired;
|
||||
BOOLEAN DeletePending;
|
||||
LONG OpenCount;
|
||||
@ -101,11 +103,7 @@ static NTSTATUS FspFsvolCleanup(
|
||||
/* create the user-mode file system request */
|
||||
Result = FspIopCreateRequest(Irp, FileNameRequired ? &FsContext->FileName : 0, 0, &Request);
|
||||
if (!NT_SUCCESS(Result))
|
||||
{
|
||||
/* IRP_MJ_CLEANUP cannot really fail :-\ */
|
||||
Result = STATUS_SUCCESS;
|
||||
goto exit;
|
||||
}
|
||||
goto leak_exit;
|
||||
|
||||
/*
|
||||
* The new request is associated with our IRP and will be deleted during its completion.
|
||||
@ -113,12 +111,24 @@ static NTSTATUS FspFsvolCleanup(
|
||||
|
||||
/* populate the Cleanup request */
|
||||
Request->Kind = FspFsctlTransactCleanupKind;
|
||||
Request->Req.Cleanup.UserContext = FsContext->UserContext;
|
||||
Request->Req.Cleanup.UserContext2 = (UINT_PTR)FileObject->FsContext2;
|
||||
Request->Req.Cleanup.UserContext = UserContext;
|
||||
Request->Req.Cleanup.UserContext2 = UserContext2;
|
||||
Request->Req.Cleanup.Delete = DeletePending && 0 == OpenCount;
|
||||
|
||||
Result = STATUS_PENDING;
|
||||
|
||||
goto exit;
|
||||
|
||||
leak_exit:;
|
||||
#if DBG
|
||||
DEBUGLOG("FileObject=%p[%p:\"%wZ\"], UserContext=%llx, UserContext2=%p: "
|
||||
"error: the user-mode file system handle will be leaked!",
|
||||
IrpSp->FileObject, IrpSp->FileObject->RelatedFileObject, IrpSp->FileObject->FileName,
|
||||
UserContext, UserContext2);
|
||||
#endif
|
||||
/* IRP_MJ_CLEANUP cannot really fail :-\ */
|
||||
Result = STATUS_SUCCESS;
|
||||
|
||||
exit:;
|
||||
}
|
||||
finally
|
||||
|
@ -60,6 +60,8 @@ static NTSTATUS FspFsvolClose(
|
||||
FspFsvrtDeviceExtension(FsvrtDeviceObject);
|
||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||
FSP_FILE_CONTEXT *FsContext = FileObject->FsContext;
|
||||
UINT64 UserContext = FsContext->UserContext;
|
||||
UINT64 UserContext2 = (UINT_PTR)FileObject->FsContext2;
|
||||
BOOLEAN FileNameRequired = 0 != FsvrtDeviceExtension->VolumeParams.FileNameRequired;
|
||||
FSP_FSCTL_TRANSACT_REQ *Request;
|
||||
|
||||
@ -69,11 +71,7 @@ static NTSTATUS FspFsvolClose(
|
||||
/* create the user-mode file system request */
|
||||
Result = FspIopCreateRequest(0, FileNameRequired ? &FsContext->FileName : 0, 0, &Request);
|
||||
if (!NT_SUCCESS(Result))
|
||||
{
|
||||
/* IRP_MJ_CLOSE cannot really fail :-\ */
|
||||
Result = STATUS_SUCCESS;
|
||||
goto exit;
|
||||
}
|
||||
goto leak_exit;
|
||||
|
||||
/*
|
||||
* The new request is associated with our IRP and will be deleted during its completion.
|
||||
@ -81,19 +79,26 @@ static NTSTATUS FspFsvolClose(
|
||||
|
||||
/* populate the Close request */
|
||||
Request->Kind = FspFsctlTransactCloseKind;
|
||||
Request->Req.Close.UserContext = FsContext->UserContext;
|
||||
Request->Req.Close.UserContext2 = (UINT_PTR)FileObject->FsContext2;
|
||||
Request->Req.Close.UserContext = UserContext;
|
||||
Request->Req.Close.UserContext2 = UserContext2;
|
||||
|
||||
/* post as a work request; this allows us to complete our own IRP and return immediately! */
|
||||
if (!FspIopPostWorkRequest(DeviceObject, Request))
|
||||
{
|
||||
/* no need to delete the request here as FspIopPostWorkRequest() will do so in all cases */
|
||||
goto leak_exit;
|
||||
|
||||
/* IRP_MJ_CLOSE cannot really fail :-\ */
|
||||
Result = STATUS_SUCCESS;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto exit;
|
||||
|
||||
leak_exit:;
|
||||
#if DBG
|
||||
DEBUGLOG("FileObject=%p[%p:\"%wZ\"], UserContext=%llx, UserContext2=%p: "
|
||||
"error: the user-mode file system handle will be leaked!",
|
||||
IrpSp->FileObject, IrpSp->FileObject->RelatedFileObject, IrpSp->FileObject->FileName,
|
||||
UserContext, UserContext2);
|
||||
#endif
|
||||
/* IRP_MJ_CLOSE cannot really fail :-\ */
|
||||
Result = STATUS_SUCCESS;
|
||||
|
||||
exit:;
|
||||
|
@ -680,6 +680,8 @@ static VOID FspFsvolCreateClose(
|
||||
FspFsvrtDeviceExtension(FsvolDeviceExtension->FsvrtDeviceObject);
|
||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||
FSP_FILE_CONTEXT *FsContext = FileObject->FsContext;
|
||||
UINT64 UserContext = FsContext->UserContext;
|
||||
UINT64 UserContext2 = (UINT_PTR)FileObject->FsContext2;
|
||||
BOOLEAN FileNameRequired = 0 != FsvrtDeviceExtension->VolumeParams.FileNameRequired;
|
||||
FSP_FSCTL_TRANSACT_REQ *Request;
|
||||
|
||||
@ -690,8 +692,8 @@ static VOID FspFsvolCreateClose(
|
||||
|
||||
/* populate the CreateCleanupClose request */
|
||||
Request->Kind = FspFsctlTransactCreateCleanupCloseKind;
|
||||
Request->Req.Cleanup.UserContext = FsContext->UserContext;
|
||||
Request->Req.Cleanup.UserContext2 = (UINT_PTR)FileObject->FsContext2;
|
||||
Request->Req.Cleanup.UserContext = UserContext;
|
||||
Request->Req.Cleanup.UserContext2 = UserContext2;
|
||||
Request->Req.Cleanup.Delete = FILE_CREATED == Response->IoStatus.Information;
|
||||
|
||||
/* post as a work request */
|
||||
@ -706,7 +708,7 @@ leak_exit:;
|
||||
DEBUGLOG("FileObject=%p[%p:\"%wZ\"], UserContext=%llx, UserContext2=%p: "
|
||||
"error: the user-mode file system handle will be leaked!",
|
||||
IrpSp->FileObject, IrpSp->FileObject->RelatedFileObject, IrpSp->FileObject->FileName,
|
||||
FsContext->UserContext, FileObject->FsContext2);
|
||||
UserContext, UserContext2);
|
||||
#endif
|
||||
|
||||
exit:
|
||||
|
Loading…
x
Reference in New Issue
Block a user