Skip to content

Commit

Permalink
Kernel / Library - Allow FCB Garbage collection interval to be set fr…
Browse files Browse the repository at this point in the history
…om userland
  • Loading branch information
Liryna committed Dec 30, 2021
1 parent eba8aac commit 574a532
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions dokan/dokan.c
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,7 @@ BOOL DokanStart(_In_ PDOKAN_INSTANCE DokanInstance) {
sizeof(DokanInstance->UNCName));

eventStart.IrpTimeout = DokanInstance->DokanOptions->Timeout;
eventStart.FcbGarbageCollectionIntervalMs = 2000;

SendToDevice(DOKAN_GLOBAL_DEVICE_NAME, FSCTL_EVENT_START, &eventStart,
sizeof(EVENT_START), &driverInfo, sizeof(EVENT_DRIVER_INFO),
Expand Down
15 changes: 14 additions & 1 deletion sys/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,6 @@ DokanEventStart(__in PREQUEST_CONTEXT RequestContext) {
}

dcb = dokanControl.Dcb;
dcb->FcbGarbageCollectionIntervalMs = 2000;
dcb->MountOptions = eventStart->Flags;
dcb->DispatchDriverLogs =
(eventStart->Flags & DOKAN_EVENT_DISPATCH_DRIVER_LOGS) != 0;
Expand Down Expand Up @@ -1023,6 +1022,20 @@ DokanEventStart(__in PREQUEST_CONTEXT RequestContext) {
dcb->IrpTimeout = eventStart->IrpTimeout;
}

dcb->FcbGarbageCollectionIntervalMs =
eventStart->FcbGarbageCollectionIntervalMs;
// Sanitize the garbage collection parameter.
if (dcb->FcbGarbageCollectionIntervalMs > 0) {
if (dcb->FcbGarbageCollectionIntervalMs <
MIN_FCB_GARBAGE_COLLECTION_INTERVAL) {
DokanLogInfo(&logger,
L"Not using FCB garbage collection because the"
L" specified interval of %lu is too low to be useful.",
dcb->FcbGarbageCollectionIntervalMs);
dcb->FcbGarbageCollectionIntervalMs = 0;
}
}

DokanLogInfo(&logger, L"Event start using mount ID: %d; device name: %s.",
dcb->MountId, driverInfo->DeviceName);

Expand Down
1 change: 1 addition & 0 deletions sys/public.h
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ typedef struct _EVENT_START {
WCHAR MountPoint[260];
WCHAR UNCName[64];
ULONG IrpTimeout;
ULONG FcbGarbageCollectionIntervalMs;
ULONG VolumeSecurityDescriptorLength;
CHAR VolumeSecurityDescriptor[VOLUME_SECURITY_DESCRIPTOR_MAX_SIZE];
} EVENT_START, *PEVENT_START;
Expand Down

0 comments on commit 574a532

Please sign in to comment.