mirror of
https://github.com/winfsp/winfsp.git
synced 2025-06-08 04:52:10 -05:00
Major refactoring: IRP_MJ_CREATE
This commit is contained in:
parent
983ba0bcc1
commit
78c5fdb6f2
@ -156,6 +156,7 @@
|
||||
<ClCompile Include="..\..\src\sys\driver.c" />
|
||||
<ClCompile Include="..\..\src\sys\ea.c" />
|
||||
<ClCompile Include="..\..\src\sys\fastio.c" />
|
||||
<ClCompile Include="..\..\src\sys\filectx.c" />
|
||||
<ClCompile Include="..\..\src\sys\fileinfo.c" />
|
||||
<ClCompile Include="..\..\src\sys\flush.c" />
|
||||
<ClCompile Include="..\..\src\sys\fsctl.c" />
|
||||
|
@ -83,6 +83,9 @@
|
||||
<ClCompile Include="..\..\src\sys\volume.c">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\sys\filectx.c">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\sys\driver.h">
|
||||
|
@ -476,10 +476,10 @@ typedef struct
|
||||
BOOLEAN DeletePending; /* FileDispositionInformation */
|
||||
BOOLEAN DeleteOnClose; /* FILE_DELETE_ON_CLOSE */
|
||||
FSP_DEVICE_GENERIC_TABLE_ELEMENT ElementStorage;
|
||||
PDEVICE_OBJECT FsvolDeviceObject;
|
||||
UINT64 UserContext;
|
||||
#endif
|
||||
/* read-only after creation */
|
||||
PDEVICE_OBJECT FsvolDeviceObject;
|
||||
UNICODE_STRING FileName;
|
||||
WCHAR FileNameBuf[];
|
||||
} FSP_FILE_CONTEXT;
|
||||
|
72
src/sys/filectx.c
Normal file
72
src/sys/filectx.c
Normal file
@ -0,0 +1,72 @@
|
||||
/**
|
||||
* @file sys/filectx.c
|
||||
*
|
||||
* @copyright 2015 Bill Zissimopoulos
|
||||
*/
|
||||
|
||||
#include <sys/driver.h>
|
||||
|
||||
NTSTATUS FspFileContextCreate(PDEVICE_OBJECT DeviceObject,
|
||||
ULONG ExtraSize, FSP_FILE_CONTEXT **PFsContext);
|
||||
VOID FspFileContextDelete(FSP_FILE_CONTEXT *Context);
|
||||
|
||||
#ifdef ALLOC_PRAGMA
|
||||
#pragma alloc_text(PAGE, FspFileContextCreate)
|
||||
#pragma alloc_text(PAGE, FspFileContextDelete)
|
||||
#endif
|
||||
|
||||
NTSTATUS FspFileContextCreate(PDEVICE_OBJECT DeviceObject,
|
||||
ULONG ExtraSize, FSP_FILE_CONTEXT **PFsContext)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
*PFsContext = 0;
|
||||
|
||||
FSP_FILE_CONTEXT_NONPAGED *NonPaged = FspAllocNonPaged(sizeof *NonPaged);
|
||||
if (0 == NonPaged)
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
||||
FSP_FILE_CONTEXT *FsContext = FspAlloc(sizeof *FsContext + ExtraSize);
|
||||
if (0 == FsContext)
|
||||
{
|
||||
FspFree(NonPaged);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
RtlZeroMemory(NonPaged, sizeof *NonPaged);
|
||||
ExInitializeResourceLite(&NonPaged->Resource);
|
||||
ExInitializeResourceLite(&NonPaged->PagingIoResource);
|
||||
ExInitializeFastMutex(&NonPaged->HeaderFastMutex);
|
||||
|
||||
RtlZeroMemory(FsContext, sizeof *FsContext + ExtraSize);
|
||||
FsContext->Header.NodeTypeCode = FspFileContextFileKind;
|
||||
FsContext->Header.NodeByteSize = sizeof *FsContext;
|
||||
FsContext->Header.IsFastIoPossible = FastIoIsQuestionable;
|
||||
FsContext->Header.Resource = &NonPaged->Resource;
|
||||
FsContext->Header.PagingIoResource = &NonPaged->PagingIoResource;
|
||||
FsRtlSetupAdvancedHeader(&FsContext->Header, &NonPaged->HeaderFastMutex);
|
||||
FsContext->NonPaged = NonPaged;
|
||||
FsContext->RefCount = 1;
|
||||
FsContext->FsvolDeviceObject = DeviceObject;
|
||||
FspDeviceRetain(FsContext->FsvolDeviceObject);
|
||||
RtlInitEmptyUnicodeString(&FsContext->FileName, FsContext->FileNameBuf, (USHORT)ExtraSize);
|
||||
|
||||
*PFsContext = FsContext;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
VOID FspFileContextDelete(FSP_FILE_CONTEXT *FsContext)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
FsRtlTeardownPerStreamContexts(&FsContext->Header);
|
||||
|
||||
FspDeviceRelease(FsContext->FsvolDeviceObject);
|
||||
|
||||
ExDeleteResourceLite(&FsContext->NonPaged->PagingIoResource);
|
||||
ExDeleteResourceLite(&FsContext->NonPaged->Resource);
|
||||
FspFree(FsContext->NonPaged);
|
||||
|
||||
FspFree(FsContext);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user