- From f82986c2ac380daa6787d1b458c958634729cd7f Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 2 Sep 2024 14:34:24 +0200
- Subject: [PATCH 1/3] build.vc19,sys: Use compiler optimizer+less debug
- messages for Release kernel module
- Use compiler optimizer+less debug messages for Release kernel module.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- build.vc19/nfs41_driver/nfs41_driver.vcxproj | 32 +++++++++++++++-----
- sys/nfs41_driver.c | 24 ++++++++++++---
- 2 files changed, 44 insertions(+), 12 deletions(-)
- diff --git a/build.vc19/nfs41_driver/nfs41_driver.vcxproj b/build.vc19/nfs41_driver/nfs41_driver.vcxproj
- index a7bff35..6d3a135 100644
- --- a/build.vc19/nfs41_driver/nfs41_driver.vcxproj
- +++ b/build.vc19/nfs41_driver/nfs41_driver.vcxproj
- @@ -137,8 +137,10 @@
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\include;..\..\dll;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <WarningLevel>Level4</WarningLevel>
- - <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <Optimization>Disabled</Optimization>
- + <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- + <StringPooling>true</StringPooling>
- <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
- </ClCompile>
- <Link>
- @@ -149,8 +151,10 @@
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\include;..\..\dll;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <WarningLevel>Level4</WarningLevel>
- - <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <Optimization>MaxSpeed</Optimization>
- + <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- + <StringPooling>true</StringPooling>
- <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
- </ClCompile>
- <Link>
- @@ -161,8 +165,10 @@
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\include;..\..\dll;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <WarningLevel>Level4</WarningLevel>
- - <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <Optimization>Disabled</Optimization>
- + <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- + <StringPooling>true</StringPooling>
- <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
- </ClCompile>
- <Link>
- @@ -173,8 +179,10 @@
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\include;..\..\dll;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <WarningLevel>Level4</WarningLevel>
- - <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <Optimization>MaxSpeed</Optimization>
- + <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- + <StringPooling>true</StringPooling>
- <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
- </ClCompile>
- <Link>
- @@ -185,8 +193,10 @@
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\include;..\..\dll;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <WarningLevel>Level4</WarningLevel>
- - <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <Optimization>Disabled</Optimization>
- + <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- + <StringPooling>true</StringPooling>
- <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
- </ClCompile>
- <Link>
- @@ -197,8 +207,10 @@
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\include;..\..\dll;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <WarningLevel>Level4</WarningLevel>
- - <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <Optimization>MaxSpeed</Optimization>
- + <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- + <StringPooling>true</StringPooling>
- <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
- </ClCompile>
- <Link>
- @@ -209,8 +221,10 @@
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\include;..\..\dll;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <WarningLevel>Level4</WarningLevel>
- - <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <Optimization>Disabled</Optimization>
- + <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- + <StringPooling>true</StringPooling>
- <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
- </ClCompile>
- <Link>
- @@ -221,8 +235,10 @@
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\include;..\..\dll;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <WarningLevel>Level4</WarningLevel>
- - <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- + <Optimization>MaxSpeed</Optimization>
- + <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- + <StringPooling>true</StringPooling>
- <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
- </ClCompile>
- <Link>
- diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
- index dfeaa1d..7d72b55 100644
- --- a/sys/nfs41_driver.c
- +++ b/sys/nfs41_driver.c
- @@ -44,6 +44,8 @@
- // #define USE_ENTIRE_PATH_FOR_NETROOT 1
- /* debugging printout defines */
- +#if defined(_DEBUG)
- +/* Debug build defines follow... */
- #define DEBUG_MARSHAL_HEADER
- #define DEBUG_MARSHAL_DETAIL
- //#define DEBUG_MARSHAL_DETAIL_RW
- @@ -71,6 +73,12 @@
- //#define ENABLE_TIMINGS
- //#define ENABLE_INDV_TIMINGS
- +#elif defined(NDEBUG)
- +/* Release build defines follow... */
- +#else
- +#error Neither _DEBUG NOR _NDEBUG defined
- +#endif
- +
- #ifdef ENABLE_TIMINGS
- typedef struct __nfs41_timings {
- LONG tops, sops;
- @@ -673,13 +681,14 @@ static NTSTATUS marshal_nfs41_header(
- */
- if (MmIsAddressValid(entry->filename) &&
- (entry->filename != NULL) &&
- - MmIsAddressValid(entry->filename->Buffer))
- + MmIsAddressValid(entry->filename->Buffer)) {
- #ifdef DEBUG_MARSHAL_HEADER
- DbgP("[upcall header] xid=%lld opcode='%s' filename='%wZ' version=%d "
- "session=0x%x open_state=0x%x\n", entry->xid,
- ENTRY_OPCODE2STRING(entry), entry->filename,
- entry->version, entry->session, entry->open_state);
- #endif /* DEBUG_MARSHAL_HEADER */
- + }
- else {
- DbgP("[upcall header] Invalid filename 0x%p\n", entry);
- status = STATUS_INTERNAL_ERROR;
- @@ -5976,9 +5985,9 @@ static NTSTATUS nfs41_QueryFileInformation(
- #ifdef DEBUG_FILE_QUERY
- DbgEn();
- print_debug_filedirquery_header(RxContext);
- -#endif
- DbgP("--> nfs41_QueryFileInformation, RxContext->Info.LengthRemaining=%ld\n",
- (long)RxContext->Info.LengthRemaining);
- +#endif
- status = check_nfs41_dirquery_args(RxContext);
- if (status) {
- @@ -5988,8 +5997,10 @@ static NTSTATUS nfs41_QueryFileInformation(
- RtlZeroMemory(RxContext->Info.Buffer, RxContext->Info.LengthRemaining);
- +#ifdef DEBUG_FILE_QUERY
- DbgP("nfs41_QueryFileInformation, RxContext->Info.LengthRemaining=%ld\n",
- (long)RxContext->Info.LengthRemaining);
- +#endif
- switch (InfoClass) {
- case FileEaInformation:
- @@ -6077,7 +6088,9 @@ static NTSTATUS nfs41_QueryFileInformation(
- print_error("entry->status == STATUS_BUFFER_TOO_SMALL\n");
- status = STATUS_BUFFER_TOO_SMALL;
- } else if (entry->status == STATUS_SUCCESS) {
- +#ifdef DEBUG_FILE_QUERY
- print_error("entry->status == STATUS_SUCCESS\n");
- +#endif
- BOOLEAN DeletePending = FALSE;
- #ifdef ENABLE_TIMINGS
- InterlockedIncrement(&getattr.sops);
- @@ -6158,8 +6171,8 @@ out:
- #endif
- #ifdef DEBUG_FILE_QUERY
- DbgEx();
- -#endif
- DbgP("<-- nfs41_QueryFileInformation, status=0x%lx\n", (long)status);
- +#endif
- return status;
- }
- @@ -6455,7 +6468,10 @@ static NTSTATUS nfs41_ComputeNewBufferingState(
- OUT ULONG *pNewBufferingState)
- {
- NTSTATUS status = STATUS_SUCCESS;
- - ULONG flag = PtrToUlong(pMRxContext), oldFlags = pSrvOpen->BufferingFlags;
- + ULONG flag = PtrToUlong(pMRxContext);
- +#ifdef DEBUG_TIME_BASED_COHERENCY
- + ULONG oldFlags = pSrvOpen->BufferingFlags;
- +#endif
- switch(flag) {
- case DISABLE_CACHING:
- --
- 2.45.1
- From 20f59f5c2fab22d54fd3ac7fb0f7d9b7ac52ca5a Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 3 Sep 2024 12:06:18 +0200
- Subject: [PATCH 2/3] cygwin: mount_sshnfs.ksh should use
- posix=1,notexec,sparse
- mount_sshnfs.ksh should use the Cygwin mount options
- posix=1,notexec,sparse.
- Reported-by: Martin Wege <martin.l.wege@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/utils/mount_sshnfs/mount_sshnfs.ksh | 12 ++++++------
- 1 file changed, 6 insertions(+), 6 deletions(-)
- diff --git a/cygwin/utils/mount_sshnfs/mount_sshnfs.ksh b/cygwin/utils/mount_sshnfs/mount_sshnfs.ksh
- index f323382..861a010 100644
- --- a/cygwin/utils/mount_sshnfs/mount_sshnfs.ksh
- +++ b/cygwin/utils/mount_sshnfs/mount_sshnfs.ksh
- @@ -422,7 +422,7 @@ function cmd_mount
- # fixme: Need better text layout for $ mount_sshnfs mount --man #
- typeset -r mount_sshnfs_cmdmount_usage=$'+
- - [-?\n@(#)\$Id: mount_sshnfs mount (Roland Mainz) 2024-07-08 \$\n]
- + [-?\n@(#)\$Id: mount_sshnfs mount (Roland Mainz) 2024-09-03 \$\n]
- [-author?Roland Mainz <roland.mainz@nrubsig.org>]
- [+NAME?mount_sshnfs mount - mount NFSv4 filesystem through ssh
- tunnel]
- @@ -701,8 +701,8 @@ function cmd_mount
- print -u2 -f $"%s: NFS filesystem mounted to drive %q.\n" \
- "$0" "${c.windows_drive_letter}"
- - # Cygwin bind mount
- - mount -o bind "/cygdrive/${c.windows_drive_letter}" "${c.mountpoint}"
- + # Cygwin mount
- + mount -o posix=1,notexec,sparse "${c.windows_drive_letter}:" "${c.mountpoint}"
- fi
- else
- #
- @@ -788,7 +788,7 @@ function cmd_umount
- typeset mydebug=false # fixme: should be "bool" for ksh93v
- # fixme: Need better text layout for $ mount_sshnfs mount --man #
- typeset -r mount_sshnfs_cmdumount_usage=$'+
- - [-?\n@(#)\$Id: mount_sshnfs umount (Roland Mainz) 2024-07-08 \$\n]
- + [-?\n@(#)\$Id: mount_sshnfs umount (Roland Mainz) 2024-09-03 \$\n]
- [-author?Roland Mainz <roland.mainz@nrubsig.org>]
- [+NAME?mount_sshnfs umount - unmount NFSv4 filesystem mounted
- via mount_sshnfs mount]
- @@ -862,7 +862,7 @@ function cmd_umount
- "${c.msnfsv41_nfsmountcmd}" -d "${mnt_config.windows_drive_letter}"
- (( retval=$? ))
- - # remove the Cygwin bind mount
- + # remove the Cygwin mount
- (( retval == 0 )) && umount "${c.mountpoint}"
- else
- umount "${c.mountpoint}"
- @@ -892,7 +892,7 @@ function main
- # fixme: Need better text layout for $ mount_sshnfs --man #
- typeset -r mount_sshnfs_usage=$'+
- - [-?\n@(#)\$Id: mount_sshnfs (Roland Mainz) 2024-07-08 \$\n]
- + [-?\n@(#)\$Id: mount_sshnfs (Roland Mainz) 2024-09-03 \$\n]
- [-author?Roland Mainz <roland.mainz@nrubsig.org>]
- [+NAME?mount_sshnfs - mount/umount NFSv4 filesystem via ssh
- tunnel]
- --
- 2.45.1
- From e693288dd39d6137620d227301ddaddfb39f6199 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 3 Sep 2024 17:49:09 +0200
- Subject: [PATCH 3/3] cygwin,dll,nfs41_build_features.h,sys: Implement
- machine-wide/global mounts
- Implement mounts which are available by all users/logons. Mounts
- made by user "SYSTEM"/SYSTEM_LUID are now usable by all users/logons.
- See $ msnfs41client sys_mount_globaldirs # for an example how
- to mount a NFSv4.1 filesystem globally.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/README.bintarball.txt | 6 ++-
- cygwin/devel/msnfs41client.bash | 67 +++++++++++++++++++++-------
- dll/nfs41_np.c | 79 +++++++++++++++++++++++++--------
- nfs41_build_features.h | 7 +++
- sys/nfs41_driver.c | 45 ++++++++++++++++---
- 5 files changed, 162 insertions(+), 42 deletions(-)
- mode change 100644 => 100755 cygwin/devel/msnfs41client.bash
- diff --git a/cygwin/README.bintarball.txt b/cygwin/README.bintarball.txt
- index 17fd91f..e64fdc9 100644
- --- a/cygwin/README.bintarball.txt
- +++ b/cygwin/README.bintarball.txt
- @@ -207,7 +207,11 @@ $ sc start ms-nfs41-client-service
- # "disabled" and therefore always requires a "manual" start (e.g.
- # $ sc start ms-nfs41-client-service #)
- # - note that DOS devices are virtualised per LSA Logon, so each Logon
- -# needs to do a separare nfs_mount.exe to mount a NFSv4 share
- +# needs to do a separare nfs_mount.exe to mount a NFSv4 share.
- +# The exception are mounts created by user "SYSTEM", such mounts
- +# are available to all users/logons.
- +# (see PsExec or function "su_system" in msnfs41client.bash how
- +# to run a process as user "SYSTEM")
- # - nfsd_debug.exe will run as user "SYSTEM", but will do user
- # impersonation for each request
- # - stopping the service will NOT unmount filesystems, and due to a
- diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
- old mode 100644
- new mode 100755
- index 352344a..dca774f
- --- a/cygwin/devel/msnfs41client.bash
- +++ b/cygwin/devel/msnfs41client.bash
- @@ -25,7 +25,7 @@
- # - PsExec from https://download.sysinternals.com/files/PSTools.zip in /home/roland_mainz/work/win_pstools/)
- # * Usage:
- # Shell1: cd /cygdrive/c/Users/roland_mainz/Downloads/ms-nfs41-client-x64/ms-nfs41-client-x64 && bash ../msnfs41client.bash sys_run_deamon
- -# Shell2: cd /cygdrive/c/Users/roland_mainz/Downloads/ms-nfs41-client-x64/ms-nfs41-client-x64 && bash ../msnfs41client.bash sys_mount_homedir
- +# Shell2: cd /cygdrive/c/Users/roland_mainz/Downloads/ms-nfs41-client-x64/ms-nfs41-client-x64 && bash ../msnfs41client.bash sys_mount_globaldirs
- #
- function is_windows_admin_account
- @@ -518,34 +518,55 @@ function watch_kernel_debuglog
- return 0
- }
- -function nfsclient_mount_homedir
- +function nfsclient_system_mount_globaldirs
- {
- set -o xtrace
- set -o nounset
- set -o errexit
- - #nfs_mount -p -o sec=sys H 'derfwpc5131:/export/home2/rmainz'
- - #nfs_mount -p -o sec=sys H '[fe80::219:99ff:feae:73ce]:/export/home2/rmainz'
- - nfs_mount -p -o sec=sys H 'derfwpc5131_ipv6linklocal:/export/home2/rmainz'
- - mkdir -p '/home/rmainz'
- - # FIXME: is "notexec" correct in this case =
- - mount -o posix=1,sparse,notexec 'H:' '/home/rmainz'
- + #
- + # ToDo: Add a /etc/fstab.msnfs41client file
- + # which is parsed for NFSv4.1 mounts like Linux/etc/fstab
- + # or SysV/Solaris/Illumos /etc/vfstab
- + #
- +
- + # purge any leftover persistent mappings to device P:
- + su_system net use 'P:' /delete || true
- + su_system nfs_mount -o sec=sys,rw 'P' 'nfs://derfwnb4966_ipv6linklocal//bigdisk'
- +
- return $?
- }
- -function nfsclient_system_mount_homedir
- +function nfsclient_system_umount_globaldirs
- {
- set -o xtrace
- set -o nounset
- set -o errexit
- - # purge any leftover persistent mappings to device H:
- - su_system net use H: /delete || true
- + #
- + # ToDo: Add a /etc/fstab.msnfs41client file
- + # which is parsed for NFSv4.1 mounts like Linux/etc/fstab
- + # or SysV/Solaris/Illumos /etc/vfstab
- + #
- +
- + # purge any leftover persistent mappings to device P:
- + su_system net use 'P:' /delete || true
- - #su_system nfs_mount -p -o sec=sys H 'derfwpc5131:/export/home2/rmainz'
- - #su_system nfs_mount -p -o sec=sys H '[fe80::219:99ff:feae:73ce]:/export/home2/rmainz'
- - su_system nfs_mount -p -o sec=sys H 'derfwpc5131_ipv6linklocal:/export/home2/rmainz'
- + return $?
- +}
- +
- +function nfsclient_mount_homedir
- +{
- + set -o xtrace
- + set -o nounset
- + set -o errexit
- + #nfs_mount -p -o sec=sys H 'derfwpc5131:/export/home2/rmainz'
- + #nfs_mount -p -o sec=sys H '[fe80::219:99ff:feae:73ce]:/export/home2/rmainz'
- + nfs_mount -p -o sec=sys H 'derfwpc5131_ipv6linklocal:/export/home2/rmainz'
- + mkdir -p '/home/rmainz'
- + # FIXME: is "notexec" correct in this case ?
- + mount -o posix=1,sparse,notexec 'H:' '/home/rmainz'
- return $?
- }
- @@ -710,16 +731,30 @@ function main
- nfsclient_system_rundeamon
- return $?
- ;;
- - 'sys_mount_homedir')
- + 'sys_mount_globaldirs')
- check_machine_arch || (( numerr++ ))
- require_cmd 'nfs_mount.exe' || (( numerr++ ))
- + require_cmd 'PsExec.exe' || (( numerr++ ))
- + if ! is_windows_admin_account ; then
- + printf $"%s: %q requires Windows Adminstator permissions.\n" "$0" "$cmd"
- + (( numerr++ ))
- + fi
- + (( numerr > 0 )) && return 1
- +
- + nfsclient_system_mount_globaldirs
- + return $?
- + ;;
- + 'sys_umount_globaldirs')
- + check_machine_arch || (( numerr++ ))
- + require_cmd 'nfs_mount.exe' || (( numerr++ ))
- + require_cmd 'PsExec.exe' || (( numerr++ ))
- if ! is_windows_admin_account ; then
- printf $"%s: %q requires Windows Adminstator permissions.\n" "$0" "$cmd"
- (( numerr++ ))
- fi
- (( numerr > 0 )) && return 1
- - nfsclient_system_mount_homedir
- + nfsclient_system_umount_globaldirs
- return $?
- ;;
- 'mount_homedir')
- diff --git a/dll/nfs41_np.c b/dll/nfs41_np.c
- index 5538ab3..5d2c8eb 100644
- --- a/dll/nfs41_np.c
- +++ b/dll/nfs41_np.c
- @@ -48,6 +48,10 @@
- #define PTR2PTRDIFF_T(p) (((char *)(p))-((char *)0))
- #define HANDLE2INT(h) ((int)PTR2PTRDIFF_T(h))
- +#ifdef NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL
- +const LUID SystemLuid = SYSTEM_LUID;
- +#endif /* NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL */
- +
- ULONG _cdecl NFS41DbgPrint(__in LPTSTR fmt, ...)
- {
- ULONG rc = 0;
- @@ -79,7 +83,7 @@ ULONG _cdecl NFS41DbgPrint(__in LPTSTR fmt, ...)
- * we cannot use |memcpy()|!
- */
- static
- -bool equal_luid(LUID *l1, LUID *l2)
- +bool equal_luid(const LUID *restrict l1, const LUID *restrict l2)
- {
- return((l1->LowPart == l2->LowPart) &&
- (l1->HighPart == l2->HighPart));
- @@ -757,6 +761,7 @@ NPCancelConnection(
- if (pNetResource->InUse) {
- if (
- #ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
- + /* Need exact match here, not |SYSTEM_LUID|! */
- equal_luid(&authenticationid,
- &pNetResource->MountAuthId) &&
- #endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
- @@ -844,6 +849,10 @@ NPGetConnection(
- INT Index;
- PNFS41NP_NETRESOURCE pNetResource;
- + PNFS41NP_NETRESOURCE foundNetResource = NULL;
- +#ifdef NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL
- + PNFS41NP_NETRESOURCE foundSystemLuidNetResource = NULL;
- +#endif /* NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL */
- Status = WN_NOT_CONNECTED;
- for (Index = 0; Index < pSharedMemory->NextAvailableIndex; Index++)
- @@ -851,31 +860,57 @@ NPGetConnection(
- pNetResource = &pSharedMemory->NetResources[Index];
- if (pNetResource->InUse) {
- - if (
- -#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
- - equal_luid(&authenticationid,
- - &pNetResource->MountAuthId) &&
- -#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
- - (((wcslen(lpLocalName)+1)*sizeof(WCHAR)) ==
- -
- + if ((((wcslen(lpLocalName)+1)*sizeof(WCHAR)) ==
- pNetResource->LocalNameLength) &&
- (!wcscmp(lpLocalName, pNetResource->LocalName))) {
- - if (*lpBufferSize < pNetResource->RemoteNameLength) {
- - *lpBufferSize = pNetResource->RemoteNameLength;
- - Status = WN_MORE_DATA;
- +#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
- + if (equal_luid(&authenticationid,
- + &pNetResource->MountAuthId)) {
- + foundNetResource = pNetResource;
- + break;
- }
- - else {
- - *lpBufferSize = pNetResource->RemoteNameLength;
- - CopyMemory(lpRemoteName,
- - pNetResource->RemoteName,
- - pNetResource->RemoteNameLength);
- - Status = WN_SUCCESS;
- +#ifdef NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL
- + else if (equal_luid(&SystemLuid,
- + &pNetResource->MountAuthId)) {
- + /*
- + * Found netresource for user "SYSTEM", but
- + * continue searching |pSharedMemory->NetResources|
- + * for an exact match...
- + */
- + foundSystemLuidNetResource = pNetResource;
- }
- - break;
- +#endif /* NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL */
- +#else /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
- + foundNetResource = pNetResource;
- +#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
- }
- }
- }
- +#ifdef NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL
- + /*
- + * No exact match found ? Then fall-back to any match we found for
- + * user "SYSTEM"
- + */
- + if (foundNetResource == NULL) {
- + foundNetResource = foundSystemLuidNetResource;
- + }
- +#endif /* NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL */
- +
- + if (foundNetResource) {
- + if (*lpBufferSize < foundNetResource->RemoteNameLength) {
- + *lpBufferSize = foundNetResource->RemoteNameLength;
- + Status = WN_MORE_DATA;
- + }
- + else {
- + *lpBufferSize = foundNetResource->RemoteNameLength;
- + (void)memcpy(lpRemoteName,
- + foundNetResource->RemoteName,
- + foundNetResource->RemoteNameLength);
- + Status = WN_SUCCESS;
- + }
- + }
- +
- CloseSharedMemory( &hMutex, &hMemory, (PVOID)&pSharedMemory);
- out:
- DbgP((L"<-- NPGetConnection returns %d\n", (int)Status));
- @@ -976,8 +1011,16 @@ NPEnumResource(
- if (pNfsNetResource->InUse
- #ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
- +#ifdef NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL
- + && (equal_luid(&authenticationid,
- + &pNfsNetResource->MountAuthId) ||
- + equal_luid(&SystemLuid,
- + &pNfsNetResource->MountAuthId)
- + )
- +#else /* NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL */
- && equal_luid(&authenticationid,
- &pNfsNetResource->MountAuthId)
- +#endif /* NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL */
- #endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
- ) {
- SpaceNeeded = sizeof(NETRESOURCE);
- diff --git a/nfs41_build_features.h b/nfs41_build_features.h
- index 37c5995..02f2840 100644
- --- a/nfs41_build_features.h
- +++ b/nfs41_build_features.h
- @@ -117,6 +117,13 @@
- */
- #define NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE 1
- +/*
- + * NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL - mounts created
- + * with user "SYSTEM" should be available for ALL users on
- + * a machine.
- + */
- +#define NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL 1
- +
- /*
- * Default POSIX permission mode bits for new files
- * Can be ovrriden with a "NfsV3Attributes" EA
- diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
- index 7d72b55..49a10c5 100644
- --- a/sys/nfs41_driver.c
- +++ b/sys/nfs41_driver.c
- @@ -129,6 +129,10 @@ DECLARE_CONST_ANSI_STRING(NfsV3Attributes, EA_NFSV3ATTRIBUTES);
- DECLARE_CONST_ANSI_STRING(NfsSymlinkTargetName, EA_NFSSYMLINKTARGETNAME);
- DECLARE_CONST_ANSI_STRING(NfsActOnLink, EA_NFSACTONLINK);
- +#ifdef NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL
- +const LUID SystemLuid = SYSTEM_LUID;
- +#endif /* NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL */
- +
- INLINE BOOL AnsiStrEq(
- IN const ANSI_STRING *lhs,
- IN const CHAR *rhs,
- @@ -3511,6 +3515,10 @@ static NTSTATUS nfs41_CreateVNetRoot(
- #endif
- PLIST_ENTRY pEntry;
- + nfs41_mount_entry *found_mount_entry = NULL;
- +#ifdef NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL
- + nfs41_mount_entry *found_system_mount_entry = NULL;
- +#endif /* NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL */
- status = STATUS_NFS_SHARE_NOT_MOUNTED;
- @@ -3531,19 +3539,42 @@ static NTSTATUS nfs41_CreateVNetRoot(
- #endif
- if (RtlEqualLuid(&luid, &existing_mount->login_id)) {
- - /* found existing mount */
- - copy_nfs41_mount_config(Config, &existing_mount->Config);
- - DbgP("Found existing mount: LUID=(0x%lx.0x%lx) Entry Config->MntPt='%wZ'\n",
- - (long)existing_mount->login_id.HighPart,
- - (long)existing_mount->login_id.LowPart,
- - &Config->MntPt);
- - status = STATUS_SUCCESS;
- + /* found existing mount with exact LUID match */
- + found_mount_entry = existing_mount;
- break;
- }
- +#ifdef NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL
- + else if (RtlEqualLuid(&SystemLuid,
- + &existing_mount->login_id)) {
- + /*
- + * found existing mount for user "SYSTEM"
- + * We continue searching the |pNetRootContext->mounts|
- + * list for an exact match ...
- + */
- + found_system_mount_entry = existing_mount;
- + }
- +#endif /* NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL */
- if (pEntry->Flink == &pNetRootContext->mounts.head)
- break;
- pEntry = pEntry->Flink;
- }
- +
- + if (found_mount_entry) {
- + copy_nfs41_mount_config(Config, &found_mount_entry->Config);
- + DbgP("Found existing mount: LUID=(0x%lx.0x%lx) Entry Config->MntPt='%wZ'\n",
- + (long)found_mount_entry->login_id.HighPart,
- + (long)found_mount_entry->login_id.LowPart,
- + &Config->MntPt);
- + status = STATUS_SUCCESS;
- + }
- +#ifdef NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL
- + else if (found_system_mount_entry) {
- + copy_nfs41_mount_config(Config, &found_system_mount_entry->Config);
- + DbgP("Found existing SYSTEM mount: Entry Config->MntPt='%wZ'\n",
- + &Config->MntPt);
- + status = STATUS_SUCCESS;
- + }
- +#endif /* NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL */
- ExReleaseFastMutex(&pNetRootContext->mountLock);
- if (status != STATUS_SUCCESS) {
- --
- 2.45.1
msnfs41client: Patches for global/machine-wide NFS mounts, optimized builds+misc, 2024-09-03
Posted by Anonymous on Tue 3rd Sep 2024 17:01
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.