mirror of
https://github.com/winfsp/winfsp.git
synced 2025-06-14 15:52:47 -05:00
inc,sys,tst: FSP_FSCTL_VOLUME_PARAMS: fine-grained timeouts
This commit is contained in:
@ -346,7 +346,7 @@ static NTSTATUS FspFsvolDeviceInit(PDEVICE_OBJECT DeviceObject)
|
||||
FsvolDeviceExtension->InitDoneIoq = 1;
|
||||
|
||||
/* create our security meta cache */
|
||||
SecurityTimeout.QuadPart = FspTimeoutFromMillis(FsvolDeviceExtension->VolumeParams.FileInfoTimeout);
|
||||
SecurityTimeout.QuadPart = FspTimeoutFromMillis(FsvolDeviceExtension->VolumeParams.SecurityTimeout);
|
||||
/* convert millis to nanos */
|
||||
Result = FspMetaCacheCreate(
|
||||
FspFsvolDeviceSecurityCacheCapacity, FspFsvolDeviceSecurityCacheItemSizeMax, &SecurityTimeout,
|
||||
@ -356,7 +356,7 @@ static NTSTATUS FspFsvolDeviceInit(PDEVICE_OBJECT DeviceObject)
|
||||
FsvolDeviceExtension->InitDoneSec = 1;
|
||||
|
||||
/* create our directory meta cache */
|
||||
DirInfoTimeout.QuadPart = FspTimeoutFromMillis(FsvolDeviceExtension->VolumeParams.FileInfoTimeout);
|
||||
DirInfoTimeout.QuadPart = FspTimeoutFromMillis(FsvolDeviceExtension->VolumeParams.DirInfoTimeout);
|
||||
/* convert millis to nanos */
|
||||
Result = FspMetaCacheCreate(
|
||||
FspFsvolDeviceDirInfoCacheCapacity, FspFsvolDeviceDirInfoCacheItemSizeMax, &DirInfoTimeout,
|
||||
@ -366,7 +366,7 @@ static NTSTATUS FspFsvolDeviceInit(PDEVICE_OBJECT DeviceObject)
|
||||
FsvolDeviceExtension->InitDoneDir = 1;
|
||||
|
||||
/* create our stream info meta cache */
|
||||
StreamInfoTimeout.QuadPart = FspTimeoutFromMillis(FsvolDeviceExtension->VolumeParams.FileInfoTimeout);
|
||||
StreamInfoTimeout.QuadPart = FspTimeoutFromMillis(FsvolDeviceExtension->VolumeParams.StreamInfoTimeout);
|
||||
/* convert millis to nanos */
|
||||
Result = FspMetaCacheCreate(
|
||||
FspFsvolDeviceStreamInfoCacheCapacity, FspFsvolDeviceStreamInfoCacheItemSizeMax, &StreamInfoTimeout,
|
||||
@ -873,7 +873,7 @@ VOID FspFsvolDeviceSetVolumeInfo(PDEVICE_OBJECT DeviceObject, const FSP_FSCTL_VO
|
||||
KeAcquireSpinLock(&FsvolDeviceExtension->InfoSpinLock, &Irql);
|
||||
FsvolDeviceExtension->VolumeInfo = VolumeInfoNp;
|
||||
FsvolDeviceExtension->InfoExpirationTime = FspExpirationTimeFromMillis(
|
||||
FsvolDeviceExtension->VolumeParams.FileInfoTimeout);
|
||||
FsvolDeviceExtension->VolumeParams.VolumeInfoTimeout);
|
||||
KeReleaseSpinLock(&FsvolDeviceExtension->InfoSpinLock, Irql);
|
||||
}
|
||||
|
||||
|
@ -551,7 +551,7 @@ static NTSTATUS FspFsvolQueryDirectoryRetry(
|
||||
FsvolDeviceExtension->VolumeParams.MaxComponentLength * sizeof(WCHAR);
|
||||
QueryDirectoryLengthMin = FSP_FSCTL_ALIGN_UP(QueryDirectoryLengthMin, 8);
|
||||
ASSERT(QueryDirectoryLengthMin < FspFsvolQueryDirectoryLengthMax);
|
||||
if (0 != FsvolDeviceExtension->VolumeParams.FileInfoTimeout &&
|
||||
if (0 != FsvolDeviceExtension->VolumeParams.DirInfoTimeout &&
|
||||
0 == FileDesc->DirectoryMarker.Buffer)
|
||||
{
|
||||
if (PatternIsFileName)
|
||||
|
@ -101,18 +101,26 @@ static NTSTATUS FspVolumeCreateNoLock(
|
||||
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension;
|
||||
|
||||
/* check parameters */
|
||||
if (PREFIXW_SIZE + sizeof(FSP_FSCTL_VOLUME_PARAMS) * sizeof(WCHAR) > FileObject->FileName.Length)
|
||||
if (PREFIXW_SIZE + sizeof(FSP_FSCTL_VOLUME_PARAMS_V0) * sizeof(WCHAR) > FileObject->FileName.Length)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
||||
/* copy the VolumeParams */
|
||||
for (USHORT Index = 0, Length = sizeof(FSP_FSCTL_VOLUME_PARAMS); Length > Index; Index++)
|
||||
{
|
||||
if (PREFIXW_SIZE / sizeof(WCHAR) + Index >= FileObject->FileName.Length / sizeof(WCHAR))
|
||||
break;
|
||||
|
||||
WCHAR Value = FileObject->FileName.Buffer[PREFIXW_SIZE / sizeof(WCHAR) + Index];
|
||||
if (0xF000 != (Value & 0xFF00))
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
((PUINT8)&VolumeParams)[Index] = Value & 0xFF;
|
||||
}
|
||||
|
||||
/* check VolumeParams size */
|
||||
if (0 != VolumeParams.Version &&
|
||||
PREFIXW_SIZE + VolumeParams.Version * sizeof(WCHAR) != FileObject->FileName.Length)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
||||
/* check the VolumeParams */
|
||||
if (0 == VolumeParams.SectorSize)
|
||||
VolumeParams.SectorSize = 512;
|
||||
@ -133,6 +141,28 @@ static NTSTATUS FspVolumeCreateNoLock(
|
||||
if (FspFsctlIrpCapacityMinimum > VolumeParams.IrpCapacity ||
|
||||
VolumeParams.IrpCapacity > FspFsctlIrpCapacityMaximum)
|
||||
VolumeParams.IrpCapacity = FspFsctlIrpCapacityDefault;
|
||||
if (sizeof(FSP_FSCTL_VOLUME_PARAMS_V0) >= VolumeParams.Version)
|
||||
{
|
||||
VolumeParams.VolumeInfoTimeout = VolumeParams.FileInfoTimeout;
|
||||
VolumeParams.DirInfoTimeout = VolumeParams.FileInfoTimeout;
|
||||
VolumeParams.SecurityTimeout = VolumeParams.FileInfoTimeout;
|
||||
VolumeParams.StreamInfoTimeout = VolumeParams.FileInfoTimeout;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!VolumeParams.VolumeInfoTimeoutValid)
|
||||
VolumeParams.VolumeInfoTimeout = VolumeParams.FileInfoTimeout;
|
||||
if (!VolumeParams.DirInfoTimeoutValid)
|
||||
VolumeParams.DirInfoTimeout = VolumeParams.FileInfoTimeout;
|
||||
if (!VolumeParams.SecurityTimeoutValid)
|
||||
VolumeParams.SecurityTimeout = VolumeParams.FileInfoTimeout;
|
||||
if (!VolumeParams.StreamInfoTimeoutValid)
|
||||
VolumeParams.StreamInfoTimeout = VolumeParams.FileInfoTimeout;
|
||||
}
|
||||
VolumeParams.VolumeInfoTimeoutValid = 1;
|
||||
VolumeParams.DirInfoTimeoutValid = 1;
|
||||
VolumeParams.SecurityTimeoutValid = 1;
|
||||
VolumeParams.StreamInfoTimeoutValid = 1;
|
||||
if (FILE_DEVICE_NETWORK_FILE_SYSTEM == FsctlDeviceObject->DeviceType)
|
||||
{
|
||||
VolumeParams.Prefix[sizeof VolumeParams.Prefix / sizeof(WCHAR) - 1] = L'\0';
|
||||
|
Reference in New Issue
Block a user