mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-23 00:43:00 -05:00
sys: IRP_MJ_CREATE: FILE_DELETE_ON_CLOSE
This commit is contained in:
parent
6c29a98e90
commit
6ea86a5e8a
@ -112,6 +112,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
UINT64 UserContext;
|
UINT64 UserContext;
|
||||||
UINT64 UserContext2;
|
UINT64 UserContext2;
|
||||||
|
UINT32 Delete:1; /* if set, the file or directory must be deleted */
|
||||||
} Cleanup;
|
} Cleanup;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
@ -195,6 +195,15 @@ static NTSTATUS FspFsvolCreate(
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* cannot FILE_DELETE_ON_CLOSE on the root directory */
|
||||||
|
if (sizeof(WCHAR) == RelatedFsContext->FileName.Length &&
|
||||||
|
0 == FileName.Length &&
|
||||||
|
FlagOn(CreateOptions, FILE_DELETE_ON_CLOSE))
|
||||||
|
{
|
||||||
|
Result = STATUS_CANNOT_DELETE;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
FSP_FILE_CONTEXT *RelatedFsContext = RelatedFileObject->FsContext;
|
FSP_FILE_CONTEXT *RelatedFsContext = RelatedFileObject->FsContext;
|
||||||
ASSERT(0 != RelatedFsContext);
|
ASSERT(0 != RelatedFsContext);
|
||||||
|
|
||||||
@ -230,6 +239,14 @@ static NTSTATUS FspFsvolCreate(
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* cannot FILE_DELETE_ON_CLOSE on the root directory */
|
||||||
|
if (sizeof(WCHAR) == FileName.Length) &&
|
||||||
|
FlagOn(CreateOptions, FILE_DELETE_ON_CLOSE))
|
||||||
|
{
|
||||||
|
Result = STATUS_CANNOT_DELETE;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
Result = FspFileContextCreate(
|
Result = FspFileContextCreate(
|
||||||
FileName.Length,
|
FileName.Length,
|
||||||
&FsContext);
|
&FsContext);
|
||||||
@ -483,7 +500,8 @@ VOID FspFsvolCreateComplete(
|
|||||||
FSP_RETURN(Result = STATUS_ACCESS_DENIED);
|
FSP_RETURN(Result = STATUS_ACCESS_DENIED);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (FlagOn(CreateOptions, FILE_DELETE_ON_CLOSE))
|
if (!FlagOn(ResponseFileAttributes, FILE_ATTRIBUTE_DIRECTORY) &&
|
||||||
|
FlagOn(CreateOptions, FILE_DELETE_ON_CLOSE))
|
||||||
{
|
{
|
||||||
FspFsvolCreateClose(Irp, Response);
|
FspFsvolCreateClose(Irp, Response);
|
||||||
FSP_RETURN(Result = STATUS_CANNOT_DELETE);
|
FSP_RETURN(Result = STATUS_CANNOT_DELETE);
|
||||||
@ -573,6 +591,8 @@ VOID FspFsvolCreateComplete(
|
|||||||
IoSetShareAccess(AccessState->PreviouslyGrantedAccess,
|
IoSetShareAccess(AccessState->PreviouslyGrantedAccess,
|
||||||
ShareAccess, FileObject, &FsContext->ShareAccess);
|
ShareAccess, FileObject, &FsContext->ShareAccess);
|
||||||
FspFileContextOpen(FsContext);
|
FspFileContextOpen(FsContext);
|
||||||
|
if (FlagOn(CreateOptions, FILE_DELETE_ON_CLOSE))
|
||||||
|
FsContext->DeleteOnClose = TRUE;
|
||||||
Result = STATUS_SUCCESS;
|
Result = STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -592,6 +612,8 @@ VOID FspFsvolCreateComplete(
|
|||||||
{
|
{
|
||||||
FspFileContextRetain(FsContext);
|
FspFileContextRetain(FsContext);
|
||||||
FspFileContextOpen(FsContext);
|
FspFileContextOpen(FsContext);
|
||||||
|
if (FlagOn(CreateOptions, FILE_DELETE_ON_CLOSE))
|
||||||
|
FsContext->DeleteOnClose = TRUE;
|
||||||
}
|
}
|
||||||
ExReleaseResourceLite(FsContext->Header.Resource);
|
ExReleaseResourceLite(FsContext->Header.Resource);
|
||||||
}
|
}
|
||||||
|
@ -388,7 +388,8 @@ typedef struct
|
|||||||
/* protected by Header.Resource */
|
/* protected by Header.Resource */
|
||||||
LONG OpenCount;
|
LONG OpenCount;
|
||||||
SHARE_ACCESS ShareAccess;
|
SHARE_ACCESS ShareAccess;
|
||||||
BOOLEAN DeletePending;
|
BOOLEAN DeletePending; /* FileDispositionInformation */
|
||||||
|
BOOLEAN DeleteOnClose; /* FILE_DELETE_ON_CLOSE */
|
||||||
/* read-only after creation */
|
/* read-only after creation */
|
||||||
FSP_DEVICE_GENERIC_TABLE_ELEMENT ElementStorage;
|
FSP_DEVICE_GENERIC_TABLE_ELEMENT ElementStorage;
|
||||||
UINT64 UserContext;
|
UINT64 UserContext;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user