diff --git a/dokan/dokan.c b/dokan/dokan.c index 8e243460..2a065250 100644 --- a/dokan/dokan.c +++ b/dokan/dokan.c @@ -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), diff --git a/sys/event.c b/sys/event.c index c01d3f6a..2f213124 100644 --- a/sys/event.c +++ b/sys/event.c @@ -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; @@ -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); diff --git a/sys/public.h b/sys/public.h index 1fc3457b..dfe778a4 100644 --- a/sys/public.h +++ b/sys/public.h @@ -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;