memfs: add -d (debug) switch

This commit is contained in:
Bill Zissimopoulos 2016-05-23 13:47:07 -07:00
parent b004268583
commit 1505b1f368

View File

@ -30,13 +30,14 @@
static ULONG wcstol_deflt(wchar_t *w, ULONG deflt) static ULONG wcstol_deflt(wchar_t *w, ULONG deflt)
{ {
wchar_t *endp; wchar_t *endp;
ULONG ul = wcstol(w, &endp, 10); ULONG ul = wcstol(w, &endp, 0);
return L'\0' != w[0] && L'\0' == *endp ? ul : deflt; return L'\0' != w[0] && L'\0' == *endp ? ul : deflt;
} }
NTSTATUS SvcStart(FSP_SERVICE *Service, ULONG argc, PWSTR *argv) NTSTATUS SvcStart(FSP_SERVICE *Service, ULONG argc, PWSTR *argv)
{ {
wchar_t **argp, **arge; wchar_t **argp, **arge;
ULONG DebugFlags = 0;
ULONG Flags = MemfsDisk; ULONG Flags = MemfsDisk;
ULONG FileInfoTimeout = INFINITE; ULONG FileInfoTimeout = INFINITE;
ULONG MaxFileNodes = 1024; ULONG MaxFileNodes = 1024;
@ -55,6 +56,9 @@ NTSTATUS SvcStart(FSP_SERVICE *Service, ULONG argc, PWSTR *argv)
{ {
case L'?': case L'?':
goto usage; goto usage;
case L'd':
argtol(DebugFlags);
break;
case L'm': case L'm':
argtos(MountPoint); argtos(MountPoint);
break; break;
@ -93,6 +97,8 @@ NTSTATUS SvcStart(FSP_SERVICE *Service, ULONG argc, PWSTR *argv)
goto exit; goto exit;
} }
FspFileSystemSetDebugLog(MemfsFileSystem(Memfs), DebugFlags);
if (0 != MountPoint && L'\0' != MountPoint[0]) if (0 != MountPoint && L'\0' != MountPoint[0])
{ {
Result = FspFileSystemSetMountPoint(MemfsFileSystem(Memfs), Result = FspFileSystemSetMountPoint(MemfsFileSystem(Memfs),
@ -133,6 +139,7 @@ usage:
"usage: %s OPTIONS\n" "usage: %s OPTIONS\n"
"\n" "\n"
"options:\n" "options:\n"
" -d DebugFlags [-1: enable all debug logs]\n"
" -t FileInfoTimeout [millis]\n" " -t FileInfoTimeout [millis]\n"
" -n MaxFileNodes\n" " -n MaxFileNodes\n"
" -s MaxFileSize [bytes]\n" " -s MaxFileSize [bytes]\n"