mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-25 01:42:24 -05:00
sys: IRP_MJ_CREATE
This commit is contained in:
parent
a382db8b01
commit
8c7f790805
@ -86,6 +86,7 @@ static NTSTATUS FspFsvolCreate(
|
|||||||
if ((0 == RelatedFileObject || RelatedFileObject->FsContext) && 0 == FileName.Length)
|
if ((0 == RelatedFileObject || RelatedFileObject->FsContext) && 0 == FileName.Length)
|
||||||
{
|
{
|
||||||
if (0 != FsvolDeviceExtension->FsvrtDeviceObject)
|
if (0 != FsvolDeviceExtension->FsvrtDeviceObject)
|
||||||
|
#pragma prefast(disable:28175, "We are a filesystem: ok to access Vpb")
|
||||||
FileObject->Vpb = FsvolDeviceExtension->FsvrtDeviceObject->Vpb;
|
FileObject->Vpb = FsvolDeviceExtension->FsvrtDeviceObject->Vpb;
|
||||||
|
|
||||||
Irp->IoStatus.Information = FILE_OPENED;
|
Irp->IoStatus.Information = FILE_OPENED;
|
||||||
@ -242,7 +243,7 @@ static NTSTATUS FspFsvolCreate(
|
|||||||
FspFsvolCreateRequestFini, &Request);
|
FspFsvolCreateRequestFini, &Request);
|
||||||
if (!NT_SUCCESS(Result))
|
if (!NT_SUCCESS(Result))
|
||||||
{
|
{
|
||||||
FspFileContextDelete(FsContext);
|
FspFileContextRelease(FsContext);
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,6 +375,7 @@ VOID FspFsvolCreateComplete(
|
|||||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||||
FSP_FSCTL_TRANSACT_REQ *Request = FspIrpRequest(Irp);
|
FSP_FSCTL_TRANSACT_REQ *Request = FspIrpRequest(Irp);
|
||||||
FSP_FILE_CONTEXT *FsContext = FspIopRequestContext(Request, RequestFsContext);
|
FSP_FILE_CONTEXT *FsContext = FspIopRequestContext(Request, RequestFsContext);
|
||||||
|
FSP_FILE_CONTEXT *OpenedFsContext;
|
||||||
UNICODE_STRING ReparseFileName;
|
UNICODE_STRING ReparseFileName;
|
||||||
BOOLEAN DeleteOnClose;
|
BOOLEAN DeleteOnClose;
|
||||||
|
|
||||||
@ -451,6 +453,7 @@ VOID FspFsvolCreateComplete(
|
|||||||
|
|
||||||
/* set up the FileObject */
|
/* set up the FileObject */
|
||||||
if (0 != FsvolDeviceExtension->FsvrtDeviceObject)
|
if (0 != FsvolDeviceExtension->FsvrtDeviceObject)
|
||||||
|
#pragma prefast(disable:28175, "We are a filesystem: ok to access Vpb")
|
||||||
FileObject->Vpb = FsvolDeviceExtension->FsvrtDeviceObject->Vpb;
|
FileObject->Vpb = FsvolDeviceExtension->FsvrtDeviceObject->Vpb;
|
||||||
FileObject->SectionObjectPointer = &FsContext->NonPaged->SectionObjectPointers;
|
FileObject->SectionObjectPointer = &FsContext->NonPaged->SectionObjectPointers;
|
||||||
FileObject->PrivateCacheMap = 0;
|
FileObject->PrivateCacheMap = 0;
|
||||||
@ -460,11 +463,10 @@ VOID FspFsvolCreateComplete(
|
|||||||
DeleteOnClose = BooleanFlagOn(Request->Req.Create.CreateOptions, FILE_DELETE_ON_CLOSE);
|
DeleteOnClose = BooleanFlagOn(Request->Req.Create.CreateOptions, FILE_DELETE_ON_CLOSE);
|
||||||
|
|
||||||
/* open the FsContext */
|
/* open the FsContext */
|
||||||
FsContext = FspFileContextOpen(FsContext, FileObject,
|
OpenedFsContext = FspFileContextOpen(FsContext, FileObject,
|
||||||
Response->Rsp.Create.Opened.GrantedAccess, IrpSp->Parameters.Create.ShareAccess,
|
Response->Rsp.Create.Opened.GrantedAccess, IrpSp->Parameters.Create.ShareAccess,
|
||||||
&Result);
|
&Result);
|
||||||
FspIopRequestContext(Request, RequestFsContext) = FsContext;
|
if (0 == OpenedFsContext)
|
||||||
if (0 == FsContext)
|
|
||||||
{
|
{
|
||||||
/* unable to open the FsContext; post a close Create2 request */
|
/* unable to open the FsContext; post a close Create2 request */
|
||||||
FspFsvolCreatePostClose(FsvolDeviceObject,
|
FspFsvolCreatePostClose(FsvolDeviceObject,
|
||||||
@ -473,9 +475,16 @@ VOID FspFsvolCreateComplete(
|
|||||||
Response->Rsp.Create.Opened.UserContext2,
|
Response->Rsp.Create.Opened.UserContext2,
|
||||||
Result);
|
Result);
|
||||||
|
|
||||||
|
FspFileContextRelease(FsContext);
|
||||||
|
|
||||||
FSP_RETURN();
|
FSP_RETURN();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (OpenedFsContext != FsContext)
|
||||||
|
FspFileContextRelease(FsContext);
|
||||||
|
|
||||||
|
FspIopRequestContext(Request, RequestFsContext) = FsContext = OpenedFsContext;
|
||||||
|
|
||||||
if (FILE_OPENED == Response->IoStatus.Information)
|
if (FILE_OPENED == Response->IoStatus.Information)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -25,11 +25,7 @@ static NTSTATUS FspFsvolDeviceInit(PDEVICE_OBJECT DeviceObject);
|
|||||||
static VOID FspFsvolDeviceFini(PDEVICE_OBJECT DeviceObject);
|
static VOID FspFsvolDeviceFini(PDEVICE_OBJECT DeviceObject);
|
||||||
static IO_TIMER_ROUTINE FspFsvolDeviceTimerRoutine;
|
static IO_TIMER_ROUTINE FspFsvolDeviceTimerRoutine;
|
||||||
static WORKER_THREAD_ROUTINE FspFsvolDeviceExpirationRoutine;
|
static WORKER_THREAD_ROUTINE FspFsvolDeviceExpirationRoutine;
|
||||||
_IRQL_raises_(APC_LEVEL)
|
|
||||||
_IRQL_saves_global_(OldIrql, DeviceObject)
|
|
||||||
VOID FspFsvolDeviceLockContextTable(PDEVICE_OBJECT DeviceObject);
|
VOID FspFsvolDeviceLockContextTable(PDEVICE_OBJECT DeviceObject);
|
||||||
_IRQL_requires_(APC_LEVEL)
|
|
||||||
_IRQL_restores_global_(OldIrql, DeviceObject)
|
|
||||||
VOID FspFsvolDeviceUnlockContextTable(PDEVICE_OBJECT DeviceObject);
|
VOID FspFsvolDeviceUnlockContextTable(PDEVICE_OBJECT DeviceObject);
|
||||||
PVOID FspFsvolDeviceLookupContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier);
|
PVOID FspFsvolDeviceLookupContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier);
|
||||||
PVOID FspFsvolDeviceInsertContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier, PVOID Context,
|
PVOID FspFsvolDeviceInsertContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier, PVOID Context,
|
||||||
@ -295,7 +291,7 @@ static NTSTATUS FspFsvolDeviceInit(PDEVICE_OBJECT DeviceObject)
|
|||||||
FsvolDeviceExtension->InitDoneIoq = 1;
|
FsvolDeviceExtension->InitDoneIoq = 1;
|
||||||
|
|
||||||
/* initialize our generic table */
|
/* initialize our generic table */
|
||||||
ExInitializeFastMutex(&FsvolDeviceExtension->GenericTableFastMutex);
|
KeInitializeGuardedMutex(&FsvolDeviceExtension->GenericTableMutex);
|
||||||
RtlInitializeGenericTableAvl(&FsvolDeviceExtension->GenericTable,
|
RtlInitializeGenericTableAvl(&FsvolDeviceExtension->GenericTable,
|
||||||
FspFsvolDeviceCompareElement, FspFsvolDeviceAllocateElement, FspFsvolDeviceFreeElement, 0);
|
FspFsvolDeviceCompareElement, FspFsvolDeviceAllocateElement, FspFsvolDeviceFreeElement, 0);
|
||||||
FsvolDeviceExtension->InitDoneGenTab = 1;
|
FsvolDeviceExtension->InitDoneGenTab = 1;
|
||||||
@ -412,24 +408,20 @@ static VOID FspFsvolDeviceExpirationRoutine(PVOID Context)
|
|||||||
FspDeviceRelease(DeviceObject);
|
FspDeviceRelease(DeviceObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
_IRQL_raises_(APC_LEVEL)
|
|
||||||
_IRQL_saves_global_(OldIrql, DeviceObject)
|
|
||||||
VOID FspFsvolDeviceLockContextTable(PDEVICE_OBJECT DeviceObject)
|
VOID FspFsvolDeviceLockContextTable(PDEVICE_OBJECT DeviceObject)
|
||||||
{
|
{
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
||||||
ExAcquireFastMutex(&FsvolDeviceExtension->GenericTableFastMutex);
|
KeAcquireGuardedMutex(&FsvolDeviceExtension->GenericTableMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
_IRQL_requires_(APC_LEVEL)
|
|
||||||
_IRQL_restores_global_(OldIrql, DeviceObject)
|
|
||||||
VOID FspFsvolDeviceUnlockContextTable(PDEVICE_OBJECT DeviceObject)
|
VOID FspFsvolDeviceUnlockContextTable(PDEVICE_OBJECT DeviceObject)
|
||||||
{
|
{
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
||||||
ExReleaseFastMutex(&FsvolDeviceExtension->GenericTableFastMutex);
|
KeReleaseGuardedMutex(&FsvolDeviceExtension->GenericTableMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
PVOID FspFsvolDeviceLookupContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier)
|
PVOID FspFsvolDeviceLookupContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier)
|
||||||
|
@ -433,7 +433,7 @@ typedef struct
|
|||||||
KSPIN_LOCK ExpirationLock;
|
KSPIN_LOCK ExpirationLock;
|
||||||
WORK_QUEUE_ITEM ExpirationWorkItem;
|
WORK_QUEUE_ITEM ExpirationWorkItem;
|
||||||
BOOLEAN ExpirationInProgress;
|
BOOLEAN ExpirationInProgress;
|
||||||
FAST_MUTEX GenericTableFastMutex;
|
KGUARDED_MUTEX GenericTableMutex;
|
||||||
RTL_AVL_TABLE GenericTable;
|
RTL_AVL_TABLE GenericTable;
|
||||||
PVOID GenericTableElementStorage;
|
PVOID GenericTableElementStorage;
|
||||||
UNICODE_STRING VolumeName;
|
UNICODE_STRING VolumeName;
|
||||||
@ -461,11 +461,7 @@ NTSTATUS FspDeviceInitialize(PDEVICE_OBJECT DeviceObject);
|
|||||||
VOID FspDeviceDelete(PDEVICE_OBJECT DeviceObject);
|
VOID FspDeviceDelete(PDEVICE_OBJECT DeviceObject);
|
||||||
BOOLEAN FspDeviceRetain(PDEVICE_OBJECT DeviceObject);
|
BOOLEAN FspDeviceRetain(PDEVICE_OBJECT DeviceObject);
|
||||||
VOID FspDeviceRelease(PDEVICE_OBJECT DeviceObject);
|
VOID FspDeviceRelease(PDEVICE_OBJECT DeviceObject);
|
||||||
_IRQL_raises_(APC_LEVEL)
|
|
||||||
_IRQL_saves_global_(OldIrql, DeviceObject)
|
|
||||||
VOID FspFsvolDeviceLockContextTable(PDEVICE_OBJECT DeviceObject);
|
VOID FspFsvolDeviceLockContextTable(PDEVICE_OBJECT DeviceObject);
|
||||||
_IRQL_requires_(APC_LEVEL)
|
|
||||||
_IRQL_restores_global_(OldIrql, DeviceObject)
|
|
||||||
VOID FspFsvolDeviceUnlockContextTable(PDEVICE_OBJECT DeviceObject);
|
VOID FspFsvolDeviceUnlockContextTable(PDEVICE_OBJECT DeviceObject);
|
||||||
PVOID FspFsvolDeviceLookupContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier);
|
PVOID FspFsvolDeviceLookupContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier);
|
||||||
PVOID FspFsvolDeviceInsertContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier, PVOID Context,
|
PVOID FspFsvolDeviceInsertContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier, PVOID Context,
|
||||||
|
@ -112,7 +112,7 @@ FSP_FILE_CONTEXT *FspFileContextOpen(FSP_FILE_CONTEXT *FsContext, PFILE_OBJECT F
|
|||||||
* opening a prior FsContext that we found in the table.
|
* opening a prior FsContext that we found in the table.
|
||||||
*
|
*
|
||||||
* First check and update the share access. If successful then retain the
|
* First check and update the share access. If successful then retain the
|
||||||
* prior FsContext for our caller and release the original FsContext.
|
* prior FsContext for our caller.
|
||||||
*/
|
*/
|
||||||
ASSERT(OpenedFsContext != FsContext);
|
ASSERT(OpenedFsContext != FsContext);
|
||||||
|
|
||||||
@ -150,9 +150,6 @@ FSP_FILE_CONTEXT *FspFileContextOpen(FSP_FILE_CONTEXT *FsContext, PFILE_OBJECT F
|
|||||||
|
|
||||||
FspFsvolDeviceUnlockContextTable(FsvolDeviceObject);
|
FspFsvolDeviceUnlockContextTable(FsvolDeviceObject);
|
||||||
|
|
||||||
if (!Inserted)
|
|
||||||
FspFileContextRelease(FsContext);
|
|
||||||
|
|
||||||
return OpenedFsContext;
|
return OpenedFsContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user