sys: check and remove volume prefix when mounted as a network file system

This commit is contained in:
Bill Zissimopoulos
2016-01-21 15:06:41 -08:00
parent e8eccef80a
commit e2e96322f3
6 changed files with 54 additions and 33 deletions

View File

@ -107,7 +107,7 @@ void create_test(void)
{
if (WinFspDiskTests)
create_dotest(MemfsDisk, 0);
if (0 && WinFspNetTests)
if (WinFspNetTests)
create_dotest(MemfsNet, L"\\\\memfs\\share");
}
@ -211,7 +211,7 @@ void create_sd_test(void)
{
if (WinFspDiskTests)
create_sd_dotest(MemfsDisk, 0);
if (0 && WinFspNetTests)
if (WinFspNetTests)
create_sd_dotest(MemfsNet, L"\\\\memfs\\share");
}
@ -279,7 +279,7 @@ void create_share_test(void)
{
if (WinFspDiskTests)
create_share_dotest(MemfsDisk, 0);
if (0 && WinFspNetTests)
if (WinFspNetTests)
create_share_dotest(MemfsNet, L"\\\\memfs\\share");
}

View File

@ -87,7 +87,7 @@ static unsigned __stdcall mount_volume_cancel_dotest_thread(void *FilePath)
return 0;
}
void mount_volume_cancel_dotest(PWSTR DeviceName)
void mount_volume_cancel_dotest(PWSTR DeviceName, PWSTR Prefix)
{
NTSTATUS Result;
BOOL Success;
@ -107,11 +107,12 @@ void mount_volume_cancel_dotest(PWSTR DeviceName)
ASSERT(0 == wcsncmp(L"\\Device\\Volume{", VolumeName, 15));
ASSERT(INVALID_HANDLE_VALUE != VolumeHandle);
StringCbPrintfW(FilePath, sizeof FilePath, L"\\\\?\\GLOBALROOT%s\\file0", VolumeName);
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\file0",
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : VolumeName);
Thread = (HANDLE)_beginthreadex(0, 0, mount_volume_cancel_dotest_thread, FilePath, 0, 0);
ASSERT(0 != Thread);
Sleep(1000); /* give some time to the thread to execute */
Sleep(0 == Prefix ? 1000 : 5000); /* give some time to the thread to execute */
Success = CloseHandle(VolumeHandle);
ASSERT(Success);
@ -126,9 +127,9 @@ void mount_volume_cancel_dotest(PWSTR DeviceName)
void mount_volume_cancel_test(void)
{
if (WinFspDiskTests)
mount_volume_cancel_dotest(L"WinFsp.Disk");
mount_volume_cancel_dotest(L"WinFsp.Disk", 0);
if (WinFspNetTests)
mount_volume_cancel_dotest(L"WinFsp.Net");
mount_volume_cancel_dotest(L"WinFsp.Net", L"\\\\winfsp-tests\\share");
}
static unsigned __stdcall mount_volume_transact_dotest_thread(void *FilePath)
@ -210,9 +211,7 @@ void mount_volume_transact_dotest(PWSTR DeviceName, PWSTR Prefix)
ASSERT(!Request->Req.Create.CaseSensitive);
ASSERT(0 == Request->FileName.Offset);
ASSERT((wcslen((PVOID)Request->Buffer) + 1) * sizeof(WCHAR) == Request->FileName.Size);
ASSERT(
0 == wcscmp((PVOID)Request->Buffer, L"\\file0") ||
0 == wcscmp((PVOID)Request->Buffer, FilePath + 1));
ASSERT(0 == wcscmp((PVOID)Request->Buffer, L"\\file0"));
ASSERT(FspFsctlTransactCanProduceResponse(Response, ResponseBufEnd));
@ -250,10 +249,7 @@ void mount_volume_transact_test(void)
if (WinFspDiskTests)
mount_volume_transact_dotest(L"WinFsp.Disk", 0);
if (WinFspNetTests)
{
mount_volume_transact_dotest(L"WinFsp.Net", 0);
mount_volume_transact_dotest(L"WinFsp.Net", L"\\\\winfsp-tests\\share");
}
}
void mount_tests(void)

