mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-23 17:03:12 -05:00
sys: IRP_MJ_CREATE: allow simple volume opens
This commit is contained in:
parent
a6c81010b6
commit
43b8fc00f5
@ -48,6 +48,10 @@ static NTSTATUS FspFsvolCleanup(
|
|||||||
{
|
{
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
|
/* is this a valid FileObject? */
|
||||||
|
if (!FspFileContextIsValid(IrpSp->FileObject->FsContext))
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
|
||||||
NTSTATUS Result;
|
NTSTATUS Result;
|
||||||
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
||||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||||
@ -92,7 +96,8 @@ static NTSTATUS FspFsvolCleanup(
|
|||||||
|
|
||||||
PDEVICE_OBJECT FsvrtDeviceObject = FsvolDeviceExtension->FsvrtDeviceObject;
|
PDEVICE_OBJECT FsvrtDeviceObject = FsvolDeviceExtension->FsvrtDeviceObject;
|
||||||
if (!FspDeviceRetain(FsvrtDeviceObject))
|
if (!FspDeviceRetain(FsvrtDeviceObject))
|
||||||
return STATUS_CANCELLED;
|
/* IRP_MJ_CLEANUP cannot really fail :-\ */
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -48,6 +48,10 @@ static NTSTATUS FspFsvolClose(
|
|||||||
{
|
{
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
|
/* is this a valid FileObject? */
|
||||||
|
if (!FspFileContextIsValid(IrpSp->FileObject->FsContext))
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
|
||||||
NTSTATUS Result;
|
NTSTATUS Result;
|
||||||
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
||||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||||
@ -60,7 +64,8 @@ static NTSTATUS FspFsvolClose(
|
|||||||
|
|
||||||
PDEVICE_OBJECT FsvrtDeviceObject = FsvolDeviceExtension->FsvrtDeviceObject;
|
PDEVICE_OBJECT FsvrtDeviceObject = FsvolDeviceExtension->FsvrtDeviceObject;
|
||||||
if (!FspDeviceRetain(FsvrtDeviceObject))
|
if (!FspDeviceRetain(FsvrtDeviceObject))
|
||||||
return STATUS_CANCELLED;
|
/* IRP_MJ_CLOSE cannot really fail :-\ */
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -61,6 +61,15 @@ static NTSTATUS FspFsvolCreate(
|
|||||||
{
|
{
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
|
/* open the volume object? */
|
||||||
|
if (0 == IrpSp->FileObject->FileName.Length &&
|
||||||
|
(0 == IrpSp->FileObject->RelatedFileObject ||
|
||||||
|
0 == IrpSp->FileObject->RelatedFileObject->FsContext))
|
||||||
|
{
|
||||||
|
Irp->IoStatus.Information = FILE_OPENED;
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS Result;
|
NTSTATUS Result;
|
||||||
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
||||||
|
|
||||||
@ -95,13 +104,6 @@ static NTSTATUS FspFsvolCreate(
|
|||||||
FSP_FILE_CONTEXT *FsContext = 0;
|
FSP_FILE_CONTEXT *FsContext = 0;
|
||||||
FSP_FSCTL_TRANSACT_REQ *Request;
|
FSP_FSCTL_TRANSACT_REQ *Request;
|
||||||
|
|
||||||
/* cannot open the volume object */
|
|
||||||
if (0 == RelatedFileObject && 0 == FileName.Length)
|
|
||||||
{
|
|
||||||
Result = STATUS_ACCESS_DENIED;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* cannot open a paging file */
|
/* cannot open a paging file */
|
||||||
if (FlagOn(Flags, SL_OPEN_PAGING_FILE))
|
if (FlagOn(Flags, SL_OPEN_PAGING_FILE))
|
||||||
{
|
{
|
||||||
@ -195,6 +197,15 @@ static NTSTATUS FspFsvolCreate(
|
|||||||
/* is this a relative or absolute open? */
|
/* is this a relative or absolute open? */
|
||||||
if (0 != RelatedFileObject)
|
if (0 != RelatedFileObject)
|
||||||
{
|
{
|
||||||
|
FSP_FILE_CONTEXT *RelatedFsContext = RelatedFileObject->FsContext;
|
||||||
|
|
||||||
|
/* is this a valid RelatedFileObject? */
|
||||||
|
if (!FspFileContextIsValid(RelatedFsContext))
|
||||||
|
{
|
||||||
|
Result = STATUS_OBJECT_PATH_NOT_FOUND;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
/* must be a relative path */
|
/* must be a relative path */
|
||||||
if (sizeof(WCHAR) <= FileName.Length && L'\\' == FileName.Buffer[0])
|
if (sizeof(WCHAR) <= FileName.Length && L'\\' == FileName.Buffer[0])
|
||||||
{
|
{
|
||||||
@ -202,9 +213,6 @@ static NTSTATUS FspFsvolCreate(
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
FSP_FILE_CONTEXT *RelatedFsContext = RelatedFileObject->FsContext;
|
|
||||||
ASSERT(0 != RelatedFsContext);
|
|
||||||
|
|
||||||
/* cannot FILE_DELETE_ON_CLOSE on the root directory */
|
/* cannot FILE_DELETE_ON_CLOSE on the root directory */
|
||||||
if (sizeof(WCHAR) == RelatedFsContext->FileName.Length &&
|
if (sizeof(WCHAR) == RelatedFsContext->FileName.Length &&
|
||||||
0 == FileName.Length &&
|
0 == FileName.Length &&
|
||||||
@ -605,11 +613,6 @@ VOID FspFsvolCreateComplete(
|
|||||||
* Looks like SUCCESS!
|
* Looks like SUCCESS!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* record the user-mode file system contexts */
|
|
||||||
FsContext->UserContext = Response->Rsp.Create.Opened.UserContext;
|
|
||||||
FileObject->FsContext = FsContext;
|
|
||||||
FileObject->FsContext2 = (PVOID)(UINT_PTR)Response->Rsp.Create.Opened.UserContext2;
|
|
||||||
|
|
||||||
/* did 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 as it is not being used */
|
/* delete the newly created FsContext as it is not being used */
|
||||||
@ -618,6 +621,11 @@ VOID FspFsvolCreateComplete(
|
|||||||
/* disassociate our FsContext from the Request */
|
/* disassociate our FsContext from the Request */
|
||||||
FspIopRequestContext(Request, RequestFsContext) = 0;
|
FspIopRequestContext(Request, RequestFsContext) = 0;
|
||||||
|
|
||||||
|
/* record the user-mode file system contexts */
|
||||||
|
FsContext->UserContext = Response->Rsp.Create.Opened.UserContext;
|
||||||
|
FileObject->FsContext = FsContext;
|
||||||
|
FileObject->FsContext2 = (PVOID)(UINT_PTR)Response->Rsp.Create.Opened.UserContext2;
|
||||||
|
|
||||||
/* finish seting up the FileObject */
|
/* finish seting up the FileObject */
|
||||||
FileObject->Vpb = FsvrtDeviceObject->Vpb;
|
FileObject->Vpb = FsvrtDeviceObject->Vpb;
|
||||||
|
|
||||||
|
@ -379,6 +379,14 @@ VOID FspDeviceDeleteList(
|
|||||||
VOID FspDeviceDeleteAll(VOID);
|
VOID FspDeviceDeleteAll(VOID);
|
||||||
|
|
||||||
/* file objects */
|
/* file objects */
|
||||||
|
#define FspFileContextKind(FsContext) \
|
||||||
|
(((FSP_FILE_CONTEXT *)FsContext)->Header.NodeTypeCode)
|
||||||
|
#define FspFileContextIsValid(FsContext)\
|
||||||
|
(0 != (FsContext) && FspFileContextFileKind == ((FSP_FILE_CONTEXT *)FsContext)->Header.NodeTypeCode)
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
FspFileContextFileKind = 'BZ',
|
||||||
|
};
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
ERESOURCE Resource;
|
ERESOURCE Resource;
|
||||||
|
@ -39,7 +39,7 @@ NTSTATUS FspFileContextCreate(PDEVICE_OBJECT DeviceObject,
|
|||||||
ExInitializeFastMutex(&NonPaged->HeaderFastMutex);
|
ExInitializeFastMutex(&NonPaged->HeaderFastMutex);
|
||||||
|
|
||||||
RtlZeroMemory(FsContext, sizeof *FsContext + ExtraSize);
|
RtlZeroMemory(FsContext, sizeof *FsContext + ExtraSize);
|
||||||
FsContext->Header.NodeTypeCode = 'F';
|
FsContext->Header.NodeTypeCode = FspFileContextFileKind;
|
||||||
FsContext->Header.NodeByteSize = sizeof *FsContext;
|
FsContext->Header.NodeByteSize = sizeof *FsContext;
|
||||||
FsContext->Header.IsFastIoPossible = FastIoIsQuestionable;
|
FsContext->Header.IsFastIoPossible = FastIoIsQuestionable;
|
||||||
FsContext->Header.Resource = &NonPaged->Resource;
|
FsContext->Header.Resource = &NonPaged->Resource;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user