mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 16:33:02 -05:00
sys: IRP_MJ_CREATE
This commit is contained in:
parent
0e170901c8
commit
0d49e87468
@ -4,6 +4,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
VisualStudioVersion = 14.0.23107.0
|
VisualStudioVersion = 14.0.23107.0
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "winfsp.dll", "winfsp_dll.vcxproj", "{4A7C0B21-9E10-4C81-92DE-1493EFCF24EB}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "winfsp.dll", "winfsp_dll.vcxproj", "{4A7C0B21-9E10-4C81-92DE-1493EFCF24EB}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{C85C26BA-8C22-4D30-83DA-46C3548E6332} = {C85C26BA-8C22-4D30-83DA-46C3548E6332}
|
||||||
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "winfsp.sys", "winfsp_sys.vcxproj", "{C85C26BA-8C22-4D30-83DA-46C3548E6332}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "winfsp.sys", "winfsp_sys.vcxproj", "{C85C26BA-8C22-4D30-83DA-46C3548E6332}"
|
||||||
EndProject
|
EndProject
|
||||||
|
@ -403,7 +403,7 @@ VOID FspFsvolCreateComplete(
|
|||||||
FsContext->UserContext = Response->Rsp.Create.UserContext;
|
FsContext->UserContext = Response->Rsp.Create.UserContext;
|
||||||
FileObject->FsContext2 = (PVOID)(UINT_PTR)Response->Rsp.Create.UserContext2;
|
FileObject->FsContext2 = (PVOID)(UINT_PTR)Response->Rsp.Create.UserContext2;
|
||||||
|
|
||||||
/* following must be performed under the fsvol lock */
|
/* lock the file system volume device while accessing its generic table */
|
||||||
ExAcquireResourceExclusiveLite(&FsvolDeviceExtension->Base.Resource, TRUE);
|
ExAcquireResourceExclusiveLite(&FsvolDeviceExtension->Base.Resource, TRUE);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -415,19 +415,34 @@ VOID FspFsvolCreateComplete(
|
|||||||
Result = STATUS_INSUFFICIENT_RESOURCES;
|
Result = STATUS_INSUFFICIENT_RESOURCES;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* do the share access checks */
|
/* share access check */
|
||||||
if (Inserted)
|
if (Inserted)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* This is a newly created FsContext. Set its share access and
|
||||||
|
* increment its open count. There is no need to acquire the
|
||||||
|
* FsContext's Resource (because it is newly created).
|
||||||
|
*/
|
||||||
IoSetShareAccess(DesiredAccess, ShareAccess, FileObject,
|
IoSetShareAccess(DesiredAccess, ShareAccess, FileObject,
|
||||||
&FsContext->ShareAccess);
|
&FsContext->ShareAccess);
|
||||||
FspFileContextOpen(FsContext);
|
FspFileContextOpen(FsContext);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* This is an existing FsContext. We must acquire its Resource and
|
||||||
|
* check if there is a delete pending and the share access. Only if
|
||||||
|
* both tests succeed we increment the open count and report success.
|
||||||
|
*/
|
||||||
|
ExAcquireResourceExclusiveLite(FsContext->Header.Resource, TRUE);
|
||||||
|
if (FsContext->DeletePending)
|
||||||
|
Result = STATUS_DELETE_PENDING;
|
||||||
|
else
|
||||||
Result = IoCheckShareAccess(DesiredAccess, ShareAccess, FileObject,
|
Result = IoCheckShareAccess(DesiredAccess, ShareAccess, FileObject,
|
||||||
&FsContext->ShareAccess, TRUE);
|
&FsContext->ShareAccess, TRUE);
|
||||||
if (NT_SUCCESS(Result))
|
if (NT_SUCCESS(Result))
|
||||||
FspFileContextOpen(FsContext);
|
FspFileContextOpen(FsContext);
|
||||||
|
ExReleaseResourceLite(FsContext->Header.Resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -444,9 +459,10 @@ VOID FspFsvolCreateComplete(
|
|||||||
FSP_RETURN();
|
FSP_RETURN();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* does an FsContext with the same UserContext already exist? */
|
/* did an FsContext with the same UserContext already exist? */
|
||||||
if (!Inserted)
|
if (!Inserted)
|
||||||
{
|
{
|
||||||
|
/* delete the newly created FsContext and use the existing one */
|
||||||
FspFileContextDelete(FileObject->FsContext);
|
FspFileContextDelete(FileObject->FsContext);
|
||||||
FileObject->FsContext = FsContext;
|
FileObject->FsContext = FsContext;
|
||||||
}
|
}
|
||||||
|
@ -363,9 +363,13 @@ typedef struct
|
|||||||
{
|
{
|
||||||
FSRTL_ADVANCED_FCB_HEADER Header;
|
FSRTL_ADVANCED_FCB_HEADER Header;
|
||||||
FSP_FILE_CONTEXT_NONPAGED *NonPaged;
|
FSP_FILE_CONTEXT_NONPAGED *NonPaged;
|
||||||
|
/* interlocked access */
|
||||||
|
LONG RefCount;
|
||||||
|
/* protected by Header.Resource */
|
||||||
LONG OpenCount;
|
LONG OpenCount;
|
||||||
SHARE_ACCESS ShareAccess;
|
SHARE_ACCESS ShareAccess;
|
||||||
/* protected by containing fsvol lock */
|
BOOLEAN DeletePending;
|
||||||
|
/* read-only after creation */
|
||||||
UINT64 UserContext;
|
UINT64 UserContext;
|
||||||
UNICODE_STRING FileName;
|
UNICODE_STRING FileName;
|
||||||
WCHAR FileNameBuf[];
|
WCHAR FileNameBuf[];
|
||||||
@ -375,13 +379,26 @@ VOID FspFileContextDelete(FSP_FILE_CONTEXT *Context);
|
|||||||
static inline
|
static inline
|
||||||
VOID FspFileContextOpen(FSP_FILE_CONTEXT *Context)
|
VOID FspFileContextOpen(FSP_FILE_CONTEXT *Context)
|
||||||
{
|
{
|
||||||
InterlockedIncrement(&Context->OpenCount);
|
ASSERT(0 == Context->OpenCount || ExIsResourceAcquiredExclusiveLite(Context->Header.Resource));
|
||||||
|
Context->OpenCount++;
|
||||||
}
|
}
|
||||||
static inline
|
static inline
|
||||||
VOID FspFileContextClose(FSP_FILE_CONTEXT *Context)
|
VOID FspFileContextClose(FSP_FILE_CONTEXT *Context)
|
||||||
{
|
{
|
||||||
LONG Result = InterlockedDecrement(&Context->OpenCount);
|
ASSERT(ExIsResourceAcquiredExclusiveLite(Context->Header.Resource));
|
||||||
if (0 == Result)
|
ASSERT(0 < Context->OpenCount);
|
||||||
|
Context->OpenCount--;
|
||||||
|
}
|
||||||
|
static inline
|
||||||
|
VOID FspFileContextRetain(FSP_FILE_CONTEXT *Context)
|
||||||
|
{
|
||||||
|
InterlockedIncrement(&Context->RefCount);
|
||||||
|
}
|
||||||
|
static inline
|
||||||
|
VOID FspFileContextRelease(FSP_FILE_CONTEXT *Context)
|
||||||
|
{
|
||||||
|
LONG RefCount = InterlockedDecrement(&Context->RefCount);
|
||||||
|
if (0 == RefCount)
|
||||||
FspFileContextDelete(Context);
|
FspFileContextDelete(Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ NTSTATUS FspFileContextCreate(ULONG ExtraSize, FSP_FILE_CONTEXT **PFsContext)
|
|||||||
FsContext->Header.PagingIoResource = &NonPaged->PagingIoResource;
|
FsContext->Header.PagingIoResource = &NonPaged->PagingIoResource;
|
||||||
FsRtlSetupAdvancedHeader(&FsContext->Header, &NonPaged->HeaderFastMutex);
|
FsRtlSetupAdvancedHeader(&FsContext->Header, &NonPaged->HeaderFastMutex);
|
||||||
FsContext->NonPaged = NonPaged;
|
FsContext->NonPaged = NonPaged;
|
||||||
|
FsContext->RefCount = 1;
|
||||||
RtlInitEmptyUnicodeString(&FsContext->FileName, FsContext->FileNameBuf, (USHORT)ExtraSize);
|
RtlInitEmptyUnicodeString(&FsContext->FileName, FsContext->FileNameBuf, (USHORT)ExtraSize);
|
||||||
|
|
||||||
*PFsContext = FsContext;
|
*PFsContext = FsContext;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user