View File

@ -34,7 +34,7 @@ static unsigned __stdcall timeout_pending_dotest_thread2(void *FilePath)
return 0;
}
void timeout_pending_dotest(PWSTR DeviceName)
void timeout_pending_dotest(PWSTR DeviceName, PWSTR Prefix)
{
NTSTATUS Result;
BOOL Success;
@ -45,6 +45,7 @@ void timeout_pending_dotest(PWSTR DeviceName)
HANDLE Thread;
DWORD ExitCode;
VolumeParams.TransactTimeout = 10000; /* allow for longer transact timeout to handle MUP redir */
VolumeParams.IrpTimeout = FspFsctlIrpTimeoutDebug;
VolumeParams.SectorSize = 16384;
VolumeParams.SerialNumber = 0x12345678;
@ -55,7 +56,8 @@ void timeout_pending_dotest(PWSTR DeviceName)
ASSERT(0 == wcsncmp(L"\\Device\\Volume{", VolumeName, 15));
ASSERT(INVALID_HANDLE_VALUE != VolumeHandle);
StringCbPrintfW(FilePath, sizeof FilePath, L"\\\\?\\GLOBALROOT%s\\file0", VolumeName);
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\file0",
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : VolumeName);
Thread = (HANDLE)_beginthreadex(0, 0, timeout_pending_dotest_thread, FilePath, 0, 0);
ASSERT(0 != Thread);
@ -126,9 +128,9 @@ void timeout_pending_dotest(PWSTR DeviceName)
void timeout_pending_test(void)
{
if (WinFspDiskTests)
timeout_pending_dotest(L"WinFsp.Disk");
timeout_pending_dotest(L"WinFsp.Disk", 0);
if (WinFspNetTests)
timeout_pending_dotest(L"WinFsp.Net");
timeout_pending_dotest(L"WinFsp.Net", L"\\\\winfsp-tests\\share");
}
static unsigned __stdcall timeout_transact_dotest_thread(void *FilePath)
@ -144,7 +146,7 @@ static unsigned __stdcall timeout_transact_dotest_thread(void *FilePath)
return 0;
}
void timeout_transact_dotest(PWSTR DeviceName)
void timeout_transact_dotest(PWSTR DeviceName, PWSTR Prefix)
{
NTSTATUS Result;
BOOL Success;
@ -155,7 +157,7 @@ void timeout_transact_dotest(PWSTR DeviceName)
HANDLE Thread;
DWORD ExitCode;
VolumeParams.TransactTimeout = 1000;
VolumeParams.TransactTimeout = 0 != Prefix ? 1000 : 5000;
VolumeParams.SectorSize = 16384;
VolumeParams.SerialNumber = 0x12345678;
wcscpy_s(VolumeParams.Prefix, sizeof VolumeParams.Prefix / sizeof(WCHAR), L"\\winfsp-tests\\share");
@ -181,7 +183,8 @@ void timeout_transact_dotest(PWSTR DeviceName)
ASSERT(STATUS_SUCCESS == Result);
ASSERT(0 == RequestBufSize);
StringCbPrintfW(FilePath, sizeof FilePath, L"\\\\?\\GLOBALROOT%s\\file0", VolumeName);
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\file0",
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : VolumeName);
Thread = (HANDLE)_beginthreadex(0, 0, timeout_transact_dotest_thread, FilePath, 0, 0);
ASSERT(0 != Thread);
@ -232,9 +235,9 @@ void timeout_transact_dotest(PWSTR DeviceName)
void timeout_transact_test(void)
{
if (WinFspDiskTests)
timeout_transact_dotest(L"WinFsp.Disk");
timeout_transact_dotest(L"WinFsp.Disk", 0);
if (WinFspNetTests)
timeout_transact_dotest(L"WinFsp.Net");
timeout_transact_dotest(L"WinFsp.Net", L"\\\\winfsp-tests\\share");
}
void timeout_tests(void)