mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-23 00:43:00 -05:00
sys: fsctl
This commit is contained in:
parent
68eefd9e24
commit
b5bd03df30
@ -37,6 +37,19 @@ FSP_DRIVER_DISPATCH FspFileSystemControl;
|
|||||||
#pragma alloc_text(PAGE, FspFileSystemControl)
|
#pragma alloc_text(PAGE, FspFileSystemControl)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static inline PDEVICE_OBJECT FspFsvolDeviceObjectFromFileObject(PFILE_OBJECT FileObject)
|
||||||
|
{
|
||||||
|
PDEVICE_OBJECT FsvolDeviceObject;
|
||||||
|
FSP_FSCTL_FILE_CONTEXT2 *FsContext2 = FileObject->FsContext2;
|
||||||
|
|
||||||
|
ExAcquireFastMutex(&FsContext2->FastMutex);
|
||||||
|
FsvolDeviceObject = FsContext2->FsvolDeviceObject;
|
||||||
|
ExReleaseFastMutex(&FsContext2->FastMutex);
|
||||||
|
|
||||||
|
/* no FspDeviceRetain on the volume device, because it exists until the FileObject IRP_MJ_CLEANUP */
|
||||||
|
return FsvolDeviceObject;
|
||||||
|
}
|
||||||
|
|
||||||
static NTSTATUS FspFsctlFileSystemControl(
|
static NTSTATUS FspFsctlFileSystemControl(
|
||||||
PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
|
PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
@ -249,15 +262,10 @@ VOID FspFsctlDeleteVolume(
|
|||||||
/* performed during IRP_MJ_CLEANUP! */
|
/* performed during IRP_MJ_CLEANUP! */
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
FSP_FSCTL_FILE_CONTEXT2 *FsContext2 = IrpSp->FileObject->FsContext2;
|
PDEVICE_OBJECT FsvolDeviceObject;
|
||||||
PDEVICE_OBJECT FsvolDeviceObject = 0;
|
|
||||||
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension;
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension;
|
||||||
|
|
||||||
/*
|
FsvolDeviceObject = FspFsvolDeviceObjectFromFileObject(IrpSp->FileObject);
|
||||||
* Check to see if we have a volume. There is no need to protect this
|
|
||||||
* access in FsContext2->FastMutex, because we are called during IRP_MJ_CLEANUP.
|
|
||||||
*/
|
|
||||||
FsvolDeviceObject = FsContext2->FsvolDeviceObject;
|
|
||||||
if (0 == FsvolDeviceObject)
|
if (0 == FsvolDeviceObject)
|
||||||
return;
|
return;
|
||||||
FsvolDeviceExtension = FspFsvolDeviceExtension(FsvolDeviceObject);
|
FsvolDeviceExtension = FspFsvolDeviceExtension(FsvolDeviceObject);
|
||||||
@ -384,8 +392,7 @@ static NTSTATUS FspFsctlTransact(
|
|||||||
return STATUS_BUFFER_TOO_SMALL;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
|
|
||||||
NTSTATUS Result;
|
NTSTATUS Result;
|
||||||
FSP_FSCTL_FILE_CONTEXT2 *FsContext2;
|
PDEVICE_OBJECT FsvolDeviceObject;
|
||||||
PDEVICE_OBJECT FsvolDeviceObject = 0;
|
|
||||||
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension;
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension;
|
||||||
PVOID MdlBuffer;
|
PVOID MdlBuffer;
|
||||||
PUINT8 BufferEnd;
|
PUINT8 BufferEnd;
|
||||||
@ -394,25 +401,9 @@ static NTSTATUS FspFsctlTransact(
|
|||||||
PIRP ProcessIrp, PendingIrp;
|
PIRP ProcessIrp, PendingIrp;
|
||||||
LARGE_INTEGER Timeout;
|
LARGE_INTEGER Timeout;
|
||||||
|
|
||||||
Result = STATUS_SUCCESS;
|
FsvolDeviceObject = FspFsvolDeviceObjectFromFileObject(IrpSp->FileObject);
|
||||||
FsContext2 = IrpSp->FileObject->FsContext2;
|
|
||||||
ExAcquireFastMutex(&FsContext2->FastMutex);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
/* check to see if we already have a volume */
|
|
||||||
FsvolDeviceObject = FsContext2->FsvolDeviceObject;
|
|
||||||
if (0 == FsvolDeviceObject)
|
if (0 == FsvolDeviceObject)
|
||||||
Result = STATUS_ACCESS_DENIED;
|
return STATUS_ACCESS_DENIED;
|
||||||
|
|
||||||
/* no need to FspDeviceRetain our volume device, because it exists until IRP_MJ_CLEANUP */
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
ExReleaseFastMutex(&FsContext2->FastMutex);
|
|
||||||
}
|
|
||||||
if (!NT_SUCCESS(Result))
|
|
||||||
return Result;
|
|
||||||
|
|
||||||
FsvolDeviceExtension = FspFsvolDeviceExtension(FsvolDeviceObject);
|
FsvolDeviceExtension = FspFsvolDeviceExtension(FsvolDeviceObject);
|
||||||
|
|
||||||
/* process any user-mode file system responses */
|
/* process any user-mode file system responses */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user