mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-24 01:13:04 -05:00
Major refactoring: WIP
This commit is contained in:
parent
59203b7db9
commit
63a1227b57
123
src/sys/volume.c
123
src/sys/volume.c
@ -215,129 +215,6 @@ NTSTATUS FspVolumeWork(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
NTSTATUS FspFsctlCreateVolume(
|
|
||||||
PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
|
|
||||||
{
|
|
||||||
PAGED_CODE();
|
|
||||||
|
|
||||||
/* check parameters */
|
|
||||||
ULONG InputBufferLength = IrpSp->Parameters.FileSystemControl.InputBufferLength;
|
|
||||||
ULONG OutputBufferLength = IrpSp->Parameters.FileSystemControl.OutputBufferLength;
|
|
||||||
PVOID SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
|
|
||||||
if (0 == SystemBuffer || sizeof(FSP_FSCTL_VOLUME_PARAMS) > InputBufferLength)
|
|
||||||
return STATUS_INVALID_PARAMETER;
|
|
||||||
if (FSP_FSCTL_CREATE_BUFFER_SIZEMIN > OutputBufferLength)
|
|
||||||
return STATUS_BUFFER_TOO_SMALL;
|
|
||||||
|
|
||||||
NTSTATUS Result;
|
|
||||||
FSP_FSCTL_VOLUME_PARAMS VolumeParams = *(FSP_FSCTL_VOLUME_PARAMS *)SystemBuffer;
|
|
||||||
GUID Guid;
|
|
||||||
UNICODE_STRING DeviceSddl;
|
|
||||||
UNICODE_STRING DeviceName;
|
|
||||||
FSP_FSCTL_FILE_CONTEXT2 *FsContext2;
|
|
||||||
HANDLE MupHandle = 0;
|
|
||||||
PDEVICE_OBJECT FsvrtDeviceObject = 0;
|
|
||||||
PDEVICE_OBJECT FsvolDeviceObject;
|
|
||||||
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension;
|
|
||||||
|
|
||||||
/* check the passed in VolumeParams */
|
|
||||||
if (FspFsctlIrpTimeoutMinimum > VolumeParams.IrpTimeout ||
|
|
||||||
VolumeParams.IrpTimeout > FspFsctlIrpTimeoutMaximum)
|
|
||||||
{
|
|
||||||
#if DBG
|
|
||||||
/* allow the debug timeout value on debug builds */
|
|
||||||
if (FspFsctlIrpTimeoutDebug != VolumeParams.IrpTimeout)
|
|
||||||
#endif
|
|
||||||
VolumeParams.IrpTimeout = FspFsctlIrpTimeoutDefault;
|
|
||||||
}
|
|
||||||
if (FspFsctlTransactTimeoutMinimum > VolumeParams.TransactTimeout ||
|
|
||||||
VolumeParams.TransactTimeout > FspFsctlTransactTimeoutMaximum)
|
|
||||||
VolumeParams.TransactTimeout = FspFsctlTransactTimeoutDefault;
|
|
||||||
|
|
||||||
/* create volume guid */
|
|
||||||
Result = FspCreateGuid(&Guid);
|
|
||||||
if (!NT_SUCCESS(Result))
|
|
||||||
return Result;
|
|
||||||
|
|
||||||
/* prepare the device name and SDDL */
|
|
||||||
RtlInitUnicodeString(&DeviceSddl, L"" FSP_FSVRT_DEVICE_SDDL);
|
|
||||||
RtlInitEmptyUnicodeString(&DeviceName, SystemBuffer, FSP_FSCTL_CREATE_BUFFER_SIZEMIN);
|
|
||||||
Result = RtlUnicodeStringPrintf(&DeviceName,
|
|
||||||
L"\\Device\\Volume{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
|
|
||||||
Guid.Data1, Guid.Data2, Guid.Data3,
|
|
||||||
Guid.Data4[0], Guid.Data4[1], Guid.Data4[2], Guid.Data4[3],
|
|
||||||
Guid.Data4[4], Guid.Data4[5], Guid.Data4[6], Guid.Data4[7]);
|
|
||||||
ASSERT(NT_SUCCESS(Result));
|
|
||||||
|
|
||||||
FsContext2 = IrpSp->FileObject->FsContext2;
|
|
||||||
ExAcquireFastMutex(&FsContext2->FastMutex);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
/* check to see if we already have a volume */
|
|
||||||
if (0 != FsContext2->FsvolDeviceObject)
|
|
||||||
{
|
|
||||||
Result = STATUS_ACCESS_DENIED;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* create the volume (and virtual disk) device(s) */
|
|
||||||
Result = FspDeviceCreate(FspFsvolDeviceExtensionKind, 0,
|
|
||||||
DeviceObject->DeviceType,
|
|
||||||
&FsvolDeviceObject);
|
|
||||||
if (!NT_SUCCESS(Result))
|
|
||||||
goto exit;
|
|
||||||
if (FILE_DEVICE_DISK_FILE_SYSTEM == DeviceObject->DeviceType)
|
|
||||||
{
|
|
||||||
Result = FspDeviceCreateSecure(FspFsvrtDeviceExtensionKind, 0,
|
|
||||||
&DeviceName, FILE_DEVICE_VIRTUAL_DISK,
|
|
||||||
&DeviceSddl, &FspFsvrtDeviceClassGuid,
|
|
||||||
&FsvrtDeviceObject);
|
|
||||||
if (!NT_SUCCESS(Result))
|
|
||||||
{
|
|
||||||
FspDeviceRelease(FsvolDeviceObject);
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
#pragma prefast(suppress:28175, "We are a filesystem: ok to access SectorSize")
|
|
||||||
FsvrtDeviceObject->SectorSize = VolumeParams.SectorSize;
|
|
||||||
}
|
|
||||||
#pragma prefast(suppress:28175, "We are a filesystem: ok to access SectorSize")
|
|
||||||
FsvolDeviceObject->SectorSize = VolumeParams.SectorSize;
|
|
||||||
FsvolDeviceExtension = FspFsvolDeviceExtension(FsvolDeviceObject);
|
|
||||||
FsvolDeviceExtension->FsctlDeviceObject = DeviceObject;
|
|
||||||
FsvolDeviceExtension->FsvrtDeviceObject = FsvrtDeviceObject;
|
|
||||||
FsvolDeviceExtension->VolumeParams = VolumeParams;
|
|
||||||
if (0 != FsvrtDeviceObject)
|
|
||||||
FspDeviceInitComplete(FsvrtDeviceObject);
|
|
||||||
FspDeviceInitComplete(FsvolDeviceObject);
|
|
||||||
|
|
||||||
/* do we need to register with MUP? */
|
|
||||||
if (0 == FsvrtDeviceObject)
|
|
||||||
{
|
|
||||||
Result = FsRtlRegisterUncProviderEx(&MupHandle, &DeviceName, FsvolDeviceObject, 0);
|
|
||||||
if (!NT_SUCCESS(Result))
|
|
||||||
{
|
|
||||||
FspDeviceRelease(FsvolDeviceObject);
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
FsvolDeviceExtension->MupHandle = MupHandle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* associate the new volume device with our file object */
|
|
||||||
FsContext2->FsvolDeviceObject = FsvolDeviceObject;
|
|
||||||
|
|
||||||
Irp->IoStatus.Information = DeviceName.Length + sizeof(WCHAR);
|
|
||||||
Result = STATUS_SUCCESS;
|
|
||||||
|
|
||||||
exit:;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
ExReleaseFastMutex(&FsContext2->FastMutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static NTSTATUS FspFsctlMountVolume(
|
static NTSTATUS FspFsctlMountVolume(
|
||||||
PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
|
PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user