mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 16:33:02 -05:00
tst: memfs: ReadDirectory fix with concurrent deletes
This commit is contained in:
parent
15c16d7070
commit
bdc02c8ab5
@ -358,14 +358,13 @@ exit /b 0
|
|||||||
|
|
||||||
:__ifstest-memfs
|
:__ifstest-memfs
|
||||||
set IfsTestMemfsExit=0
|
set IfsTestMemfsExit=0
|
||||||
M:
|
|
||||||
rem call :__ifstest %1 /d %2 /g Security /z /v
|
rem call :__ifstest %1 /d %2 /g Security /z /v
|
||||||
rem if !ERRORLEVEL! neq 0 set IfsTestMemfsExit=1
|
rem if !ERRORLEVEL! neq 0 set IfsTestMemfsExit=1
|
||||||
call :__ifstest %1 /d %2 /g OpenCreateGeneral -t FileOpenByIDTest -t OpenVolumeTest /z /v
|
call :__ifstest %1 /d %2 /g OpenCreateGeneral -t FileOpenByIDTest -t OpenVolumeTest /z /v
|
||||||
if !ERRORLEVEL! neq 0 set IfsTestMemfsExit=1
|
if !ERRORLEVEL! neq 0 set IfsTestMemfsExit=1
|
||||||
call :__ifstest %1 /d %2 /g OpenCreateParameters /z /v
|
call :__ifstest %1 /d %2 /g OpenCreateParameters /z /v
|
||||||
if !ERRORLEVEL! neq 0 set IfsTestMemfsExit=1
|
if !ERRORLEVEL! neq 0 set IfsTestMemfsExit=1
|
||||||
call :__ifstest %1 /d %2 /g CloseCleanupDelete -t UpdateOnCloseTest /z /v
|
call :__ifstest %1 /d %2 /g CloseCleanupDelete -t UpdateOnCloseTest -t TunnelingTest /z /v
|
||||||
if !ERRORLEVEL! neq 0 set IfsTestMemfsExit=1
|
if !ERRORLEVEL! neq 0 set IfsTestMemfsExit=1
|
||||||
call :__ifstest %1 /d %2 /g VolumeInformation /z /v
|
call :__ifstest %1 /d %2 /g VolumeInformation /z /v
|
||||||
if !ERRORLEVEL! neq 0 set IfsTestMemfsExit=1
|
if !ERRORLEVEL! neq 0 set IfsTestMemfsExit=1
|
||||||
|
@ -462,24 +462,18 @@ BOOLEAN MemfsFileNodeMapEnumerateChildren(MEMFS_FILE_NODE_MAP *FileNodeMap, MEMF
|
|||||||
BOOLEAN IsDirectoryChild;
|
BOOLEAN IsDirectoryChild;
|
||||||
if (0 != PrevFileName0)
|
if (0 != PrevFileName0)
|
||||||
{
|
{
|
||||||
WCHAR PrevFileName[MEMFS_MAX_PATH];
|
WCHAR PrevFileName[MEMFS_MAX_PATH + 256];
|
||||||
size_t Length0 = wcslen(FileNode->FileName);
|
size_t Length0 = wcslen(FileNode->FileName);
|
||||||
size_t Length1 = 1 != Length0 || L'\\' != FileNode->FileName[0];
|
size_t Length1 = 1 != Length0 || L'\\' != FileNode->FileName[0];
|
||||||
size_t Length2 = wcslen(PrevFileName0);
|
size_t Length2 = wcslen(PrevFileName0);
|
||||||
if (MEMFS_MAX_PATH <= Length0 + Length1 + Length2)
|
assert(MEMFS_MAX_PATH + 256 > Length0 + Length1 + Length2);
|
||||||
/* fall back to linear scan! */
|
|
||||||
goto fallback;
|
|
||||||
memcpy(PrevFileName, FileNode->FileName, Length0 * sizeof(WCHAR));
|
memcpy(PrevFileName, FileNode->FileName, Length0 * sizeof(WCHAR));
|
||||||
memcpy(PrevFileName + Length0, L"\\", Length1 * sizeof(WCHAR));
|
memcpy(PrevFileName + Length0, L"\\", Length1 * sizeof(WCHAR));
|
||||||
memcpy(PrevFileName + Length0 + Length1, PrevFileName0, Length2 * sizeof(WCHAR));
|
memcpy(PrevFileName + Length0 + Length1, PrevFileName0, Length2 * sizeof(WCHAR));
|
||||||
PrevFileName[Length0 + Length1 + Length2] = L'\0';
|
PrevFileName[Length0 + Length1 + Length2] = L'\0';
|
||||||
iter = FileNodeMap->find(PrevFileName);
|
iter = FileNodeMap->upper_bound(PrevFileName);
|
||||||
if (FileNodeMap->end() == iter)
|
|
||||||
/* fall back to linear scan! */
|
|
||||||
goto fallback;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fallback:
|
|
||||||
iter = FileNodeMap->upper_bound(FileNode->FileName);
|
iter = FileNodeMap->upper_bound(FileNode->FileName);
|
||||||
for (; FileNodeMap->end() != iter; ++iter)
|
for (; FileNodeMap->end() != iter; ++iter)
|
||||||
{
|
{
|
||||||
@ -1452,6 +1446,7 @@ static NTSTATUS ReadDirectory(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
FspFileSystemGetOperationContext()->Request->Req.QueryDirectory.UserContext2;
|
FspFileSystemGetOperationContext()->Request->Req.QueryDirectory.UserContext2;
|
||||||
MEMFS_FILE_NODE *ParentNode;
|
MEMFS_FILE_NODE *ParentNode;
|
||||||
MEMFS_READ_DIRECTORY_CONTEXT Context;
|
MEMFS_READ_DIRECTORY_CONTEXT Context;
|
||||||
|
PWSTR PrevFileName = 0;
|
||||||
NTSTATUS Result;
|
NTSTATUS Result;
|
||||||
|
|
||||||
Context.Buffer = Buffer;
|
Context.Buffer = Buffer;
|
||||||
@ -1484,7 +1479,13 @@ static NTSTATUS ReadDirectory(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MemfsFileNodeMapEnumerateChildren(Memfs->FileNodeMap, FileNode, MemfsDirDescGetFileName(DirDesc, Offset),
|
if (0 != Context.Offset && !Context.OffsetFound)
|
||||||
|
{
|
||||||
|
PrevFileName = MemfsDirDescGetFileName(DirDesc, Offset);
|
||||||
|
Context.OffsetFound = 0 != PrevFileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MemfsFileNodeMapEnumerateChildren(Memfs->FileNodeMap, FileNode, PrevFileName,
|
||||||
ReadDirectoryEnumFn, &Context))
|
ReadDirectoryEnumFn, &Context))
|
||||||
FspFileSystemAddDirInfo(0, Buffer, Length, PBytesTransferred);
|
FspFileSystemAddDirInfo(0, Buffer, Length, PBytesTransferred);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user