From 106b3ab0c75dc590a24a12d00f2603b71ed95a56 Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Mon, 7 Dec 2015 22:59:08 -0800 Subject: [PATCH] sys: IRP_MJ_CREATE --- inc/winfsp/fsctl.h | 2 +- src/sys/create.c | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/inc/winfsp/fsctl.h b/inc/winfsp/fsctl.h index f24da056..56c83ed9 100644 --- a/inc/winfsp/fsctl.h +++ b/inc/winfsp/fsctl.h @@ -49,7 +49,7 @@ enum { FspFsctlTransactUnknownKind = 0, FspFsctlTransactCreateKind = 'C', - FspFsctlTransactCreateCloseKind = 'c', + FspFsctlTransactCreateCleanupCloseKind = 'c', FspFsctlTransactCloseKind = 'z', FspFsctlTransactReadKind = 'R', FspFsctlTransactWriteKind = 'W', diff --git a/src/sys/create.c b/src/sys/create.c index 4bdffadb..99276ef1 100644 --- a/src/sys/create.c +++ b/src/sys/create.c @@ -195,6 +195,9 @@ static NTSTATUS FspFsvolCreate( goto exit; } + FSP_FILE_CONTEXT *RelatedFsContext = RelatedFileObject->FsContext; + ASSERT(0 != RelatedFsContext); + /* cannot FILE_DELETE_ON_CLOSE on the root directory */ if (sizeof(WCHAR) == RelatedFsContext->FileName.Length && 0 == FileName.Length && @@ -204,9 +207,6 @@ static NTSTATUS FspFsvolCreate( goto exit; } - FSP_FILE_CONTEXT *RelatedFsContext = RelatedFileObject->FsContext; - ASSERT(0 != RelatedFsContext); - /* * There is no need to lock our accesses of RelatedFileObject->FsContext->FileName, * because RelatedFileObject->FsContext->Filename is read-only (after creation) and @@ -240,7 +240,7 @@ static NTSTATUS FspFsvolCreate( } /* cannot FILE_DELETE_ON_CLOSE on the root directory */ - if (sizeof(WCHAR) == FileName.Length) && + if (sizeof(WCHAR) == FileName.Length && FlagOn(CreateOptions, FILE_DELETE_ON_CLOSE)) { Result = STATUS_CANNOT_DELETE; @@ -689,9 +689,10 @@ static VOID FspFsvolCreateClose( goto leak_exit; /* populate the CreateClose request */ - Request->Kind = FspFsctlTransactCreateCloseKind; - Request->Req.Close.UserContext = FsContext->UserContext; - Request->Req.Close.UserContext2 = (UINT_PTR)FileObject->FsContext2; + Request->Kind = FspFsctlTransactCreateCleanupCloseKind; + Request->Req.Cleanup.UserContext = FsContext->UserContext; + Request->Req.Cleanup.UserContext2 = (UINT_PTR)FileObject->FsContext2; + Request->Req.Cleanup.Delete = FILE_CREATED == Response->IoStatus.Information; /* post as a work request */ if (!FspIopPostWorkRequest(DeviceObject, Request))