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
8c3f912e05
commit
6bfb23e77d
@ -50,9 +50,14 @@ static NTSTATUS FspFsvolCreate(
|
||||
|
||||
NTSTATUS Result;
|
||||
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
||||
FSP_FSVRT_DEVICE_EXTENSION *FsvrtDeviceExtension =
|
||||
FspFsvrtDeviceExtension(FsvolDeviceExtension->FsvrtDeviceObject);
|
||||
PDEVICE_OBJECT FsvrtDeviceObject = FsvolDeviceExtension->FsvrtDeviceObject;
|
||||
|
||||
if (!FspDeviceRetain(FsvrtDeviceObject))
|
||||
return STATUS_CANCELLED;
|
||||
try
|
||||
{
|
||||
FSP_FSVRT_DEVICE_EXTENSION *FsvrtDeviceExtension =
|
||||
FspFsvrtDeviceExtension(FsvrtDeviceObject);
|
||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||
PFILE_OBJECT RelatedFileObject = FileObject->RelatedFileObject;
|
||||
UNICODE_STRING FileName = FileObject->FileName;
|
||||
@ -69,8 +74,10 @@ static NTSTATUS FspFsvolCreate(
|
||||
PFILE_FULL_EA_INFORMATION EaBuffer = Irp->AssociatedIrp.SystemBuffer;
|
||||
//ULONG EaLength = IrpSp->Parameters.Create.EaLength;
|
||||
ULONG Flags = IrpSp->Flags;
|
||||
KPROCESSOR_MODE RequestorMode = FlagOn(Flags, SL_FORCE_ACCESS_CHECK) ? UserMode : Irp->RequestorMode;
|
||||
BOOLEAN HasTraversePrivilege = BooleanFlagOn(AccessState->Flags, TOKEN_HAS_TRAVERSE_PRIVILEGE);
|
||||
KPROCESSOR_MODE RequestorMode =
|
||||
FlagOn(Flags, SL_FORCE_ACCESS_CHECK) ? UserMode : Irp->RequestorMode;
|
||||
BOOLEAN HasTraversePrivilege =
|
||||
BooleanFlagOn(AccessState->Flags, TOKEN_HAS_TRAVERSE_PRIVILEGE);
|
||||
BOOLEAN IsAbsoluteSecurityDescriptor = FALSE;
|
||||
BOOLEAN IsSelfRelativeSecurityDescriptor = FALSE;
|
||||
BOOLEAN HasTrailingBackslash = FALSE;
|
||||
@ -79,19 +86,31 @@ static NTSTATUS FspFsvolCreate(
|
||||
|
||||
/* cannot open the volume object */
|
||||
if (0 == RelatedFileObject && 0 == FileName.Length)
|
||||
return STATUS_ACCESS_DENIED; /* need error code like POSIX EPERM (STATUS_NOT_SUPPORTED?) */
|
||||
{
|
||||
Result = STATUS_ACCESS_DENIED; /* need error code like POSIX EPERM (STATUS_NOT_SUPPORTED?) */
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* cannot open a paging file */
|
||||
if (FlagOn(Flags, SL_OPEN_PAGING_FILE))
|
||||
return STATUS_ACCESS_DENIED;
|
||||
{
|
||||
Result = STATUS_ACCESS_DENIED;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* cannot open files by fileid */
|
||||
if (FlagOn(CreateOptions, FILE_OPEN_BY_FILE_ID))
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
{
|
||||
Result = STATUS_NOT_IMPLEMENTED;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* do we support EA? */
|
||||
if (0 != EaBuffer && !FsvrtDeviceExtension->VolumeParams.EaSupported)
|
||||
return STATUS_EAS_NOT_SUPPORTED;
|
||||
{
|
||||
Result = STATUS_EAS_NOT_SUPPORTED;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* check security descriptor validity */
|
||||
if (0 != SecurityDescriptor)
|
||||
@ -101,7 +120,10 @@ static NTSTATUS FspFsvolCreate(
|
||||
{
|
||||
Result = RtlAbsoluteToSelfRelativeSD(SecurityDescriptor, 0, &SecurityDescriptorSize);
|
||||
if (STATUS_BUFFER_TOO_SMALL != Result)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
{
|
||||
Result = STATUS_INVALID_PARAMETER;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -109,7 +131,10 @@ static NTSTATUS FspFsvolCreate(
|
||||
IsSelfRelativeSecurityDescriptor = RtlValidRelativeSecurityDescriptor(
|
||||
SecurityDescriptor, SecurityDescriptorSize, 0);
|
||||
if (!IsSelfRelativeSecurityDescriptor)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
{
|
||||
Result = STATUS_INVALID_PARAMETER;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,7 +148,10 @@ static NTSTATUS FspFsvolCreate(
|
||||
|
||||
if (sizeof(WCHAR) * 2 <= FileName.Length &&
|
||||
L'\\' == FileName.Buffer[1] && L'\\' == FileName.Buffer[0])
|
||||
return STATUS_OBJECT_NAME_INVALID;
|
||||
{
|
||||
Result = STATUS_OBJECT_NAME_INVALID;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
/* check for trailing backslash */
|
||||
@ -134,7 +162,10 @@ static NTSTATUS FspFsvolCreate(
|
||||
HasTrailingBackslash = TRUE;
|
||||
|
||||
if (sizeof(WCHAR) * 2 <= FileName.Length && L'\\' == FileName.Buffer[FileName.Length / 2 - 1])
|
||||
return STATUS_OBJECT_NAME_INVALID;
|
||||
{
|
||||
Result = STATUS_OBJECT_NAME_INVALID;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
/* is this a relative or absolute open? */
|
||||
@ -142,7 +173,10 @@ static NTSTATUS FspFsvolCreate(
|
||||
{
|
||||
/* must be a relative path */
|
||||
if (sizeof(WCHAR) <= FileName.Length && L'\\' == FileName.Buffer[0])
|
||||
return STATUS_OBJECT_NAME_INVALID;
|
||||
{
|
||||
Result = STATUS_OBJECT_NAME_INVALID;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
FSP_FILE_CONTEXT *RelatedFsContext = RelatedFileObject->FsContext;
|
||||
ASSERT(0 != RelatedFsContext);
|
||||
@ -160,7 +194,7 @@ static NTSTATUS FspFsvolCreate(
|
||||
RelatedFsContext->FileName.Length + AppendBackslash * sizeof(WCHAR) + FileName.Length,
|
||||
&FsContext);
|
||||
if (!NT_SUCCESS(Result))
|
||||
return Result;
|
||||
goto exit;
|
||||
|
||||
Result = RtlAppendUnicodeStringToString(&FsContext->FileName, &RelatedFsContext->FileName);
|
||||
ASSERT(NT_SUCCESS(Result));
|
||||
@ -174,13 +208,16 @@ static NTSTATUS FspFsvolCreate(
|
||||
{
|
||||
/* must be an absolute path */
|
||||
if (sizeof(WCHAR) <= FileName.Length && L'\\' != FileName.Buffer[0])
|
||||
return STATUS_OBJECT_NAME_INVALID;
|
||||
{
|
||||
Result = STATUS_OBJECT_NAME_INVALID;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
Result = FspFileContextCreate(
|
||||
FileName.Length,
|
||||
&FsContext);
|
||||
if (!NT_SUCCESS(Result))
|
||||
return Result;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
Result = RtlAppendUnicodeStringToString(&FsContext->FileName, &FileName);
|
||||
@ -195,7 +232,7 @@ static NTSTATUS FspFsvolCreate(
|
||||
if (!NT_SUCCESS(Result))
|
||||
{
|
||||
FspFileContextDelete(FsContext);
|
||||
return Result;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* populate the Create request */
|
||||
@ -226,7 +263,7 @@ static NTSTATUS FspFsvolCreate(
|
||||
FspFileContextDelete(FsContext);
|
||||
if (STATUS_BAD_DESCRIPTOR_FORMAT == Result || STATUS_BUFFER_TOO_SMALL == Result)
|
||||
return STATUS_INVALID_PARAMETER; /* should not happen */
|
||||
return Result;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -242,7 +279,7 @@ static NTSTATUS FspFsvolCreate(
|
||||
if (!NT_SUCCESS(Result))
|
||||
{
|
||||
FspFileContextDelete(FsContext);
|
||||
return Result;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* send the kernel handle and change it into a process handle at prepare time */
|
||||
@ -258,7 +295,15 @@ static NTSTATUS FspFsvolCreate(
|
||||
/* this can only happen if the Ioq was stopped */
|
||||
ASSERT(FspIoqStopped(&FsvrtDeviceExtension->Ioq));
|
||||
FspFileContextDelete(FsContext);
|
||||
return STATUS_CANCELLED;
|
||||
Result = STATUS_CANCELLED;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
exit:;
|
||||
}
|
||||
finally
|
||||
{
|
||||
FspDeviceRelease(FsvrtDeviceObject);
|
||||
}
|
||||
|
||||
return STATUS_PENDING;
|
||||
|
Loading…
x
Reference in New Issue
Block a user