mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 08:23:05 -05:00
dll: FspFileSystemSetMountPoint: testing
This commit is contained in:
parent
82a9c8e80f
commit
cb17b7e2e0
@ -855,9 +855,13 @@ FSP_API VOID FspFileSystemDelete(FSP_FILE_SYSTEM *FileSystem);
|
|||||||
/**
|
/**
|
||||||
* Set the mount point for a file system.
|
* Set the mount point for a file system.
|
||||||
*
|
*
|
||||||
* This function currently only supports drive letters (X:) as mount points. Refer to the
|
* This function supports drive letters (X:) or directories as mount points:
|
||||||
* documentation of the DefineDosDevice Windows API to better understand how drive letters are
|
* <ul>
|
||||||
* created.
|
* <li>Drive letters: Refer to the documentation of the DefineDosDevice Windows API
|
||||||
|
* to better understand how they are created.</li>
|
||||||
|
* <li>Directories: They can be used as mount points for disk based file systems. They cannot
|
||||||
|
* be used for network file systems. This is a limitation that Windows imposes on junctions.</li>
|
||||||
|
* </ul>
|
||||||
*
|
*
|
||||||
* @param FileSystem
|
* @param FileSystem
|
||||||
* The file system object.
|
* The file system object.
|
||||||
|
18
src/dll/fs.c
18
src/dll/fs.c
@ -126,10 +126,24 @@ static NTSTATUS FspFileSystemSetMountPoint_CreateDirectory(PWSTR MountPoint, PWS
|
|||||||
NTSTATUS Result;
|
NTSTATUS Result;
|
||||||
HANDLE DirHandle;
|
HANDLE DirHandle;
|
||||||
BOOL Success;
|
BOOL Success;
|
||||||
DWORD Bytes;
|
DWORD Backslashes, Bytes;
|
||||||
USHORT VolumeNameLength, BackslashLength, ReparseDataLength;
|
USHORT VolumeNameLength, BackslashLength, ReparseDataLength;
|
||||||
PREPARSE_DATA_BUFFER ReparseData = 0;
|
PREPARSE_DATA_BUFFER ReparseData = 0;
|
||||||
PWSTR PathBuffer;
|
PWSTR P, PathBuffer;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Windows does not allow mount points (junctions) to point to network file systems.
|
||||||
|
*
|
||||||
|
* Count how many backslashes our VolumeName. If it is 3 or more this is a network
|
||||||
|
* file system. Preemptively return STATUS_NETWORK_ACCESS_DENIED.
|
||||||
|
*/
|
||||||
|
for (P = VolumeName, Backslashes = 0; *P; P++)
|
||||||
|
if (L'\\' == *P)
|
||||||
|
if (3 == ++Backslashes)
|
||||||
|
{
|
||||||
|
Result = STATUS_NETWORK_ACCESS_DENIED;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
if (!CreateDirectoryW(MountPoint, 0))
|
if (!CreateDirectoryW(MountPoint, 0))
|
||||||
{
|
{
|
||||||
|
@ -78,6 +78,12 @@ if errorlevel 1 goto fail
|
|||||||
echo winfsp-tests-x64 --case-randomize
|
echo winfsp-tests-x64 --case-randomize
|
||||||
winfsp-tests-x64 --case-randomize
|
winfsp-tests-x64 --case-randomize
|
||||||
if errorlevel 1 goto fail
|
if errorlevel 1 goto fail
|
||||||
|
echo winfsp-tests-x64 --mountpoint=X:
|
||||||
|
winfsp-tests-x64 --mountpoint=X:
|
||||||
|
if errorlevel 1 goto fail
|
||||||
|
echo winfsp-tests-x64 --mountpoint=mymnt
|
||||||
|
winfsp-tests-x64 --mountpoint=mymnt
|
||||||
|
if errorlevel 1 goto fail
|
||||||
exit /b 0
|
exit /b 0
|
||||||
|
|
||||||
:winfsp-tests-x86
|
:winfsp-tests-x86
|
||||||
@ -87,6 +93,12 @@ if errorlevel 1 goto fail
|
|||||||
echo winfsp-tests-x86 --case-randomize
|
echo winfsp-tests-x86 --case-randomize
|
||||||
winfsp-tests-x86 --case-randomize
|
winfsp-tests-x86 --case-randomize
|
||||||
if errorlevel 1 goto fail
|
if errorlevel 1 goto fail
|
||||||
|
echo winfsp-tests-x86 --mountpoint=X:
|
||||||
|
winfsp-tests-x86 --mountpoint=X:
|
||||||
|
if errorlevel 1 goto fail
|
||||||
|
echo winfsp-tests-x86 --mountpoint=mymnt
|
||||||
|
winfsp-tests-x86 --mountpoint=mymnt
|
||||||
|
if errorlevel 1 goto fail
|
||||||
exit /b 0
|
exit /b 0
|
||||||
|
|
||||||
:fsx-memfs-x64
|
:fsx-memfs-x64
|
||||||
|
@ -62,10 +62,13 @@ void create_dotest(ULONG Flags, PWSTR Prefix)
|
|||||||
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\\\\\file0",
|
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\\\\\file0",
|
||||||
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
|
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
|
||||||
|
|
||||||
Handle = CreateFileW(FilePath,
|
if (0 == OptMountPoint)
|
||||||
GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
|
{
|
||||||
ASSERT(INVALID_HANDLE_VALUE == Handle);
|
Handle = CreateFileW(FilePath,
|
||||||
ASSERT(ERROR_INVALID_NAME == GetLastError());
|
GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
|
||||||
|
ASSERT(INVALID_HANDLE_VALUE == Handle);
|
||||||
|
ASSERT(ERROR_INVALID_NAME == GetLastError());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* invalid chars (wildcards) not allowed */
|
/* invalid chars (wildcards) not allowed */
|
||||||
@ -146,10 +149,13 @@ void create_dotest(ULONG Flags, PWSTR Prefix)
|
|||||||
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\file0\\",
|
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\file0\\",
|
||||||
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
|
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
|
||||||
|
|
||||||
Handle = CreateFileW(FilePath,
|
if (0 == OptMountPoint)
|
||||||
GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
|
{
|
||||||
ASSERT(INVALID_HANDLE_VALUE == Handle);
|
Handle = CreateFileW(FilePath,
|
||||||
ASSERT(ERROR_INVALID_NAME == GetLastError());
|
GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
|
||||||
|
ASSERT(INVALID_HANDLE_VALUE == Handle);
|
||||||
|
ASSERT(ERROR_INVALID_NAME == GetLastError());
|
||||||
|
}
|
||||||
|
|
||||||
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\dir1\\\\",
|
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\dir1\\\\",
|
||||||
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
|
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include "winfsp-tests.h"
|
#include "winfsp-tests.h"
|
||||||
|
|
||||||
|
int memfs_running;
|
||||||
|
|
||||||
void *memfs_start_ex(ULONG Flags, ULONG FileInfoTimeout)
|
void *memfs_start_ex(ULONG Flags, ULONG FileInfoTimeout)
|
||||||
{
|
{
|
||||||
if (-1 == Flags)
|
if (-1 == Flags)
|
||||||
@ -24,9 +26,17 @@ void *memfs_start_ex(ULONG Flags, ULONG FileInfoTimeout)
|
|||||||
ASSERT(NT_SUCCESS(Result));
|
ASSERT(NT_SUCCESS(Result));
|
||||||
ASSERT(0 != Memfs);
|
ASSERT(0 != Memfs);
|
||||||
|
|
||||||
|
if (OptMountPoint)
|
||||||
|
{
|
||||||
|
Result = FspFileSystemSetMountPoint(MemfsFileSystem(Memfs), OptMountPoint);
|
||||||
|
ASSERT(NT_SUCCESS(Result));
|
||||||
|
}
|
||||||
|
|
||||||
Result = MemfsStart(Memfs);
|
Result = MemfsStart(Memfs);
|
||||||
ASSERT(NT_SUCCESS(Result));
|
ASSERT(NT_SUCCESS(Result));
|
||||||
|
|
||||||
|
memfs_running = 1;
|
||||||
|
|
||||||
return Memfs;
|
return Memfs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,6 +50,8 @@ void memfs_stop(void *data)
|
|||||||
if (0 == data)
|
if (0 == data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
memfs_running = 0;
|
||||||
|
|
||||||
MEMFS *Memfs = data;
|
MEMFS *Memfs = data;
|
||||||
|
|
||||||
MemfsStop(Memfs);
|
MemfsStop(Memfs);
|
||||||
|
@ -434,7 +434,7 @@ static void reparse_symlink_relative_dotest(ULONG Flags, PWSTR Prefix, ULONG Fil
|
|||||||
{
|
{
|
||||||
ASSERT(ERROR_PRIVILEGE_NOT_HELD == GetLastError());
|
ASSERT(ERROR_PRIVILEGE_NOT_HELD == GetLastError());
|
||||||
FspDebugLog(__FUNCTION__ ": need SE_CREATE_SYMBOLIC_LINK_PRIVILEGE\n");
|
FspDebugLog(__FUNCTION__ ": need SE_CREATE_SYMBOLIC_LINK_PRIVILEGE\n");
|
||||||
return;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
my_mkdir(L"\\1");
|
my_mkdir(L"\\1");
|
||||||
@ -491,6 +491,7 @@ static void reparse_symlink_relative_dotest(ULONG Flags, PWSTR Prefix, ULONG Fil
|
|||||||
my_rmdir(L"\\1\\1.1");
|
my_rmdir(L"\\1\\1.1");
|
||||||
my_rmdir(L"\\1");
|
my_rmdir(L"\\1");
|
||||||
|
|
||||||
|
exit:
|
||||||
memfs_stop(memfs);
|
memfs_stop(memfs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ int WinFspNetTests = 1;
|
|||||||
|
|
||||||
BOOLEAN OptCaseInsensitive = FALSE;
|
BOOLEAN OptCaseInsensitive = FALSE;
|
||||||
BOOLEAN OptCaseRandomize = FALSE;
|
BOOLEAN OptCaseRandomize = FALSE;
|
||||||
|
WCHAR OptMountPointBuf[MAX_PATH], *OptMountPoint;
|
||||||
|
|
||||||
int mywcscmp(PWSTR a, int alen, PWSTR b, int blen)
|
int mywcscmp(PWSTR a, int alen, PWSTR b, int blen)
|
||||||
{
|
{
|
||||||
@ -57,12 +58,16 @@ HANDLE HookCreateFileW(
|
|||||||
HANDLE hTemplateFile)
|
HANDLE hTemplateFile)
|
||||||
{
|
{
|
||||||
static WCHAR DevicePrefix[] =
|
static WCHAR DevicePrefix[] =
|
||||||
L"\\\\?\\GLOBALROOT\\Device\\Volume{01234567-0123-0123-0101-010101010101}\\";
|
L"\\\\?\\GLOBALROOT\\Device\\Volume{01234567-0123-0123-0101-010101010101}";
|
||||||
|
static WCHAR MemfsSharePrefix[] =
|
||||||
|
L"\\\\memfs\\share";
|
||||||
static const TogglePercent = 25;
|
static const TogglePercent = 25;
|
||||||
WCHAR FileNameBuf[1024];
|
WCHAR FileNameBuf[1024];
|
||||||
PWSTR P, EndP;
|
PWSTR P, EndP;
|
||||||
|
size_t L1, L2;
|
||||||
|
|
||||||
wcscpy_s(FileNameBuf, sizeof FileNameBuf / sizeof(WCHAR), lpFileName);
|
wcscpy_s(FileNameBuf, sizeof FileNameBuf / sizeof(WCHAR), lpFileName);
|
||||||
|
|
||||||
if (OptCaseRandomize)
|
if (OptCaseRandomize)
|
||||||
{
|
{
|
||||||
if (L'\\' == FileNameBuf[0] && L'\\' == FileNameBuf[1] &&
|
if (L'\\' == FileNameBuf[0] && L'\\' == FileNameBuf[1] &&
|
||||||
@ -83,6 +88,37 @@ HANDLE HookCreateFileW(
|
|||||||
*P = togglealpha(*P);
|
*P = togglealpha(*P);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (OptMountPoint && memfs_running)
|
||||||
|
{
|
||||||
|
if (L'\\' == FileNameBuf[0] && L'\\' == FileNameBuf[1] &&
|
||||||
|
L'?' == FileNameBuf[2] && L'\\' == FileNameBuf[3] &&
|
||||||
|
testalpha(FileNameBuf[4]) && L':' == FileNameBuf[5] && L'\\' == FileNameBuf[6])
|
||||||
|
;
|
||||||
|
else if (0 == wcsncmp(FileNameBuf, DevicePrefix, wcschr(DevicePrefix, L'{') - DevicePrefix))
|
||||||
|
{
|
||||||
|
P = FileNameBuf + wcslen(DevicePrefix);
|
||||||
|
L1 = wcslen(P) + 1;
|
||||||
|
L2 = wcslen(OptMountPoint);
|
||||||
|
memmove(FileNameBuf + 1024 - L1, P, L1 * sizeof(WCHAR));
|
||||||
|
memmove(FileNameBuf, OptMountPoint, L2 * sizeof(WCHAR));
|
||||||
|
memmove(FileNameBuf + L2, P, L1 * sizeof(WCHAR));
|
||||||
|
}
|
||||||
|
else if (0 == mywcscmp(
|
||||||
|
FileNameBuf, (int)wcslen(MemfsSharePrefix), MemfsSharePrefix, (int)wcslen(MemfsSharePrefix)))
|
||||||
|
{
|
||||||
|
P = FileNameBuf + wcslen(MemfsSharePrefix);
|
||||||
|
L1 = wcslen(P) + 1;
|
||||||
|
L2 = wcslen(OptMountPoint);
|
||||||
|
memmove(FileNameBuf + 1024 - L1, P, L1 * sizeof(WCHAR));
|
||||||
|
memmove(FileNameBuf, OptMountPoint, L2 * sizeof(WCHAR));
|
||||||
|
memmove(FileNameBuf + L2, P, L1 * sizeof(WCHAR));
|
||||||
|
}
|
||||||
|
else if (testalpha(FileNameBuf[0]) && L':' == FileNameBuf[1] && L'\\' == FileNameBuf[2])
|
||||||
|
;
|
||||||
|
else
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
HANDLE h = CreateFileW(
|
HANDLE h = CreateFileW(
|
||||||
FileNameBuf,
|
FileNameBuf,
|
||||||
dwDesiredAccess,
|
dwDesiredAccess,
|
||||||
@ -149,6 +185,21 @@ int main(int argc, char *argv[])
|
|||||||
OptCaseInsensitive = TRUE;
|
OptCaseInsensitive = TRUE;
|
||||||
rmarg(argv, argc, argi);
|
rmarg(argv, argc, argi);
|
||||||
}
|
}
|
||||||
|
else if (0 == strncmp("--mountpoint=", a, sizeof "--mountpoint=" - 1))
|
||||||
|
{
|
||||||
|
if (0 != MultiByteToWideChar(CP_UTF8, 0,
|
||||||
|
a + sizeof "--mountpoint=" - 1, -1, OptMountPointBuf, MAX_PATH))
|
||||||
|
{
|
||||||
|
OptMountPoint = OptMountPointBuf;
|
||||||
|
rmarg(argv, argc, argi);
|
||||||
|
|
||||||
|
NtfsTests = 0;
|
||||||
|
if (!(testalpha(OptMountPoint[0]) &&
|
||||||
|
L':' == OptMountPoint[1] &&
|
||||||
|
L'\0' == OptMountPoint[2]))
|
||||||
|
WinFspNetTests = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,13 +5,6 @@ void *memfs_start(ULONG Flags);
|
|||||||
void memfs_stop(void *data);
|
void memfs_stop(void *data);
|
||||||
PWSTR memfs_volumename(void *data);
|
PWSTR memfs_volumename(void *data);
|
||||||
|
|
||||||
extern int NtfsTests;
|
|
||||||
extern int WinFspDiskTests;
|
|
||||||
extern int WinFspNetTests;
|
|
||||||
|
|
||||||
extern BOOLEAN OptCaseInsensitive;
|
|
||||||
extern BOOLEAN OptCaseRandomize;
|
|
||||||
|
|
||||||
int mywcscmp(PWSTR a, int alen, PWSTR b, int blen);
|
int mywcscmp(PWSTR a, int alen, PWSTR b, int blen);
|
||||||
|
|
||||||
#define CreateFileW HookCreateFileW
|
#define CreateFileW HookCreateFileW
|
||||||
@ -23,3 +16,13 @@ HANDLE HookCreateFileW(
|
|||||||
DWORD dwCreationDisposition,
|
DWORD dwCreationDisposition,
|
||||||
DWORD dwFlagsAndAttributes,
|
DWORD dwFlagsAndAttributes,
|
||||||
HANDLE hTemplateFile);
|
HANDLE hTemplateFile);
|
||||||
|
|
||||||
|
extern int NtfsTests;
|
||||||
|
extern int WinFspDiskTests;
|
||||||
|
extern int WinFspNetTests;
|
||||||
|
|
||||||
|
extern BOOLEAN OptCaseInsensitive;
|
||||||
|
extern BOOLEAN OptCaseRandomize;
|
||||||
|
extern WCHAR OptMountPointBuf[], *OptMountPoint;
|
||||||
|
|
||||||
|
extern int memfs_running;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user