- diff --git a/cygwin/Makefile b/cygwin/Makefile
 - index b7a3b1e..41e2340 100644
 - --- a/cygwin/Makefile
 - +++ b/cygwin/Makefile
 - @@ -57,7 +57,11 @@ installdest: $(VS_BUILD_DIR)/nfsd.exe \
 - fi
 - mkdir -p $(DESTDIR)
 - mkdir -p $(DESTDIR)/cygdrive/c/cygwin64/sbin/
 - - mkdir -p $(DESTDIR)/cygdrive/c/cygwin64/usr/bin
 - + # /usr/bin is a bind mount to C:/cygwin64/bin, so copy binaries to /cygdrive/c/cygwin64/bin
 - + mkdir -p $(DESTDIR)/cygdrive/c/cygwin64/bin
 - + # /usr/lib is a bind mount to C:/cygwin64/lib, so copy library data to /cygdrive/c/cygwin64/lib
 - + mkdir -p $(DESTDIR)/cygdrive/c/cygwin64/lib
 - + mkdir -p $(DESTDIR)/cygdrive/c/cygwin64/lib/msnfs41client
 - cp -r $(VS_BUILD_DIR)/nfsd.exe $(DESTDIR)/cygdrive/c/cygwin64/sbin/nfsd_debug.exe
 - cp -r $(VS_BUILD_DIR)/nfsd.pdb $(DESTDIR)/cygdrive/c/cygwin64/sbin/nfsd_debug.pdb
 - cp -r $(VS_BUILD_DIR)/nfs_mount.* $(DESTDIR)/cygdrive/c/cygwin64/sbin/.
 - @@ -68,17 +72,18 @@ installdest: $(VS_BUILD_DIR)/nfsd.exe \
 - cp -r $(VS_BUILD_DIR)/libtirpc.* $(DESTDIR)/cygdrive/c/cygwin64/sbin/.
 - cp $(PROJECT_BASEDIR_DIR)/nfs41rdr.inf $(DESTDIR)/cygdrive/c/cygwin64/sbin/.
 - cp $(PROJECT_BASEDIR_DIR)/etc_netconfig $(DESTDIR)/cygdrive/c/cygwin64/sbin/.
 - - cp $(PROJECT_BASEDIR_DIR)/ms-nfs41-idmap.conf $(DESTDIR)/cygdrive/c/cygwin64/sbin/.
 - - cp $(CYGWIN_MAKEFILE_DIR)/devel/msnfs41client.bash $(DESTDIR)/cygdrive/c/cygwin64/sbin/.
 - + cp $(PROJECT_BASEDIR_DIR)/ms-nfs41-idmap.conf $(DESTDIR)/cygdrive/c/cygwin64/sbin/.
 - + cp $(CYGWIN_MAKEFILE_DIR)/devel/msnfs41client.bash $(DESTDIR)/cygdrive/c/cygwin64/sbin/.
 - + cp $(PROJECT_BASEDIR_DIR)/cygwin_idmapper.ksh $(DESTDIR)/cygdrive/c/cygwin64/lib/msnfs41client/.
 - cp $(CYGWIN_MAKEFILE_DIR)/utils/mount_sshnfs/mount_sshnfs.ksh $(DESTDIR)/cygdrive/c/cygwin64/sbin/mount_sshnfs
 - chmod a+x $(DESTDIR)/cygdrive/c/cygwin64/sbin/mount_sshnfs
 - cp $(CYGWIN_MAKEFILE_DIR)/utils/sshnfs/sshnfs.ksh $(DESTDIR)/cygdrive/c/cygwin64/sbin/sshnfs
 - chmod a+x $(DESTDIR)/cygdrive/c/cygwin64/sbin/sshnfs
 - @ printf "# Package tests\n"
 - - cp tests/winfsinfo1/winfsinfo.exe $(DESTDIR)/cygdrive/c/cygwin64/usr/bin/winfsinfo.exe
 - + cp tests/winfsinfo1/winfsinfo.exe $(DESTDIR)/cygdrive/c/cygwin64/bin/winfsinfo.exe
 - @ printf "# Package ksh93&co (if available) since Cygwin does not ship with it yet\n"
 - - [[ -x /usr/bin/ksh93.exe ]] && cp /usr/bin/ksh93.exe $(DESTDIR)/cygdrive/c/cygwin64/usr/bin/ksh93.exe
 - - [[ -x /usr/bin/shcomp.exe ]] && cp /usr/bin/shcomp.exe $(DESTDIR)/cygdrive/c/cygwin64/usr/bin/shcomp.exe
 - + [[ -x /usr/bin/ksh93.exe ]] && cp /usr/bin/ksh93.exe $(DESTDIR)/cygdrive/c/cygwin64/bin/ksh93.exe
 - + [[ -x /usr/bin/shcomp.exe ]] && cp /usr/bin/shcomp.exe $(DESTDIR)/cygdrive/c/cygwin64/bin/shcomp.exe
 - @ printf "# Set file flags\n"
 - (cd $(DESTDIR)/cygdrive/c/cygwin64/sbin/ ; chmod a+x *.exe *.dll *.sys *.bash)
 - @printf "\n#\n# TEST sbin dir is %s\n#\n" "$(DESTDIR)/cygdrive/c/cygwin64/sbin/"
 - @@ -86,6 +91,14 @@ installdest: $(VS_BUILD_DIR)/nfsd.exe \
 - @printf "\n#\n# Now use\n# $$ cd '%s' && bash ./msnfs41client.bash install #\n# to install the kernel driver as Admin\n#\n" \
 - "$(DESTDIR)/cygdrive/c/cygwin64/sbin/"
 - +bintarball: installdest
 - + (cd destdir && \
 - + tar -cvf - \
 - + --owner=SYSTEM \
 - + --group=SYSTEM \
 - + cygdrive/c/cygwin64 | \
 - + bzip2 -9 >msnfs41client_cygwin_binaries.tar.bz2)
 - +
 - #
 - # clean destdir/, but only if nfsd*.exe does not use it right now
 - #
 - @@ -94,6 +107,6 @@ cleandest:
 - printf 'DIR %q is in use by a process\n' "$DESTDIR" 1>&2 ; \
 - exit 1 ; \
 - fi
 - - rm -r "$(DESTDIR)"
 - + rm -rf "$(DESTDIR)"
 - # EOF.
 - diff --git a/daemon/getattr.c b/daemon/getattr.c
 - index 7c5f241..7621dba 100644
 - --- a/daemon/getattr.c
 - +++ b/daemon/getattr.c
 - @@ -59,8 +59,19 @@ int nfs41_cached_getattr(
 - static int parse_getattr(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
 - {
 - int status;
 - +#if 1
 - + EASSERT(length > 4);
 - + if (length <= 4) {
 - + status = ERROR_INVALID_PARAMETER;
 - + goto out;
 - + }
 - + EASSERT(upcall->state_ref != NULL);
 - + if (upcall->state_ref == NULL) {
 - + status = ERROR_INVALID_PARAMETER;
 - + goto out;
 - + }
 - +#endif
 - getattr_upcall_args *args = &upcall->args.getattr;
 - -
 - status = safe_read(&buffer, &length, &args->query_class, sizeof(args->query_class));
 - if (status) goto out;
 - status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len));
 - @@ -80,6 +91,21 @@ static int handle_getattr(void *daemon_context, nfs41_upcall *upcall)
 - nfs41_open_state *state = upcall->state_ref;
 - nfs41_file_info info = { 0 };
 - +#if 1
 - + if (((char *)state->session) == ((char *)0xdddddddddddddddd)) {
 - + eprintf("handle_getattr: Invalid session pointer 0xdddddddddddddddd\n");
 - + status = ERROR_INVALID_PARAMETER;
 - + goto out;
 - + }
 - +
 - + EASSERT(state->file.fh.superblock != NULL);
 - + if (state->file.fh.superblock == NULL) {
 - + /* gisburn: fixme: maybe this should be |ERROR_INTERNAL_ERROR| ? */
 - + status = ERROR_INVALID_PARAMETER;
 - + goto out;
 - + }
 - +#endif
 - +
 - status = nfs41_cached_getattr(state->session, &state->file, &info);
 - if (status) {
 - eprintf("nfs41_cached_getattr() failed with %d\n", status);
 - diff --git a/daemon/idmap_cygwin.c b/daemon/idmap_cygwin.c
 - index 64c1bff..f8bb74e 100644
 - --- a/daemon/idmap_cygwin.c
 - +++ b/daemon/idmap_cygwin.c
 - @@ -40,7 +40,7 @@
 - #define CYGWIN_IDMAPPER_SCRIPT \
 - ("C:\\cygwin64\\bin\\ksh93.exe " \
 - - "/home/roland_mainz/work/msnfs41_uidmapping/ms-nfs41-client/cygwin_idmapper.ksh")
 - + "/cygdrive/c/cygwin64/lib/msnfs41client/cygwin_idmapper.ksh")
 - #ifdef NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN
 - diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
 - index fe0683e..a43d51e 100644
 - --- a/daemon/nfs41_daemon.c
 - +++ b/daemon/nfs41_daemon.c
 - @@ -27,67 +27,67 @@
 - #include <devioctl.h>
 - #include <lmcons.h> /* UNLEN for GetUserName() */
 - #include <iphlpapi.h> /* for GetNetworkParam() */
 - -#include "nfs41_driver.h" /* for NFS41_USER_DEVICE_NAME_A */
 - -#include "nfs41_np.h" /* for NFS41NP_SHARED_MEMORY */
 - -
 - -#include "nfs41_daemon.h"
 - -#include "daemon_debug.h"
 - -#include "upcall.h"
 - -#include "sid.h"
 - -#include "util.h"
 - -
 - -/* nfs41_dg.num_worker_threads sets the actual number of worker threads */
 - -#define MAX_NUM_THREADS 1024
 - -#define DEFAULT_NUM_THREADS 32
 - -DWORD NFS41D_VERSION = 0;
 - -
 - -static const char FILE_NETCONFIG[] = "C:\\etc\\netconfig";
 - -
 - -/* Globals */
 - -nfs41_daemon_globals nfs41_dg = {
 - - .default_uid = NFS_USER_NOBODY_UID,
 - - .default_gid = NFS_GROUP_NOGROUP_GID,
 - - .num_worker_threads = DEFAULT_NUM_THREADS,
 - -};
 - -
 - -
 - -#ifndef STANDALONE_NFSD //make sure to define it in "sources" not here
 - -#include "service.h"
 - +#include "nfs41_driver.h" /* for NFS41_USER_DEVICE_NAME_A */
 - +#include "nfs41_np.h" /* for NFS41NP_SHARED_MEMORY */
 - +
 - +#include "nfs41_daemon.h"
 - +#include "daemon_debug.h"
 - +#include "upcall.h"
 - +#include "sid.h"
 - +#include "util.h"
 - +
 - +/* nfs41_dg.num_worker_threads sets the actual number of worker threads */
 - +#define MAX_NUM_THREADS 1024
 - +#define DEFAULT_NUM_THREADS 32
 - +DWORD NFS41D_VERSION = 0;
 - +
 - +static const char FILE_NETCONFIG[] = "C:\\etc\\netconfig";
 - +
 - +/* Globals */
 - +nfs41_daemon_globals nfs41_dg = {
 - + .default_uid = NFS_USER_NOBODY_UID,
 - + .default_gid = NFS_GROUP_NOGROUP_GID,
 - + .num_worker_threads = DEFAULT_NUM_THREADS,
 - +};
 - +
 - +
 - +#ifndef STANDALONE_NFSD //make sure to define it in "sources" not here
 - +#include "service.h"
 - HANDLE stop_event = NULL;
 - #endif
 - typedef struct _nfs41_process_thread {
 - HANDLE handle;
 - - uint32_t tid;
 - -} nfs41_process_thread;
 - -
 - -static int map_current_user_to_ids(nfs41_idmapper *idmapper, uid_t *uid, gid_t *gid)
 - -{
 - - char username[UNLEN + 1];
 - - DWORD len = UNLEN + 1;
 - + uint32_t tid;
 - +} nfs41_process_thread;
 - +
 - +static int map_current_user_to_ids(nfs41_idmapper *idmapper, uid_t *uid, gid_t *gid)
 - +{
 - + char username[UNLEN + 1];
 - + DWORD len = UNLEN + 1;
 - int status = NO_ERROR;
 - -
 - - if (!GetUserNameA(username, &len)) {
 - - status = GetLastError();
 - - eprintf("map_current_user_to_ids: GetUserName() failed with %d\n", status);
 - - goto out;
 - - }
 - - dprintf(1, "map_current_user_to_ids: mapping user %s\n", username);
 - -
 - - if (nfs41_idmap_name_to_ids(idmapper, username, uid, gid)) {
 - - /* instead of failing for auth_sys, fall back to 'nobody' uid/gid */
 - - *uid = nfs41_dg.default_uid;
 - - *gid = nfs41_dg.default_gid;
 - - }
 - -out:
 - - return status;
 - +
 - + if (!GetUserNameA(username, &len)) {
 - + status = GetLastError();
 - + eprintf("map_current_user_to_ids: GetUserName() failed with %d\n", status);
 - + goto out;
 - + }
 - + dprintf(1, "map_current_user_to_ids: mapping user %s\n", username);
 - +
 - + if (nfs41_idmap_name_to_ids(idmapper, username, uid, gid)) {
 - + /* instead of failing for auth_sys, fall back to 'nobody' uid/gid */
 - + *uid = nfs41_dg.default_uid;
 - + *gid = nfs41_dg.default_gid;
 - + }
 - +out:
 - + return status;
 - }
 - -
 - -static unsigned int WINAPI thread_main(void *args)
 - -{
 - - nfs41_daemon_globals *nfs41dg = (nfs41_daemon_globals *)args;
 - - DWORD status = 0;
 - - HANDLE pipe;
 - - // buffer used to process upcall, assumed to be fixed size.
 - +
 - +static unsigned int WINAPI thread_main(void *args)
 - +{
 - + nfs41_daemon_globals *nfs41dg = (nfs41_daemon_globals *)args;
 - + DWORD status = 0;
 - + HANDLE pipe;
 - + // buffer used to process upcall, assumed to be fixed size.
 - // if we ever need to handle non-cached IO, need to make it dynamic
 - unsigned char outbuf[UPCALL_BUF_SIZE], inbuf[UPCALL_BUF_SIZE];
 - DWORD inbuf_len = UPCALL_BUF_SIZE, outbuf_len;
 - @@ -113,29 +113,29 @@ static unsigned int WINAPI thread_main(void *args)
 - status = upcall_parse(outbuf, (uint32_t)outbuf_len, &upcall);
 - if (status) {
 - upcall.status = status;
 - - goto write_downcall;
 - - }
 - -
 - - /*
 - - * Map current username to uid/gid
 - - * Each thread can handle a different user
 - - */
 - - status = map_current_user_to_ids(nfs41dg->idmapper,
 - - &upcall.uid, &upcall.gid);
 - - if (status) {
 - - upcall.status = status;
 - - goto write_downcall;
 - + goto write_downcall;
 - + }
 - +
 - + /*
 - + * Map current username to uid/gid
 - + * Each thread can handle a different user
 - + */
 - + status = map_current_user_to_ids(nfs41dg->idmapper,
 - + &upcall.uid, &upcall.gid);
 - + if (status) {
 - + upcall.status = status;
 - + goto write_downcall;
 - }
 - if (upcall.opcode == NFS41_SHUTDOWN) {
 - printf("Shutting down..\n");
 - - exit(0);
 - - }
 - -
 - - status = upcall_handle(&nfs41_dg, &upcall);
 - -
 - -write_downcall:
 - - dprintf(1, "writing downcall: xid=%lld opcode=%s status=%d "
 - + exit(0);
 - + }
 - +
 - + status = upcall_handle(&nfs41_dg, &upcall);
 - +
 - +write_downcall:
 - + dprintf(1, "writing downcall: xid=%lld opcode=%s status=%d "
 - "get_last_error=%d\n", upcall.xid, opcode2string(upcall.opcode),
 - upcall.status, upcall.last_error);
 - @@ -182,18 +182,18 @@ static bool_t check_for_files()
 - fclose(fd);
 - return TRUE;
 - }
 - -
 - -static void PrintUsage()
 - -{
 - - (void)fprintf(stderr, "Usage: nfsd.exe -d <debug_level> "
 - - "--noldap "
 - - "--uid <non-zero value> "
 - - "--gid <non-zero value> "
 - - "--numworkerthreads <value-between 16 and %d> "
 - - "\n", MAX_NUM_THREADS);
 - -}
 - -static bool_t parse_cmdlineargs(int argc, TCHAR *argv[], nfsd_args *out)
 - -{
 - +
 - +static void PrintUsage()
 - +{
 - + (void)fprintf(stderr, "Usage: nfsd.exe -d <debug_level> "
 - + "--noldap "
 - + "--uid <non-zero value> "
 - + "--gid <non-zero value> "
 - + "--numworkerthreads <value-between 16 and %d> "
 - + "\n", MAX_NUM_THREADS);
 - +}
 - +static bool_t parse_cmdlineargs(int argc, TCHAR *argv[], nfsd_args *out)
 - +{
 - int i;
 - /* set defaults. */
 - @@ -223,60 +223,60 @@ static bool_t parse_cmdlineargs(int argc, TCHAR *argv[], nfsd_args *out)
 - ++i;
 - if (i >= argc) {
 - fprintf(stderr, "Missing uid value\n");
 - - PrintUsage();
 - - return FALSE;
 - - }
 - - nfs41_dg.default_uid = _ttoi(argv[i]);
 - - if (!nfs41_dg.default_uid) {
 - - fprintf(stderr, "Invalid (or missing) anonymous uid value of %d\n",
 - - nfs41_dg.default_uid);
 - - return FALSE;
 - - }
 - - }
 - + PrintUsage();
 - + return FALSE;
 - + }
 - + nfs41_dg.default_uid = _ttoi(argv[i]);
 - + if (!nfs41_dg.default_uid) {
 - + fprintf(stderr, "Invalid (or missing) anonymous uid value of %d\n",
 - + nfs41_dg.default_uid);
 - + return FALSE;
 - + }
 - + }
 - else if (_tcscmp(argv[i], TEXT("--gid")) == 0) { /* no LDAP, setting default gid */
 - ++i;
 - if (i >= argc) {
 - fprintf(stderr, "Missing gid value\n");
 - - PrintUsage();
 - - return FALSE;
 - - }
 - - nfs41_dg.default_gid = _ttoi(argv[i]);
 - - }
 - - else if (_tcscmp(argv[i], TEXT("--numworkerthreads")) == 0) {
 - - ++i;
 - - if (i >= argc) {
 - - fprintf(stderr, "Missing value for num_worker_threads\n");
 - - PrintUsage();
 - - return FALSE;
 - - }
 - - nfs41_dg.num_worker_threads = _ttoi(argv[i]);
 - - if (nfs41_dg.num_worker_threads < 16) {
 - - fprintf(stderr, "--numworkerthreads requires at least 16 worker threads\n");
 - - PrintUsage();
 - - return FALSE;
 - - }
 - - if (nfs41_dg.num_worker_threads >= MAX_NUM_THREADS) {
 - - fprintf(stderr,
 - - "--numworkerthreads supports a maximum of "
 - - "%d worker threads\n",
 - - MAX_NUM_THREADS);
 - - PrintUsage();
 - - return FALSE;
 - - }
 - - }
 - - else
 - - fprintf(stderr, "Unrecognized option '%s', disregarding.\n", argv[i]);
 - - }
 - - }
 - -
 - - (void)fprintf(stdout, "parse_cmdlineargs: debug_level %d ldap is %d "
 - -#ifdef NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN
 - - "idmap_cygwin is 1 "
 - -#endif /* NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN */
 - - "\n",
 - - out->debug_level, out->ldap_enable);
 - - return TRUE;
 - -}
 - + PrintUsage();
 - + return FALSE;
 - + }
 - + nfs41_dg.default_gid = _ttoi(argv[i]);
 - + }
 - + else if (_tcscmp(argv[i], TEXT("--numworkerthreads")) == 0) {
 - + ++i;
 - + if (i >= argc) {
 - + fprintf(stderr, "Missing value for num_worker_threads\n");
 - + PrintUsage();
 - + return FALSE;
 - + }
 - + nfs41_dg.num_worker_threads = _ttoi(argv[i]);
 - + if (nfs41_dg.num_worker_threads < 16) {
 - + fprintf(stderr, "--numworkerthreads requires at least 16 worker threads\n");
 - + PrintUsage();
 - + return FALSE;
 - + }
 - + if (nfs41_dg.num_worker_threads >= MAX_NUM_THREADS) {
 - + fprintf(stderr,
 - + "--numworkerthreads supports a maximum of "
 - + "%d worker threads\n",
 - + MAX_NUM_THREADS);
 - + PrintUsage();
 - + return FALSE;
 - + }
 - + }
 - + else
 - + fprintf(stderr, "Unrecognized option '%s', disregarding.\n", argv[i]);
 - + }
 - + }
 - +
 - + (void)fprintf(stdout, "parse_cmdlineargs: debug_level %d ldap is %d "
 - +#ifdef NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN
 - + "idmap_cygwin is 1 "
 - +#endif /* NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN */
 - + "\n",
 - + out->debug_level, out->ldap_enable);
 - + return TRUE;
 - +}
 - static void print_getaddrinfo(struct addrinfo *ptr)
 - {
 - @@ -358,15 +358,15 @@ static int getdomainname()
 - for (i = 0; i < len; i++)
 - if (p[i] == '.')
 - break;
 - - if (i == len)
 - - break;
 - - flag = TRUE;
 - - memcpy(nfs41_dg.localdomain_name, &hostname[i+1], len-i);
 - - dprintf(1, "getdomainname: domainname %s %d\n",
 - - nfs41_dg.localdomain_name, strlen(nfs41_dg.localdomain_name));
 - - goto out_loop;
 - - }
 - - break;
 - + if (i == len)
 - + break;
 - + flag = TRUE;
 - + memcpy(nfs41_dg.localdomain_name, &hostname[i+1], len-i);
 - + dprintf(1, "getdomainname: domainname %s %d\n",
 - + nfs41_dg.localdomain_name, strlen(nfs41_dg.localdomain_name));
 - + goto out_loop;
 - + }
 - + break;
 - default:
 - break;
 - }
 - @@ -378,15 +378,15 @@ out_loop:
 - "Set this machine's domain name:\n"
 - "System > ComputerName > Change > More > mydomain\n");
 - }
 - - freeaddrinfo(result);
 - - } else {
 - - dprintf(1, "domain name is %s\n", net_info->DomainName);
 - - memcpy(nfs41_dg.localdomain_name, net_info->DomainName,
 - - strlen(net_info->DomainName));
 - - nfs41_dg.localdomain_name[strlen(net_info->DomainName)] = '\0';
 - - }
 - -out_free:
 - - free(net_info);
 - + freeaddrinfo(result);
 - + } else {
 - + dprintf(1, "domain name is %s\n", net_info->DomainName);
 - + memcpy(nfs41_dg.localdomain_name, net_info->DomainName,
 - + strlen(net_info->DomainName));
 - + nfs41_dg.localdomain_name[strlen(net_info->DomainName)] = '\0';
 - + }
 - +out_free:
 - + free(net_info);
 - out:
 - return status;
 - }
 - @@ -398,24 +398,38 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv)
 - #endif
 - {
 - DWORD status = 0, len;
 - - // handle to our drivers
 - - HANDLE pipe;
 - - nfs41_process_thread tids[MAX_NUM_THREADS];
 - - int i;
 - - nfsd_args cmd_args;
 - -
 - - if (!check_for_files())
 - - exit(1);
 - - if (!parse_cmdlineargs(argc, argv, &cmd_args))
 - - exit(1);
 - - set_debug_level(cmd_args.debug_level);
 - - open_log_files();
 - - sidcache_init();
 - -
 - -#ifdef _DEBUG
 - - /* dump memory leaks to stderr on exit; this requires the debug heap,
 - + // handle to our drivers
 - + HANDLE pipe;
 - + nfs41_process_thread tids[MAX_NUM_THREADS];
 - + int i;
 - + nfsd_args cmd_args;
 - +
 - + if (!check_for_files())
 - + exit(1);
 - + if (!parse_cmdlineargs(argc, argv, &cmd_args))
 - + exit(1);
 - + set_debug_level(cmd_args.debug_level);
 - + open_log_files();
 - + sidcache_init();
 - +
 - +#ifdef _DEBUG
 - + /* dump memory leaks to stderr on exit; this requires the debug heap,
 - /* available only when built in debug mode under visual studio -cbodley */
 - - _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
 - +
 - + int crtsetdbgflags = 0;
 - + crtsetdbgflags |= _CRTDBG_ALLOC_MEM_DF; /* use debug heap */
 - + crtsetdbgflags |= _CRTDBG_LEAK_CHECK_DF; /* report leaks on exit */
 - +#if 1
 - + /*
 - + * _CRTDBG_DELAY_FREE_MEM_DF - Delay freeing of memory, but fill
 - + * memory blocks passed to |free()| with 0xdd. We rely on that to
 - + * see 0xdddddddddddddddd-pointers for use-after-free and catch
 - + * them in stress testing instead of having to deal with a core
 - + * dump
 - + */
 - + crtsetdbgflags |= _CRTDBG_DELAY_FREE_MEM_DF;
 - +#endif
 - + (void)_CrtSetDbgFlag(crtsetdbgflags);
 - _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
 - /*
 - @@ -434,34 +448,34 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv)
 - * needed for acls */
 - if (getdomainname()) {
 - eprintf("Could not get domain name\n");
 - - exit(1);
 - - }
 - -
 - - /*
 - - * Set high priority class to avoid that the daemon gets stomped
 - - * by other processes, which might lead to some kind of priority
 - - * inversion
 - - */
 - - if(SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS)) {
 - - dprintf(0, "Running as HIGH_PRIORITY_CLASS\n");
 - - }
 - - else {
 - - eprintf("Failed to enter HIGH_PRIORITY_CLASS mode\n");
 - - }
 - -
 - -#ifdef NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN
 - - /* force enable for cygwin getent passwd/group testing */
 - - cmd_args.ldap_enable = TRUE;
 - - DASSERT(0/* test asserts*/, 0);
 - -#endif /* NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN */
 - -
 - - nfs41_server_list_init();
 - -
 - - if (cmd_args.ldap_enable) {
 - - status = nfs41_idmap_create(&(nfs41_dg.idmapper));
 - - if (status) {
 - - eprintf("id mapping initialization failed with %d\n", status);
 - - goto out_logs;
 - + exit(1);
 - + }
 - +
 - + /*
 - + * Set high priority class to avoid that the daemon gets stomped
 - + * by other processes, which might lead to some kind of priority
 - + * inversion
 - + */
 - + if(SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS)) {
 - + dprintf(0, "Running as HIGH_PRIORITY_CLASS\n");
 - + }
 - + else {
 - + eprintf("Failed to enter HIGH_PRIORITY_CLASS mode\n");
 - + }
 - +
 - +#ifdef NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN
 - + /* force enable for cygwin getent passwd/group testing */
 - + cmd_args.ldap_enable = TRUE;
 - + DASSERT(0/* test asserts*/, 0);
 - +#endif /* NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN */
 - +
 - + nfs41_server_list_init();
 - +
 - + if (cmd_args.ldap_enable) {
 - + status = nfs41_idmap_create(&(nfs41_dg.idmapper));
 - + if (status) {
 - + eprintf("id mapping initialization failed with %d\n", status);
 - + goto out_logs;
 - }
 - }
 - @@ -489,17 +503,17 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv)
 - #ifndef STANDALONE_NFSD
 - stop_event = CreateEvent(NULL, TRUE, FALSE, NULL);
 - if (stop_event == NULL)
 - - goto out_pipe;
 - -#endif
 - -
 - - dprintf(1, "Starting %d worker threads...\n",
 - - (int)nfs41_dg.num_worker_threads);
 - - for (i = 0; i < nfs41_dg.num_worker_threads; i++) {
 - - tids[i].handle = (HANDLE)_beginthreadex(NULL, 0, thread_main,
 - - &nfs41_dg, 0, &tids[i].tid);
 - - if (tids[i].handle == INVALID_HANDLE_VALUE) {
 - - status = GetLastError();
 - - eprintf("_beginthreadex failed %d\n", status);
 - + goto out_pipe;
 - +#endif
 - +
 - + dprintf(1, "Starting %d worker threads...\n",
 - + (int)nfs41_dg.num_worker_threads);
 - + for (i = 0; i < nfs41_dg.num_worker_threads; i++) {
 - + tids[i].handle = (HANDLE)_beginthreadex(NULL, 0, thread_main,
 - + &nfs41_dg, 0, &tids[i].tid);
 - + if (tids[i].handle == INVALID_HANDLE_VALUE) {
 - + status = GetLastError();
 - + eprintf("_beginthreadex failed %d\n", status);
 - goto out_pipe;
 - }
 - }
 - @@ -508,22 +522,22 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv)
 - if (!ReportStatusToSCMgr(SERVICE_RUNNING, NO_ERROR, 0))
 - goto out_pipe;
 - WaitForSingleObject(stop_event, INFINITE);
 - -#else
 - - //This can be changed to waiting on an array of handles and using waitformultipleobjects
 - - dprintf(1, "Parent waiting for children threads\n");
 - - for (i = 0; i < nfs41_dg.num_worker_threads; i++)
 - - WaitForSingleObject(tids[i].handle, INFINITE );
 - -#endif
 - - dprintf(1, "Parent woke up!!!!\n");
 - -
 - -out_pipe:
 - - CloseHandle(pipe);
 - -out_idmap:
 - - if (nfs41_dg.idmapper)
 - - nfs41_idmap_free(nfs41_dg.idmapper);
 - -out_logs:
 - -#ifndef STANDALONE_NFSD
 - - close_log_files();
 - +#else
 - + //This can be changed to waiting on an array of handles and using waitformultipleobjects
 - + dprintf(1, "Parent waiting for children threads\n");
 - + for (i = 0; i < nfs41_dg.num_worker_threads; i++)
 - + WaitForSingleObject(tids[i].handle, INFINITE );
 - +#endif
 - + dprintf(1, "Parent woke up!!!!\n");
 - +
 - +out_pipe:
 - + CloseHandle(pipe);
 - +out_idmap:
 - + if (nfs41_dg.idmapper)
 - + nfs41_idmap_free(nfs41_dg.idmapper);
 - +out_logs:
 - +#ifndef STANDALONE_NFSD
 - + close_log_files();
 - #endif
 - return;
 - }
 - diff --git a/daemon/nfs41_ops.c b/daemon/nfs41_ops.c
 - index bcca070..f2a4f22 100644
 - --- a/daemon/nfs41_ops.c
 - +++ b/daemon/nfs41_ops.c
 - @@ -400,6 +400,9 @@ int nfs41_open(
 - bool_t already_delegated = delegation->type == OPEN_DELEGATE_READ
 - || delegation->type == OPEN_DELEGATE_WRITE;
 - + EASSERT(parent);
 - + EASSERT(parent->fh.superblock);
 - +
 - /* depending on the claim type, OPEN expects CURRENT_FH set
 - * to either the parent directory, or to the file itself */
 - switch (claim->claim) {
 - diff --git a/daemon/open.c b/daemon/open.c
 - index 8c01ac1..1cbac2c 100644
 - --- a/daemon/open.c
 - +++ b/daemon/open.c
 - @@ -99,6 +99,24 @@ static void open_state_free(
 - void nfs41_open_state_ref(
 - IN nfs41_open_state *state)
 - {
 - +#if 1
 - + /*
 - + * gisburn: fixme: sometimes this happens under high parallel
 - + * usage with multiple mounts - but why ?
 - + * 0:038> kp
 - + * Child-SP RetAddr Call Site
 - + * 0000006d`431fde10 00007ff7`32f7d905 nfsd!nfs41_open_state_ref(struct __nfs41_open_state * state = 0x00000000`00000000)+0x31
 - + * 0000006d`431fdf30 00007ff7`32f4d284 nfsd!upcall_parse(unsigned char * buffer = 0x0000006d`431fe180 "???", unsigned int length = 8, struct __nfs41_upcall * upcall = 0x0000006d`431ff1e0)+0x2e5
 - + * 0000006d`431fe0b0 00007ffc`1ca24c7c nfsd!thread_main(void * args = 0x00007ff7`32fb6080)+0x144
 - + * 0000006d`431ffe00 00007ffc`4d4b7344 ucrtbased!thread_start<unsigned int (void * parameter = 0x0000025d`a9c6def0)+0x9c
 - + * 0000006d`431ffe60 00007ffc`4efc26b1 KERNEL32!BaseThreadInitThunk+0x14
 - + * 0000006d`431ffe90 00000000`00000000 ntdll!RtlUserThreadStart+0x21
 - + */
 - + EASSERT(state != NULL);
 - + if (state == NULL)
 - + return;
 - +#endif
 - +
 - const LONG count = InterlockedIncrement(&state->ref_count);
 - dprintf(2, "nfs41_open_state_ref(%s) count %d\n", state->path.path, count);
 - diff --git a/daemon/upcall.c b/daemon/upcall.c
 - index bd13c61..7778429 100644
 - --- a/daemon/upcall.c
 - +++ b/daemon/upcall.c
 - @@ -121,6 +121,7 @@ int upcall_parse(
 - /* parse the operation's arguments */
 - op = g_upcall_op_table[upcall->opcode];
 - if (op && op->parse) {
 - + EASSERT(length > 0);
 - status = op->parse(buffer, length, upcall);
 - if (status) {
 - eprintf("parsing of upcall '%s' failed with %d.\n",
 - diff --git a/sys/nfs41_build_features.h b/sys/nfs41_build_features.h
 - index 93ee7a9..d43334a 100644
 - --- a/sys/nfs41_build_features.h
 - +++ b/sys/nfs41_build_features.h
 - @@ -32,19 +32,19 @@
 - /*
 - * NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES - return local uid/gid values
 - */
 - -// #define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
 - +#define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
 - /*
 - * NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID - give NFS
 - * files which do not map to a local account a SID in the
 - * Unix_User+x/Unix_Group+x range
 - */
 - -// #define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
 - +#define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
 - /*
 - * NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN - use Cygwin /usr/bin/getent
 - * as "name service"
 - */
 - -// #define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
 - +#define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
 - #endif /* !_NFS41_DRIVER_BUILDFEATURES_ */
 - diff --git a/tests/winlocktest1/winlocktest1.ksh b/tests/winlocktest1/winlocktest1.ksh
 - old mode 100644
 - new mode 100755
 
msnfs41client: tarball generation prototype+idmapper fix 2023-12-07
Posted by Anonymous on Thu 7th Dec 2023 14:18
raw | new post
view followups (newest first): msnfs41client: diff -w tarball generation prototype+idmapper fix 2023-12-07 by Anonymous
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.
 nrubsig.kpaste.net RSS