- From 5a7044ec5b517a74f52c2cb442a6b67d9680f23a Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Sat, 31 Aug 2024 13:47:54 +0200
- Subject: [PATCH 1/5] daemon: nfsd_debug should support --help+/? and reject
- unknown options
- nfsd_debug.exe should support --help and /? options, and reject
- unknown options.
- Reported-by: Martin Wege <martin.l.wege@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/nfs41_daemon.c | 74 ++++++++++++++++++++++++-------------------
- 1 file changed, 41 insertions(+), 33 deletions(-)
- diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
- index 8f30607..8904afc 100644
- --- a/daemon/nfs41_daemon.c
- +++ b/daemon/nfs41_daemon.c
- @@ -259,18 +259,20 @@ static bool_t check_for_files()
- return TRUE;
- }
- -static void PrintUsage()
- +static void PrintUsage(const wchar_t *argv0)
- {
- - (void)fprintf(stderr, "Usage: nfsd.exe -d <debug_level> "
- - "--noldap "
- - "--uid <non-zero value> "
- - "--gid <non-zero value> "
- - "--numworkerthreads <value-between 16 and %d> "
- + (void)fprintf(stderr, "Usage: %S [options]\n"
- + "\t-h, --help, /? help\n"
- + "\t-d <debug_level>\n"
- + "\t--noldap\n"
- + "\t--uid <non-zero value>\n"
- + "\t--gid <non-zero value>\n"
- + "\t--numworkerthreads <value-between 16 and %d>\n"
- #ifdef _DEBUG
- - "--crtdbgmem <'allocmem'|'leakcheck'|'delayfree', "
- - "'all', 'none' or 'default'> "
- + "\t--crtdbgmem <'allocmem'|'leakcheck'|'delayfree',\n"
- + "\t\t'all', 'none' or 'default'>\n"
- #endif /* _DEBUG */
- - "\n", MAX_NUM_THREADS);
- + , argv0, MAX_NUM_THREADS);
- }
- static
- @@ -285,15 +287,16 @@ bool_t parse_cmdlineargs(int argc, wchar_t *argv[], nfsd_args *out)
- /* parse command line */
- for (i = 1; i < argc; i++) {
- if (argv[i][0] == L'-') {
- - if (!wcscmp(argv[i], L"-h")) { /* help */
- - PrintUsage();
- + if ((!wcscmp(argv[i], L"-h")) ||
- + (!wcscmp(argv[i], L"--help"))) { /* help */
- + PrintUsage(argv[0]);
- return FALSE;
- }
- else if (!wcscmp(argv[i], L"-d")) { /* debug level */
- ++i;
- if (i >= argc) {
- - fprintf(stderr, "Missing debug level value\n");
- - PrintUsage();
- + (void)fprintf(stderr,
- + "%S: Missing debug level value\n", argv[0]);
- return FALSE;
- }
- out->debug_level = wcstol(argv[i], NULL, 0);
- @@ -303,8 +306,9 @@ bool_t parse_cmdlineargs(int argc, wchar_t *argv[], nfsd_args *out)
- ++i;
- const wchar_t *memdbgoptions = argv[i];
- if (i >= argc) {
- - fprintf(stderr, "Missing options\n");
- - PrintUsage();
- + (void)fprintf(stderr,
- + "%S: Missing options for --crtdbgmem\n",
- + argv[0]);
- return FALSE;
- }
- @@ -341,22 +345,15 @@ bool_t parse_cmdlineargs(int argc, wchar_t *argv[], nfsd_args *out)
- else if (!wcscmp(argv[i], L"--uid")) { /* no LDAP, setting default uid */
- ++i;
- if (i >= argc) {
- - fprintf(stderr, "Missing uid value\n");
- - PrintUsage();
- + (void)fprintf(stderr, "%S: Missing uid value\n", argv[0]);
- return FALSE;
- }
- nfs41_dg.default_uid = wcstol(argv[i], NULL, 0);
- - if (!nfs41_dg.default_uid) {
- - fprintf(stderr, "Invalid (or missing) anonymous uid value of %d\n",
- - nfs41_dg.default_uid);
- - return FALSE;
- - }
- }
- else if (!wcscmp(argv[i], L"--gid")) { /* no LDAP, setting default gid */
- ++i;
- if (i >= argc) {
- - fprintf(stderr, "Missing gid value\n");
- - PrintUsage();
- + (void)fprintf(stderr, "%S: Missing gid value\n", argv[0]);
- return FALSE;
- }
- nfs41_dg.default_gid = wcstol(argv[i], NULL, 0);
- @@ -364,27 +361,38 @@ bool_t parse_cmdlineargs(int argc, wchar_t *argv[], nfsd_args *out)
- else if (!wcscmp(argv[i], L"--numworkerthreads")) {
- ++i;
- if (i >= argc) {
- - fprintf(stderr, "Missing value for num_worker_threads\n");
- - PrintUsage();
- + (void)fprintf(stderr,
- + "%S: Missing value for num_worker_threads\n",
- + argv[0]);
- return FALSE;
- }
- nfs41_dg.num_worker_threads = wcstol(argv[i], NULL, 0);
- if (nfs41_dg.num_worker_threads < 16) {
- - fprintf(stderr, "--numworkerthreads requires at least 16 worker threads\n");
- - PrintUsage();
- + (void)fprintf(stderr,
- + "%S: --numworkerthreads requires at least "
- + "16 worker threads\n", argv[0]);
- return FALSE;
- }
- if (nfs41_dg.num_worker_threads >= MAX_NUM_THREADS) {
- - fprintf(stderr,
- + (void)fprintf(stderr, "%S: "
- "--numworkerthreads supports a maximum of "
- "%d worker threads\n",
- - MAX_NUM_THREADS);
- - PrintUsage();
- + argv[0], MAX_NUM_THREADS);
- return FALSE;
- }
- }
- - else
- - fprintf(stderr, "Unrecognized option '%S', disregarding.\n", argv[i]);
- + else {
- + (void)fprintf(stderr,
- + "%S: Unrecognized option '%S'\n",
- + argv[0], argv[i]);
- + return FALSE;
- + }
- + }
- + else {
- + if (!wcscmp(argv[i], L"/?")) { /* help */
- + PrintUsage(argv[0]);
- + return FALSE;
- + }
- }
- }
- --
- 2.45.1
- From c456405672085766643256a45fea28bcebc4b03f Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Sat, 31 Aug 2024 14:03:39 +0200
- Subject: [PATCH 2/5] daemon: Release/nfsd -debug prints warning about -debug
- not recognized
- Running Release/nfsd in debug mode with $ ./nfsd -debug # prints
- warning a about -debug not recognized, which in this case
- is a valid option.
- Reported-by: Martin Wege <martin.l.wege@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/nfs41_daemon.c | 12 ++++++++++++
- 1 file changed, 12 insertions(+)
- diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
- index 8904afc..258889d 100644
- --- a/daemon/nfs41_daemon.c
- +++ b/daemon/nfs41_daemon.c
- @@ -285,7 +285,12 @@ bool_t parse_cmdlineargs(int argc, wchar_t *argv[], nfsd_args *out)
- out->ldap_enable = TRUE;
- /* parse command line */
- +#ifdef STANDALONE_NFSD
- + /* Options from |CmdDebugService()| start at index 0 ... */
- + for (i = 0; i < argc; i++) {
- +#else
- for (i = 1; i < argc; i++) {
- +#endif
- if (argv[i][0] == L'-') {
- if ((!wcscmp(argv[i], L"-h")) ||
- (!wcscmp(argv[i], L"--help"))) { /* help */
- @@ -381,6 +386,13 @@ bool_t parse_cmdlineargs(int argc, wchar_t *argv[], nfsd_args *out)
- return FALSE;
- }
- }
- + /*
- + * -Debug/-debug might be passed as first option in a
- + * Release build to switch nfsd to debug mode
- + */
- + else if (!_wcsicmp(argv[i], L"-debug")) {
- + /* ignored, nothing to do here */
- + }
- else {
- (void)fprintf(stderr,
- "%S: Unrecognized option '%S'\n",
- --
- 2.45.1
- From 5a34b4f1062b54a9e5c7ccf2263e5473f53463c8 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Sat, 31 Aug 2024 15:15:49 +0200
- Subject: [PATCH 3/5] cygwin,daemon: Add infratructure to run Release builds
- from msnfs41client
- Add infratructure to run Release builds from msnfs41client.
- Reported-by: Martin Wege <martin.l.wege@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/Makefile | 6 ++++--
- cygwin/devel/msnfs41client.bash | 22 ++++++++++++----------
- daemon/nfs41_daemon.c | 6 +++++-
- 3 files changed, 21 insertions(+), 13 deletions(-)
- diff --git a/cygwin/Makefile b/cygwin/Makefile
- index 8a2a7b5..e7125bb 100644
- --- a/cygwin/Makefile
- +++ b/cygwin/Makefile
- @@ -15,6 +15,8 @@ DESTDIR:=$(PROJECT_BASEDIR_DIR)/destdir
- VS_BUILD_DIR32:=$(PROJECT_BASEDIR_DIR)/build.vc19/Debug/
- VS_BUILD_DIR64:=$(PROJECT_BASEDIR_DIR)/build.vc19/x64/Debug/
- +#VS_BUILD_DIR32:=$(PROJECT_BASEDIR_DIR)/build.vc19/Release/
- +#VS_BUILD_DIR64:=$(PROJECT_BASEDIR_DIR)/build.vc19/x64/Release/
- # trigger "build" target when these binaries are needed
- $(VS_BUILD_DIR32)/nfsd.exe \
- @@ -98,12 +100,12 @@ installdest: \
- # installdest 32bit Windows
- make -f $(CYGWIN_MAKEFILE_DIR)/Makefile.install \
- installdest \
- - VS_BUILD_DIR="$(PROJECT_BASEDIR_DIR)/build.vc19/Debug/" \
- + VS_BUILD_DIR="$(VS_BUILD_DIR32)" \
- CYGWIN_BASEPATH=/cygdrive/c/cygwin/
- # installdest 64bit Windows
- make -f $(CYGWIN_MAKEFILE_DIR)/Makefile.install \
- installdest \
- - VS_BUILD_DIR="$(PROJECT_BASEDIR_DIR)/build.vc19/x64/Debug/" \
- + VS_BUILD_DIR="$(VS_BUILD_DIR64)" \
- CYGWIN_BASEPATH=/cygdrive/c/cygwin64/
- bintarball: installdest
- diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
- index 7895e9f..352344a 100644
- --- a/cygwin/devel/msnfs41client.bash
- +++ b/cygwin/devel/msnfs41client.bash
- @@ -271,7 +271,8 @@ function nfsclient_rundeamon
- set -o xtrace
- typeset -a nfsd_args=(
- - 'nfsd_debug.exe'
- + 'nfsd.exe'
- + '-debug'
- '-d' '0'
- '--noldap'
- #'--numworkerthreads' '512'
- @@ -310,7 +311,7 @@ function nfsclient_rundeamon
- "${nfsd_args[@]}"
- elif false ; then
- #
- - # test nfsd_debug.exe with Dr. Memory (version 2.6.0 -- build 0)
- + # test nfsd.exe with Dr. Memory (version 2.6.0 -- build 0)
- #
- export _NT_ALT_SYMBOL_PATH="$(cygpath -w "$PWD")"
- nfsd_args=(
- @@ -336,19 +337,19 @@ function nfsclient_rundeamon
- # Killing DrMemory with <CTRL-C> does not terminate nfsd,
- # so we have to do it ourselves
- - trap 'taskkill /F /IM nfsd_debug.exe' SIGINT SIGTERM
- + trap 'taskkill /F /IM nfsd.exe' SIGINT SIGTERM
- "${nfsd_args[@]}"
- elif false ; then
- typeset -i vsdiagnostics_id=50
- VSDiagnostics \
- start ${vsdiagnostics_id} \
- - "/launch:$(cygpath -w "$PWD/nfsd_debug.exe")" \
- + "/launch:$(cygpath -w "$PWD/nfsd.exe")" \
- "/launchArgs:${nfsd_args[*]:1}" \
- "/loadConfig:$(cygpath -w "${vsdiagnostics_path}/AgentConfigs/CpuUsageHigh.json")"
- printf '#\n'
- printf '# use\n'
- - printf '# $ "%s" stop %d /output:nfsd_debug%d # to collect profiling data\n#\n' \
- + printf '# $ "%s" stop %d /output:nfsd%d # to collect profiling data\n#\n' \
- "$(which -a 'VSDiagnostics.exe')" \
- "${vsdiagnostics_id}" "$$"
- else
- @@ -374,7 +375,8 @@ function nfsclient_system_rundeamon
- set -o xtrace
- typeset -a nfsd_args=(
- - 'nfsd_debug.exe'
- + 'nfsd.exe'
- + '-debug'
- '-d' '0'
- '--noldap'
- #'--numworkerthreads' '512'
- @@ -427,7 +429,7 @@ function nfsclient_system_rundeamon
- "${nfsd_args[@]}"
- elif false ; then
- #
- - # test nfsd_debug.exe with Dr. Memory (version 2.6.0 -- build 0)
- + # test nfsd.exe with Dr. Memory (version 2.6.0 -- build 0)
- #
- export _NT_ALT_SYMBOL_PATH="$(cygpath -w "$PWD")"
- nfsd_args=(
- @@ -459,7 +461,7 @@ function nfsclient_system_rundeamon
- # Killing DrMemory with <CTRL-C> does not terminate nfsd,
- # so we have to do it ourselves
- - trap 'taskkill /F /IM nfsd_debug.exe' SIGINT SIGTERM
- + trap 'taskkill /F /IM nfsd.exe' SIGINT SIGTERM
- "${nfsd_args[@]}"
- elif false ; then
- @@ -467,12 +469,12 @@ function nfsclient_system_rundeamon
- # run everything as su_system
- su_system VSDiagnostics \
- start ${vsdiagnostics_id} \
- - "/launch:$(cygpath -w "$PWD/nfsd_debug.exe")" \
- + "/launch:$(cygpath -w "$PWD/nfsd.exe")" \
- "/launchArgs:${nfsd_args[*]:1}" \
- "/loadConfig:$(cygpath -w "${vsdiagnostics_path}/AgentConfigs/CpuUsageHigh.json")"
- printf '#\n'
- printf '# use\n'
- - printf '# $ "%s" stop %d /output:nfsd_debug%d # to collect profiling data\n#\n' \
- + printf '# $ "%s" stop %d /output:nfsd%d # to collect profiling data\n#\n' \
- "$(which -a 'VSDiagnostics.exe')" \
- "${vsdiagnostics_id}" "$$"
- else
- diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
- index 258889d..06730c3 100644
- --- a/daemon/nfs41_daemon.c
- +++ b/daemon/nfs41_daemon.c
- @@ -752,7 +752,11 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv)
- DPRINTF(0, ("SID cache disabled\n"));
- #endif /* NFS41_DRIVER_SID_CACHE */
- - logprintf("NFS client daemon starting...\n");
- +#ifdef _DEBUG
- + logprintf("NFS client daemon (DEBUG build) starting...\n");
- +#else
- + logprintf("NFS client daemon (Release build) starting...\n");
- +#endif
- /* Enable Win32 privileges */
- set_nfs_daemon_privileges();
- --
- 2.45.1
- From b2fd3226d3818bf81f0c373b4bed8388108c61bb Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Sat, 31 Aug 2024 15:18:20 +0200
- Subject: [PATCH 4/5] daemon: Release build nfsd crashes without -d 1
- Release build nfsd crashes without -d 1, because the log file
- was not opened yet.
- Reported-by: Martin Wege <martin.l.wege@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/daemon_debug.c | 17 ++++++++++-------
- 1 file changed, 10 insertions(+), 7 deletions(-)
- diff --git a/daemon/daemon_debug.c b/daemon/daemon_debug.c
- index ad685ce..77e5e97 100644
- --- a/daemon/daemon_debug.c
- +++ b/daemon/daemon_debug.c
- @@ -47,18 +47,21 @@ void open_log_files()
- const char dfile[] = "nfsddbg.log";
- const char efile[] = "nfsderr.log";
- const char mode[] = "w";
- - if (g_debug_level > 0) {
- - dlog_file = fopen(dfile, mode);
- - if (dlog_file == NULL) {
- - ReportStatusToSCMgr(SERVICE_STOPPED, GetLastError(), 0);
- - exit (GetLastError());
- - }
- - }
- +
- + (void)remove(efile);
- + (void)remove(dfile);
- +
- elog_file = fopen(efile, mode);
- if (elog_file == NULL) {
- ReportStatusToSCMgr(SERVICE_STOPPED, GetLastError(), 0);
- exit (GetLastError());
- }
- +
- + dlog_file = fopen(dfile, mode);
- + if (dlog_file == NULL) {
- + ReportStatusToSCMgr(SERVICE_STOPPED, GetLastError(), 0);
- + exit (GetLastError());
- + }
- }
- void close_log_files()
- --
- 2.45.1
- From e7f25bc0dee349708d65b1d09fb0a4a49fea2c06 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Sat, 31 Aug 2024 16:43:42 +0200
- Subject: [PATCH 5/5] tests: Document how to set up Windows local user mode
- crash dumps
- Document how to set up Windows local user mode crash dumps, see
- https://learn.microsoft.com/en-us/windows/win32/wer/collecting-user-mode-dumps
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- tests/manual_testing.txt | 15 +++++++++++++++
- 1 file changed, 15 insertions(+)
- diff --git a/tests/manual_testing.txt b/tests/manual_testing.txt
- index 154b8d3..ec8cf17 100644
- --- a/tests/manual_testing.txt
- +++ b/tests/manual_testing.txt
- @@ -86,6 +86,21 @@
- # $ PATH+=':/cygdrive/c/Program Files (x86)/Windows Kits/10/Debuggers/x64/'
- # $ kd -loga kdlog.log -k net:port=50000,key=1.1.1.1,target=10.49.202.87 #
- #
- +# - Windows local crash dumps setup (for non-Cygwin apps)
- +# (see https://learn.microsoft.com/en-us/windows/win32/wer/collecting-user-mode-dumps):
- +# ---- snip -----
- +# # enable crash dumps globally
- +# regtool add '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/Windows Error Reporting/LocalDumps'
- +# regtool -i set '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/Windows Error Reporting/LocalDumps/DumpType' 2
- +# mkdir -p "$(cygpath -u "$(echo $LOCALAPPDATA)")/CrashDumps"
- +# # list generated crash dumps
- +# ls -la "$(cygpath -u "$(echo $LOCALAPPDATA)")/CrashDumps"
- +# # get stack trace for crash dump "link.exe.1640.dmp"
- +# PATH+=':/cygdrive/c/Program Files (x86)/Windows Kits/10/Debuggers/x64/'
- +# cdb -z "${LOCALAPPDATA}\CrashDumps\link.exe.1640.dmp" -c '!analyze -v ; q'
- +# ---- snip -----
- +#
- +
- #
- # Tests for cp -p/mv/chmod/chgrp
- --
- 2.45.1
msnf41client: Patch for nfsd help options, release build infrastructure, tests+misc, 2024-08-31
Posted by Anonymous on Sat 31st Aug 2024 15:54
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.