mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-23 17:03:12 -05:00
Major refactoring: WIP
This commit is contained in:
parent
7197501c9a
commit
da4fa4a925
@ -28,6 +28,9 @@ static NTSTATUS FspFsctlClose(
|
|||||||
{
|
{
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
|
FspFree(IrpSp->FileObject->FsContext2);
|
||||||
|
IrpSp->FileObject->FsContext2 = 0;
|
||||||
|
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,14 @@ static NTSTATUS FspFsctlCreate(
|
|||||||
{
|
{
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
|
FSP_FSCTL_FILE_CONTEXT2 *FsContext2;
|
||||||
|
FsContext2 = FspAlloc(sizeof *FsContext2);
|
||||||
|
if (0 == FsContext2)
|
||||||
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
|
RtlZeroMemory(FsContext2, sizeof *FsContext2);
|
||||||
|
IrpSp->FileObject->FsContext2 = FsContext2;
|
||||||
|
|
||||||
Irp->IoStatus.Information = FILE_OPENED;
|
Irp->IoStatus.Information = FILE_OPENED;
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
247
src/sys/device.c
247
src/sys/device.c
@ -17,19 +17,19 @@ VOID FspDeviceInitComplete(PDEVICE_OBJECT DeviceObject);
|
|||||||
VOID FspDeviceDelete(PDEVICE_OBJECT DeviceObject);
|
VOID FspDeviceDelete(PDEVICE_OBJECT DeviceObject);
|
||||||
BOOLEAN FspDeviceRetain(PDEVICE_OBJECT DeviceObject);
|
BOOLEAN FspDeviceRetain(PDEVICE_OBJECT DeviceObject);
|
||||||
VOID FspDeviceRelease(PDEVICE_OBJECT DeviceObject);
|
VOID FspDeviceRelease(PDEVICE_OBJECT DeviceObject);
|
||||||
PVOID FspDeviceLookupContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier);
|
|
||||||
PVOID FspDeviceInsertContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier, PVOID Context,
|
|
||||||
FSP_DEVICE_GENERIC_TABLE_ELEMENT *ElementStorage, PBOOLEAN PInserted);
|
|
||||||
VOID FspDeviceDeleteContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier,
|
|
||||||
PBOOLEAN PDeleted);
|
|
||||||
static RTL_AVL_COMPARE_ROUTINE FspDeviceCompareElement;
|
|
||||||
static RTL_AVL_ALLOCATE_ROUTINE FspDeviceAllocateElement;
|
|
||||||
static RTL_AVL_FREE_ROUTINE FspDeviceFreeElement;
|
|
||||||
static NTSTATUS FspFsvolDeviceInit(PDEVICE_OBJECT DeviceObject);
|
static NTSTATUS FspFsvolDeviceInit(PDEVICE_OBJECT DeviceObject);
|
||||||
static VOID FspFsvolDeviceInitComplete(PDEVICE_OBJECT DeviceObject);
|
static VOID FspFsvolDeviceInitComplete(PDEVICE_OBJECT DeviceObject);
|
||||||
static VOID FspFsvolDeviceFini(PDEVICE_OBJECT DeviceObject);
|
static VOID FspFsvolDeviceFini(PDEVICE_OBJECT DeviceObject);
|
||||||
static IO_TIMER_ROUTINE FspFsvolDeviceTimerRoutine;
|
static IO_TIMER_ROUTINE FspFsvolDeviceTimerRoutine;
|
||||||
static WORKER_THREAD_ROUTINE FspFsvolDeviceExpirationRoutine;
|
static WORKER_THREAD_ROUTINE FspFsvolDeviceExpirationRoutine;
|
||||||
|
PVOID FspFsvolDeviceLookupContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier);
|
||||||
|
PVOID FspFsvolDeviceInsertContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier, PVOID Context,
|
||||||
|
FSP_DEVICE_GENERIC_TABLE_ELEMENT *ElementStorage, PBOOLEAN PInserted);
|
||||||
|
VOID FspFsvolDeviceDeleteContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier,
|
||||||
|
PBOOLEAN PDeleted);
|
||||||
|
static RTL_AVL_COMPARE_ROUTINE FspFsvolDeviceCompareElement;
|
||||||
|
static RTL_AVL_ALLOCATE_ROUTINE FspFsvolDeviceAllocateElement;
|
||||||
|
static RTL_AVL_FREE_ROUTINE FspFsvolDeviceFreeElement;
|
||||||
NTSTATUS FspDeviceCopyList(
|
NTSTATUS FspDeviceCopyList(
|
||||||
PDEVICE_OBJECT **PDeviceObjects, PULONG PDeviceObjectCount);
|
PDEVICE_OBJECT **PDeviceObjects, PULONG PDeviceObjectCount);
|
||||||
VOID FspDeviceDeleteList(
|
VOID FspDeviceDeleteList(
|
||||||
@ -41,15 +41,15 @@ VOID FspDeviceDeleteAll(VOID);
|
|||||||
#pragma alloc_text(PAGE, FspDeviceCreate)
|
#pragma alloc_text(PAGE, FspDeviceCreate)
|
||||||
#pragma alloc_text(PAGE, FspDeviceInitComplete)
|
#pragma alloc_text(PAGE, FspDeviceInitComplete)
|
||||||
#pragma alloc_text(PAGE, FspDeviceDelete)
|
#pragma alloc_text(PAGE, FspDeviceDelete)
|
||||||
#pragma alloc_text(PAGE, FspDeviceLookupContext)
|
|
||||||
#pragma alloc_text(PAGE, FspDeviceInsertContext)
|
|
||||||
#pragma alloc_text(PAGE, FspDeviceDeleteContext)
|
|
||||||
#pragma alloc_text(PAGE, FspDeviceCompareElement)
|
|
||||||
#pragma alloc_text(PAGE, FspDeviceAllocateElement)
|
|
||||||
#pragma alloc_text(PAGE, FspDeviceFreeElement)
|
|
||||||
#pragma alloc_text(PAGE, FspFsvolDeviceInit)
|
#pragma alloc_text(PAGE, FspFsvolDeviceInit)
|
||||||
#pragma alloc_text(PAGE, FspFsvolDeviceInitComplete)
|
#pragma alloc_text(PAGE, FspFsvolDeviceInitComplete)
|
||||||
#pragma alloc_text(PAGE, FspFsvolDeviceFini)
|
#pragma alloc_text(PAGE, FspFsvolDeviceFini)
|
||||||
|
#pragma alloc_text(PAGE, FspFsvolDeviceLookupContext)
|
||||||
|
#pragma alloc_text(PAGE, FspFsvolDeviceInsertContext)
|
||||||
|
#pragma alloc_text(PAGE, FspFsvolDeviceDeleteContext)
|
||||||
|
#pragma alloc_text(PAGE, FspFsvolDeviceCompareElement)
|
||||||
|
#pragma alloc_text(PAGE, FspFsvolDeviceAllocateElement)
|
||||||
|
#pragma alloc_text(PAGE, FspFsvolDeviceFreeElement)
|
||||||
#pragma alloc_text(PAGE, FspDeviceCopyList)
|
#pragma alloc_text(PAGE, FspDeviceCopyList)
|
||||||
#pragma alloc_text(PAGE, FspDeviceDeleteList)
|
#pragma alloc_text(PAGE, FspDeviceDeleteList)
|
||||||
#pragma alloc_text(PAGE, FspDeviceDeleteAll)
|
#pragma alloc_text(PAGE, FspDeviceDeleteAll)
|
||||||
@ -101,8 +101,6 @@ NTSTATUS FspDeviceCreateSecure(UINT32 Kind, ULONG ExtraSize,
|
|||||||
KeInitializeSpinLock(&DeviceExtension->SpinLock);
|
KeInitializeSpinLock(&DeviceExtension->SpinLock);
|
||||||
DeviceExtension->RefCount = 1;
|
DeviceExtension->RefCount = 1;
|
||||||
ExInitializeResourceLite(&DeviceExtension->Resource);
|
ExInitializeResourceLite(&DeviceExtension->Resource);
|
||||||
RtlInitializeGenericTableAvl(&DeviceExtension->GenericTable,
|
|
||||||
FspDeviceCompareElement, FspDeviceAllocateElement, FspDeviceFreeElement, 0);
|
|
||||||
DeviceExtension->Kind = Kind;
|
DeviceExtension->Kind = Kind;
|
||||||
|
|
||||||
switch (Kind)
|
switch (Kind)
|
||||||
@ -118,17 +116,6 @@ NTSTATUS FspDeviceCreateSecure(UINT32 Kind, ULONG ExtraSize,
|
|||||||
|
|
||||||
if (!NT_SUCCESS(Result))
|
if (!NT_SUCCESS(Result))
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
/* FspDeviceFreeElement is now a no-op, so this is no longer necessary */
|
|
||||||
/*
|
|
||||||
* Enumerate and delete all entries in the GenericTable.
|
|
||||||
* There is no need to protect accesses to the table as we are in the device destructor.
|
|
||||||
*/
|
|
||||||
FSP_DEVICE_GENERIC_TABLE_ELEMENT_DATA *Element;
|
|
||||||
while (0 != (Element = RtlGetElementGenericTableAvl(&DeviceExtension->GenericTable, 0)))
|
|
||||||
RtlDeleteElementGenericTableAvl(&DeviceExtension->GenericTable, &Element->Identifier);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ExDeleteResourceLite(&DeviceExtension->Resource);
|
ExDeleteResourceLite(&DeviceExtension->Resource);
|
||||||
IoDeleteDevice(DeviceObject);
|
IoDeleteDevice(DeviceObject);
|
||||||
}
|
}
|
||||||
@ -190,17 +177,6 @@ VOID FspDeviceDelete(PDEVICE_OBJECT DeviceObject)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* FspDeviceFreeElement is now a no-op, so this is no longer necessary */
|
|
||||||
/*
|
|
||||||
* Enumerate and delete all entries in the GenericTable.
|
|
||||||
* There is no need to protect accesses to the table as we are in the device destructor.
|
|
||||||
*/
|
|
||||||
FSP_DEVICE_GENERIC_TABLE_ELEMENT_DATA *Element;
|
|
||||||
while (0 != (Element = RtlGetElementGenericTableAvl(&DeviceExtension->GenericTable, 0)))
|
|
||||||
RtlDeleteElementGenericTableAvl(&DeviceExtension->GenericTable, &Element->Identifier);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ExDeleteResourceLite(&DeviceExtension->Resource);
|
ExDeleteResourceLite(&DeviceExtension->Resource);
|
||||||
IoDeleteDevice(DeviceObject);
|
IoDeleteDevice(DeviceObject);
|
||||||
}
|
}
|
||||||
@ -244,92 +220,6 @@ VOID FspDeviceRelease(PDEVICE_OBJECT DeviceObject)
|
|||||||
FspDeviceDelete(DeviceObject);
|
FspDeviceDelete(DeviceObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
PVOID FspDeviceLookupContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier)
|
|
||||||
{
|
|
||||||
PAGED_CODE();
|
|
||||||
|
|
||||||
FSP_DEVICE_EXTENSION *DeviceExtension = FspDeviceExtension(DeviceObject);
|
|
||||||
ASSERT(ExIsResourceAcquiredExclusiveLite(&DeviceExtension->Resource));
|
|
||||||
|
|
||||||
FSP_DEVICE_GENERIC_TABLE_ELEMENT_DATA *Result;
|
|
||||||
|
|
||||||
Result = RtlLookupElementGenericTableAvl(&DeviceExtension->GenericTable, &Identifier);
|
|
||||||
|
|
||||||
return 0 != Result ? Result->Context : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
PVOID FspDeviceInsertContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier, PVOID Context,
|
|
||||||
FSP_DEVICE_GENERIC_TABLE_ELEMENT *ElementStorage, PBOOLEAN PInserted)
|
|
||||||
{
|
|
||||||
PAGED_CODE();
|
|
||||||
|
|
||||||
FSP_DEVICE_EXTENSION *DeviceExtension = FspDeviceExtension(DeviceObject);
|
|
||||||
ASSERT(ExIsResourceAcquiredExclusiveLite(&DeviceExtension->Resource));
|
|
||||||
ASSERT(0 != ElementStorage);
|
|
||||||
|
|
||||||
FSP_DEVICE_GENERIC_TABLE_ELEMENT_DATA *Result, Element = { 0 };
|
|
||||||
Element.Identifier = Identifier;
|
|
||||||
Element.Context = Context;
|
|
||||||
|
|
||||||
DeviceExtension->GenericTableElementStorage = ElementStorage;
|
|
||||||
Result = RtlInsertElementGenericTableAvl(&DeviceExtension->GenericTable,
|
|
||||||
&Element, sizeof Element, PInserted);
|
|
||||||
DeviceExtension->GenericTableElementStorage = 0;
|
|
||||||
|
|
||||||
ASSERT(0 != Result);
|
|
||||||
|
|
||||||
return Result->Context;
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID FspDeviceDeleteContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier,
|
|
||||||
PBOOLEAN PDeleted)
|
|
||||||
{
|
|
||||||
PAGED_CODE();
|
|
||||||
|
|
||||||
FSP_DEVICE_EXTENSION *DeviceExtension = FspDeviceExtension(DeviceObject);
|
|
||||||
ASSERT(ExIsResourceAcquiredExclusiveLite(&DeviceExtension->Resource));
|
|
||||||
|
|
||||||
BOOLEAN Deleted;
|
|
||||||
|
|
||||||
Deleted = RtlDeleteElementGenericTableAvl(&DeviceExtension->GenericTable, &Identifier);
|
|
||||||
|
|
||||||
if (0 != PDeleted)
|
|
||||||
*PDeleted = Deleted;
|
|
||||||
}
|
|
||||||
|
|
||||||
static RTL_GENERIC_COMPARE_RESULTS NTAPI FspDeviceCompareElement(
|
|
||||||
PRTL_AVL_TABLE Table, PVOID FirstElement, PVOID SecondElement)
|
|
||||||
{
|
|
||||||
PAGED_CODE();
|
|
||||||
|
|
||||||
if (FirstElement < SecondElement)
|
|
||||||
return GenericLessThan;
|
|
||||||
else
|
|
||||||
if (SecondElement < FirstElement)
|
|
||||||
return GenericGreaterThan;
|
|
||||||
else
|
|
||||||
return GenericEqual;
|
|
||||||
}
|
|
||||||
|
|
||||||
static PVOID NTAPI FspDeviceAllocateElement(
|
|
||||||
PRTL_AVL_TABLE Table, CLONG ByteSize)
|
|
||||||
{
|
|
||||||
PAGED_CODE();
|
|
||||||
|
|
||||||
FSP_DEVICE_EXTENSION *DeviceExtension =
|
|
||||||
CONTAINING_RECORD(Table, FSP_DEVICE_EXTENSION, GenericTable);
|
|
||||||
|
|
||||||
ASSERT(sizeof(FSP_DEVICE_GENERIC_TABLE_ELEMENT) == ByteSize);
|
|
||||||
|
|
||||||
return DeviceExtension->GenericTableElementStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
static VOID NTAPI FspDeviceFreeElement(
|
|
||||||
PRTL_AVL_TABLE Table, PVOID Buffer)
|
|
||||||
{
|
|
||||||
PAGED_CODE();
|
|
||||||
}
|
|
||||||
|
|
||||||
static NTSTATUS FspFsvolDeviceInit(PDEVICE_OBJECT DeviceObject)
|
static NTSTATUS FspFsvolDeviceInit(PDEVICE_OBJECT DeviceObject)
|
||||||
{
|
{
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
@ -337,6 +227,11 @@ static NTSTATUS FspFsvolDeviceInit(PDEVICE_OBJECT DeviceObject)
|
|||||||
NTSTATUS Result;
|
NTSTATUS Result;
|
||||||
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
||||||
|
|
||||||
|
/* initialize our timer routine */
|
||||||
|
Result = IoInitializeTimer(DeviceObject, FspFsvolDeviceTimerRoutine, 0);
|
||||||
|
if (!NT_SUCCESS(Result))
|
||||||
|
return Result;
|
||||||
|
|
||||||
/* allocate a spare VPB in case we are mounted on an fsvrt */
|
/* allocate a spare VPB in case we are mounted on an fsvrt */
|
||||||
if (FILE_DEVICE_DISK_FILE_SYSTEM == DeviceObject->DeviceType)
|
if (FILE_DEVICE_DISK_FILE_SYSTEM == DeviceObject->DeviceType)
|
||||||
{
|
{
|
||||||
@ -352,10 +247,9 @@ static NTSTATUS FspFsvolDeviceInit(PDEVICE_OBJECT DeviceObject)
|
|||||||
ExInitializeWorkItem(&FsvolDeviceExtension->ExpirationWorkItem,
|
ExInitializeWorkItem(&FsvolDeviceExtension->ExpirationWorkItem,
|
||||||
FspFsvolDeviceExpirationRoutine, DeviceObject);
|
FspFsvolDeviceExpirationRoutine, DeviceObject);
|
||||||
|
|
||||||
/* initialize our timer routine */
|
/* initialize our generic table */
|
||||||
Result = IoInitializeTimer(DeviceObject, FspFsvolDeviceTimerRoutine, 0);
|
RtlInitializeGenericTableAvl(&FsvolDeviceExtension->GenericTable,
|
||||||
if (!NT_SUCCESS(Result))
|
FspFsvolDeviceCompareElement, FspFsvolDeviceAllocateElement, FspFsvolDeviceFreeElement, 0);
|
||||||
return Result;
|
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -391,6 +285,17 @@ static VOID FspFsvolDeviceFini(PDEVICE_OBJECT DeviceObject)
|
|||||||
*/
|
*/
|
||||||
IoStopTimer(DeviceObject);
|
IoStopTimer(DeviceObject);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* FspDeviceFreeElement is now a no-op, so this is no longer necessary */
|
||||||
|
/*
|
||||||
|
* Enumerate and delete all entries in the GenericTable.
|
||||||
|
* There is no need to protect accesses to the table as we are in the device destructor.
|
||||||
|
*/
|
||||||
|
FSP_DEVICE_GENERIC_TABLE_ELEMENT_DATA *Element;
|
||||||
|
while (0 != (Element = RtlGetElementGenericTableAvl(&FsvolDeviceExtension->GenericTable, 0)))
|
||||||
|
RtlDeleteElementGenericTableAvl(&FsvolDeviceExtension->GenericTable, &Element->Identifier);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dereference the virtual volume device so that it can now go away.
|
* Dereference the virtual volume device so that it can now go away.
|
||||||
*/
|
*/
|
||||||
@ -454,6 +359,92 @@ static VOID FspFsvolDeviceExpirationRoutine(PVOID Context)
|
|||||||
ObDereferenceObject(DeviceObject);
|
ObDereferenceObject(DeviceObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PVOID FspFsvolDeviceLookupContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier)
|
||||||
|
{
|
||||||
|
PAGED_CODE();
|
||||||
|
|
||||||
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
||||||
|
ASSERT(ExIsResourceAcquiredExclusiveLite(&FsvolDeviceExtension->Base.Resource));
|
||||||
|
|
||||||
|
FSP_DEVICE_GENERIC_TABLE_ELEMENT_DATA *Result;
|
||||||
|
|
||||||
|
Result = RtlLookupElementGenericTableAvl(&FsvolDeviceExtension->GenericTable, &Identifier);
|
||||||
|
|
||||||
|
return 0 != Result ? Result->Context : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
PVOID FspFsvolDeviceInsertContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier, PVOID Context,
|
||||||
|
FSP_DEVICE_GENERIC_TABLE_ELEMENT *ElementStorage, PBOOLEAN PInserted)
|
||||||
|
{
|
||||||
|
PAGED_CODE();
|
||||||
|
|
||||||
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
||||||
|
ASSERT(ExIsResourceAcquiredExclusiveLite(&FsvolDeviceExtension->Base.Resource));
|
||||||
|
ASSERT(0 != ElementStorage);
|
||||||
|
|
||||||
|
FSP_DEVICE_GENERIC_TABLE_ELEMENT_DATA *Result, Element = { 0 };
|
||||||
|
Element.Identifier = Identifier;
|
||||||
|
Element.Context = Context;
|
||||||
|
|
||||||
|
FsvolDeviceExtension->GenericTableElementStorage = ElementStorage;
|
||||||
|
Result = RtlInsertElementGenericTableAvl(&FsvolDeviceExtension->GenericTable,
|
||||||
|
&Element, sizeof Element, PInserted);
|
||||||
|
FsvolDeviceExtension->GenericTableElementStorage = 0;
|
||||||
|
|
||||||
|
ASSERT(0 != Result);
|
||||||
|
|
||||||
|
return Result->Context;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID FspFsvolDeviceDeleteContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier,
|
||||||
|
PBOOLEAN PDeleted)
|
||||||
|
{
|
||||||
|
PAGED_CODE();
|
||||||
|
|
||||||
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
||||||
|
ASSERT(ExIsResourceAcquiredExclusiveLite(&FsvolDeviceExtension->Base.Resource));
|
||||||
|
|
||||||
|
BOOLEAN Deleted;
|
||||||
|
|
||||||
|
Deleted = RtlDeleteElementGenericTableAvl(&FsvolDeviceExtension->GenericTable, &Identifier);
|
||||||
|
|
||||||
|
if (0 != PDeleted)
|
||||||
|
*PDeleted = Deleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
static RTL_GENERIC_COMPARE_RESULTS NTAPI FspFsvolDeviceCompareElement(
|
||||||
|
PRTL_AVL_TABLE Table, PVOID FirstElement, PVOID SecondElement)
|
||||||
|
{
|
||||||
|
PAGED_CODE();
|
||||||
|
|
||||||
|
if (FirstElement < SecondElement)
|
||||||
|
return GenericLessThan;
|
||||||
|
else
|
||||||
|
if (SecondElement < FirstElement)
|
||||||
|
return GenericGreaterThan;
|
||||||
|
else
|
||||||
|
return GenericEqual;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PVOID NTAPI FspFsvolDeviceAllocateElement(
|
||||||
|
PRTL_AVL_TABLE Table, CLONG ByteSize)
|
||||||
|
{
|
||||||
|
PAGED_CODE();
|
||||||
|
|
||||||
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension =
|
||||||
|
CONTAINING_RECORD(Table, FSP_FSVOL_DEVICE_EXTENSION, GenericTable);
|
||||||
|
|
||||||
|
ASSERT(sizeof(FSP_DEVICE_GENERIC_TABLE_ELEMENT) == ByteSize);
|
||||||
|
|
||||||
|
return FsvolDeviceExtension->GenericTableElementStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VOID NTAPI FspFsvolDeviceFreeElement(
|
||||||
|
PRTL_AVL_TABLE Table, PVOID Buffer)
|
||||||
|
{
|
||||||
|
PAGED_CODE();
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS FspDeviceCopyList(
|
NTSTATUS FspDeviceCopyList(
|
||||||
PDEVICE_OBJECT **PDeviceObjects, PULONG PDeviceObjectCount)
|
PDEVICE_OBJECT **PDeviceObjects, PULONG PDeviceObjectCount)
|
||||||
{
|
{
|
||||||
|
@ -355,8 +355,6 @@ typedef struct
|
|||||||
KSPIN_LOCK SpinLock;
|
KSPIN_LOCK SpinLock;
|
||||||
LONG RefCount;
|
LONG RefCount;
|
||||||
ERESOURCE Resource;
|
ERESOURCE Resource;
|
||||||
RTL_AVL_TABLE GenericTable;
|
|
||||||
PVOID GenericTableElementStorage;
|
|
||||||
UINT32 Kind;
|
UINT32 Kind;
|
||||||
} FSP_DEVICE_EXTENSION;
|
} FSP_DEVICE_EXTENSION;
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -374,6 +372,8 @@ typedef struct
|
|||||||
KSPIN_LOCK ExpirationLock;
|
KSPIN_LOCK ExpirationLock;
|
||||||
WORK_QUEUE_ITEM ExpirationWorkItem;
|
WORK_QUEUE_ITEM ExpirationWorkItem;
|
||||||
BOOLEAN ExpirationInProgress;
|
BOOLEAN ExpirationInProgress;
|
||||||
|
RTL_AVL_TABLE GenericTable;
|
||||||
|
PVOID GenericTableElementStorage;
|
||||||
} FSP_FSVOL_DEVICE_EXTENSION;
|
} FSP_FSVOL_DEVICE_EXTENSION;
|
||||||
static inline
|
static inline
|
||||||
FSP_DEVICE_EXTENSION *FspDeviceExtension(PDEVICE_OBJECT DeviceObject)
|
FSP_DEVICE_EXTENSION *FspDeviceExtension(PDEVICE_OBJECT DeviceObject)
|
||||||
@ -397,10 +397,10 @@ VOID FspDeviceInitComplete(PDEVICE_OBJECT DeviceObject);
|
|||||||
VOID FspDeviceDelete(PDEVICE_OBJECT DeviceObject);
|
VOID FspDeviceDelete(PDEVICE_OBJECT DeviceObject);
|
||||||
BOOLEAN FspDeviceRetain(PDEVICE_OBJECT DeviceObject);
|
BOOLEAN FspDeviceRetain(PDEVICE_OBJECT DeviceObject);
|
||||||
VOID FspDeviceRelease(PDEVICE_OBJECT DeviceObject);
|
VOID FspDeviceRelease(PDEVICE_OBJECT DeviceObject);
|
||||||
PVOID FspDeviceLookupContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier);
|
PVOID FspFsvolDeviceLookupContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier);
|
||||||
PVOID FspDeviceInsertContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier, PVOID Context,
|
PVOID FspFsvolDeviceInsertContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier, PVOID Context,
|
||||||
FSP_DEVICE_GENERIC_TABLE_ELEMENT *ElementStorage, PBOOLEAN PInserted);
|
FSP_DEVICE_GENERIC_TABLE_ELEMENT *ElementStorage, PBOOLEAN PInserted);
|
||||||
VOID FspDeviceDeleteContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier,
|
VOID FspFsvolDeviceDeleteContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier,
|
||||||
PBOOLEAN PDeleted);
|
PBOOLEAN PDeleted);
|
||||||
NTSTATUS FspDeviceCopyList(
|
NTSTATUS FspDeviceCopyList(
|
||||||
PDEVICE_OBJECT **PDeviceObjects, PULONG PDeviceObjectCount);
|
PDEVICE_OBJECT **PDeviceObjects, PULONG PDeviceObjectCount);
|
||||||
@ -408,6 +408,12 @@ VOID FspDeviceDeleteList(
|
|||||||
PDEVICE_OBJECT *DeviceObjects, ULONG DeviceObjectCount);
|
PDEVICE_OBJECT *DeviceObjects, ULONG DeviceObjectCount);
|
||||||
VOID FspDeviceDeleteAll(VOID);
|
VOID FspDeviceDeleteAll(VOID);
|
||||||
|
|
||||||
|
/* fsctl file objects */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
PDEVICE_OBJECT FsvolDeviceObject;
|
||||||
|
} FSP_FSCTL_FILE_CONTEXT2;
|
||||||
|
|
||||||
/* debug */
|
/* debug */
|
||||||
#if DBG
|
#if DBG
|
||||||
BOOLEAN HasDbgBreakPoint(const char *Function);
|
BOOLEAN HasDbgBreakPoint(const char *Function);
|
||||||
|
@ -69,6 +69,7 @@ static NTSTATUS FspFsctlCreateVolume(
|
|||||||
{
|
{
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
|
#if 0
|
||||||
/* check parameters */
|
/* check parameters */
|
||||||
ULONG InputBufferLength = IrpSp->Parameters.FileSystemControl.InputBufferLength;
|
ULONG InputBufferLength = IrpSp->Parameters.FileSystemControl.InputBufferLength;
|
||||||
ULONG OutputBufferLength = IrpSp->Parameters.FileSystemControl.OutputBufferLength;
|
ULONG OutputBufferLength = IrpSp->Parameters.FileSystemControl.OutputBufferLength;
|
||||||
@ -189,6 +190,9 @@ static NTSTATUS FspFsctlCreateVolume(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
|
#else
|
||||||
|
return STATUS_INVALID_DEVICE_REQUEST;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static NTSTATUS FspFsctlMountVolume(
|
static NTSTATUS FspFsctlMountVolume(
|
||||||
@ -196,6 +200,7 @@ static NTSTATUS FspFsctlMountVolume(
|
|||||||
{
|
{
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
|
#if 0
|
||||||
NTSTATUS Result;
|
NTSTATUS Result;
|
||||||
|
|
||||||
FSP_DEVICE_EXTENSION *DeviceExtension = FspDeviceExtension(DeviceObject);
|
FSP_DEVICE_EXTENSION *DeviceExtension = FspDeviceExtension(DeviceObject);
|
||||||
@ -237,6 +242,9 @@ static NTSTATUS FspFsctlMountVolume(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
|
#else
|
||||||
|
return STATUS_INVALID_DEVICE_REQUEST;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID FspFsctlDeleteVolume(
|
VOID FspFsctlDeleteVolume(
|
||||||
@ -245,6 +253,7 @@ VOID FspFsctlDeleteVolume(
|
|||||||
/* performed during IRP_MJ_CLEANUP! */
|
/* performed during IRP_MJ_CLEANUP! */
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
|
#if 0
|
||||||
PDEVICE_OBJECT FsvolDeviceObject = 0;
|
PDEVICE_OBJECT FsvolDeviceObject = 0;
|
||||||
|
|
||||||
FSP_DEVICE_EXTENSION *DeviceExtension = FspDeviceExtension(DeviceObject);
|
FSP_DEVICE_EXTENSION *DeviceExtension = FspDeviceExtension(DeviceObject);
|
||||||
@ -336,12 +345,15 @@ VOID FspFsctlDeleteVolume(
|
|||||||
FspDeviceRelease(FsvolDeviceObject);
|
FspDeviceRelease(FsvolDeviceObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID FspFsctlDeleteVolumeDelayed(PVOID Context)
|
static VOID FspFsctlDeleteVolumeDelayed(PVOID Context)
|
||||||
{
|
{
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
PDEVICE_OBJECT FsvolDeviceObject = Context;
|
PDEVICE_OBJECT FsvolDeviceObject = Context;
|
||||||
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(FsvolDeviceObject);
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(FsvolDeviceObject);
|
||||||
KIRQL Irql;
|
KIRQL Irql;
|
||||||
@ -365,6 +377,7 @@ static VOID FspFsctlDeleteVolumeDelayed(PVOID Context)
|
|||||||
DelayTimeout.QuadPart = 300/*ms*/ * -10000;
|
DelayTimeout.QuadPart = 300/*ms*/ * -10000;
|
||||||
FspQueueWorkItemWithDelay(&FsvolDeviceExtension->DeleteVolumeWorkItem, DelayTimeout);
|
FspQueueWorkItemWithDelay(&FsvolDeviceExtension->DeleteVolumeWorkItem, DelayTimeout);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static NTSTATUS FspFsctlTransact(
|
static NTSTATUS FspFsctlTransact(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user