mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 08:23:05 -05:00
memfs: memfs-main.c
This commit is contained in:
parent
9f6bbe4a63
commit
2c7ce4a3da
@ -19,6 +19,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "winfsp-tests", "testing\win
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "memfs", "testing\memfs.vcxproj", "{AA7190E8-877F-4827-8CDD-E0D85F83C8C1}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{C85C26BA-8C22-4D30-83DA-46C3548E6332} = {C85C26BA-8C22-4D30-83DA-46C3548E6332}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -54,14 +54,14 @@ static void usage(void)
|
||||
"options:\n"
|
||||
" -t FileInfoTimeout\n"
|
||||
" -n MaxFileNodes\n"
|
||||
" -s MaxFileSize\n";
|
||||
" -s MaxFileSize\n"
|
||||
" -u \\\\Volume\\Prefix\n";
|
||||
|
||||
warn(usage, PROGNAME);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
static inline
|
||||
ULONG argtol(wchar_t **argp, ULONG deflt)
|
||||
static ULONG argtol(wchar_t **argp, ULONG deflt)
|
||||
{
|
||||
if (0 == argp[0])
|
||||
usage();
|
||||
@ -71,6 +71,14 @@ ULONG argtol(wchar_t **argp, ULONG deflt)
|
||||
return 0 != ul ? ul : deflt;
|
||||
}
|
||||
|
||||
static wchar_t *argtos(wchar_t **argp)
|
||||
{
|
||||
if (0 == argp[0])
|
||||
usage();
|
||||
|
||||
return argp[0];
|
||||
}
|
||||
|
||||
static HANDLE MainEvent;
|
||||
|
||||
static BOOL WINAPI ConsoleCtrlHandler(DWORD CtrlType)
|
||||
@ -89,6 +97,7 @@ int wmain(int argc, wchar_t **argv)
|
||||
ULONG MaxFileNodes = 1024;
|
||||
ULONG MaxFileSize = 1024 * 1024;
|
||||
PWSTR MountPoint = 0;
|
||||
PWSTR VolumePrefix = 0;
|
||||
|
||||
for (argp = argv + 1; 0 != argp[0]; argp++)
|
||||
{
|
||||
@ -105,6 +114,10 @@ int wmain(int argc, wchar_t **argv)
|
||||
case L't':
|
||||
FileInfoTimeout = argtol(++argp, FileInfoTimeout);
|
||||
break;
|
||||
case L'v':
|
||||
VolumePrefix = argtos(++argp);
|
||||
Flags = MemfsNet;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
break;
|
||||
@ -119,7 +132,7 @@ int wmain(int argc, wchar_t **argv)
|
||||
if (0 == MainEvent)
|
||||
fail("error: cannot create MainEvent");
|
||||
|
||||
Result = MemfsCreate(Flags, FileInfoTimeout, MaxFileNodes, MaxFileSize, &Memfs);
|
||||
Result = MemfsCreate(Flags, FileInfoTimeout, MaxFileNodes, MaxFileSize, VolumePrefix, &Memfs);
|
||||
if (!NT_SUCCESS(Result))
|
||||
fail("error: cannot create MEMFS");
|
||||
Result = MemfsStart(Memfs);
|
||||
@ -129,8 +142,8 @@ int wmain(int argc, wchar_t **argv)
|
||||
if (!NT_SUCCESS(Result))
|
||||
fail("error: cannot mount MEMFS");
|
||||
|
||||
warn("%s -t %ld -n %ld -s %ld %s",
|
||||
PROGNAME, FileInfoTimeout, MaxFileNodes, MaxFileSize, MountPoint);
|
||||
warn("%s -t %ld -n %ld -s %ld -v %s %s",
|
||||
PROGNAME, FileInfoTimeout, MaxFileNodes, MaxFileSize, VolumePrefix, MountPoint);
|
||||
SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE);
|
||||
if (WAIT_OBJECT_0 != WaitForSingleObject(MainEvent, INFINITE))
|
||||
fail("error: cannot wait on MainEvent");
|
||||
|
@ -838,6 +838,7 @@ static VOID MemfsLeaveOperation(FSP_FILE_SYSTEM *FileSystem,
|
||||
|
||||
NTSTATUS MemfsCreate(ULONG Flags, ULONG FileInfoTimeout,
|
||||
ULONG MaxFileNodes, ULONG MaxFileSize,
|
||||
PWSTR VolumePrefix,
|
||||
MEMFS **PMemfs)
|
||||
{
|
||||
NTSTATUS Result;
|
||||
@ -877,7 +878,8 @@ NTSTATUS MemfsCreate(ULONG Flags, ULONG FileInfoTimeout,
|
||||
VolumeParams.CasePreservedNames = 1;
|
||||
VolumeParams.UnicodeOnDisk = 1;
|
||||
VolumeParams.PersistentAcls = 1;
|
||||
wcscpy_s(VolumeParams.Prefix, sizeof VolumeParams.Prefix / sizeof(WCHAR), L"\\memfs\\share");
|
||||
if (0 != VolumePrefix)
|
||||
wcscpy_s(VolumeParams.Prefix, sizeof VolumeParams.Prefix / sizeof(WCHAR), VolumePrefix);
|
||||
|
||||
Result = FspFileSystemCreate(DevicePath, &VolumeParams, &MemfsInterface, &Memfs->FileSystem);
|
||||
if (!NT_SUCCESS(Result))
|
||||
|
@ -23,6 +23,7 @@ enum
|
||||
|
||||
NTSTATUS MemfsCreate(ULONG Flags, ULONG FileInfoTimeout,
|
||||
ULONG MaxFileNodes, ULONG MaxFileSize,
|
||||
PWSTR VolumePrefix,
|
||||
MEMFS **PMemfs);
|
||||
VOID MemfsDelete(MEMFS *Memfs);
|
||||
NTSTATUS MemfsStart(MEMFS *Memfs);
|
||||
|
@ -14,7 +14,8 @@ void *memfs_start_ex(ULONG Flags, ULONG FileInfoTimeout)
|
||||
MEMFS *Memfs;
|
||||
NTSTATUS Result;
|
||||
|
||||
Result = MemfsCreate(Flags, FileInfoTimeout, 1024, 1024 * 1024, &Memfs);
|
||||
Result = MemfsCreate(Flags, FileInfoTimeout, 1024, 1024 * 1024,
|
||||
MemfsNet == Flags ? L"\\memfs\\share" : 0, &Memfs);
|
||||
ASSERT(NT_SUCCESS(Result));
|
||||
ASSERT(0 != Memfs);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user