pastebin - collaborative debugging tool
rovema.kpaste.net RSS


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

  1. From f82986c2ac380daa6787d1b458c958634729cd7f Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Mon, 2 Sep 2024 14:34:24 +0200
  4. Subject: [PATCH 1/3] build.vc19,sys: Use compiler optimizer+less debug
  5.  messages for Release kernel module
  6.  
  7. Use compiler optimizer+less debug messages for Release kernel module.
  8.  
  9. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  10. ---
  11. build.vc19/nfs41_driver/nfs41_driver.vcxproj | 32 +++++++++++++++-----
  12.  sys/nfs41_driver.c                           | 24 ++++++++++++---
  13.  2 files changed, 44 insertions(+), 12 deletions(-)
  14.  
  15. diff --git a/build.vc19/nfs41_driver/nfs41_driver.vcxproj b/build.vc19/nfs41_driver/nfs41_driver.vcxproj
  16. index a7bff35..6d3a135 100644
  17. --- a/build.vc19/nfs41_driver/nfs41_driver.vcxproj
  18. +++ b/build.vc19/nfs41_driver/nfs41_driver.vcxproj
  19. @@ -137,8 +137,10 @@
  20.      <ClCompile>
  21.        <AdditionalIncludeDirectories>..\..\include;..\..\dll;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  22.        <WarningLevel>Level4</WarningLevel>
  23. -      <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  24. +      <Optimization>Disabled</Optimization>
  25. +      <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  26.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  27. +      <StringPooling>true</StringPooling>
  28.        <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
  29.      </ClCompile>
  30.      <Link>
  31. @@ -149,8 +151,10 @@
  32.      <ClCompile>
  33.        <AdditionalIncludeDirectories>..\..\include;..\..\dll;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  34.        <WarningLevel>Level4</WarningLevel>
  35. -      <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  36. +      <Optimization>MaxSpeed</Optimization>
  37. +      <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  38.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  39. +      <StringPooling>true</StringPooling>
  40.        <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
  41.      </ClCompile>
  42.      <Link>
  43. @@ -161,8 +165,10 @@
  44.      <ClCompile>
  45.        <AdditionalIncludeDirectories>..\..\include;..\..\dll;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  46.        <WarningLevel>Level4</WarningLevel>
  47. -      <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  48. +      <Optimization>Disabled</Optimization>
  49. +      <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  50.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  51. +      <StringPooling>true</StringPooling>
  52.        <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
  53.      </ClCompile>
  54.      <Link>
  55. @@ -173,8 +179,10 @@
  56.      <ClCompile>
  57.        <AdditionalIncludeDirectories>..\..\include;..\..\dll;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  58.        <WarningLevel>Level4</WarningLevel>
  59. -      <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  60. +      <Optimization>MaxSpeed</Optimization>
  61. +      <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  62.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  63. +      <StringPooling>true</StringPooling>
  64.        <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
  65.      </ClCompile>
  66.      <Link>
  67. @@ -185,8 +193,10 @@
  68.      <ClCompile>
  69.        <AdditionalIncludeDirectories>..\..\include;..\..\dll;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  70.        <WarningLevel>Level4</WarningLevel>
  71. -      <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  72. +      <Optimization>Disabled</Optimization>
  73. +      <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  74.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  75. +      <StringPooling>true</StringPooling>
  76.        <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
  77.      </ClCompile>
  78.      <Link>
  79. @@ -197,8 +207,10 @@
  80.      <ClCompile>
  81.        <AdditionalIncludeDirectories>..\..\include;..\..\dll;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  82.        <WarningLevel>Level4</WarningLevel>
  83. -      <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  84. +      <Optimization>MaxSpeed</Optimization>
  85. +      <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  86.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  87. +      <StringPooling>true</StringPooling>
  88.        <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
  89.      </ClCompile>
  90.      <Link>
  91. @@ -209,8 +221,10 @@
  92.      <ClCompile>
  93.        <AdditionalIncludeDirectories>..\..\include;..\..\dll;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  94.        <WarningLevel>Level4</WarningLevel>
  95. -      <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  96. +      <Optimization>Disabled</Optimization>
  97. +      <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  98.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  99. +      <StringPooling>true</StringPooling>
  100.        <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
  101.      </ClCompile>
  102.      <Link>
  103. @@ -221,8 +235,10 @@
  104.      <ClCompile>
  105.        <AdditionalIncludeDirectories>..\..\include;..\..\dll;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  106.        <WarningLevel>Level4</WarningLevel>
  107. -      <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  108. +      <Optimization>MaxSpeed</Optimization>
  109. +      <PreprocessorDefinitions>EXPLODE_POOLTAGS;MONOLITHIC_MINIRDR;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  110.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  111. +      <StringPooling>true</StringPooling>
  112.        <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
  113.      </ClCompile>
  114.      <Link>
  115. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  116. index dfeaa1d..7d72b55 100644
  117. --- a/sys/nfs41_driver.c
  118. +++ b/sys/nfs41_driver.c
  119. @@ -44,6 +44,8 @@
  120.  // #define USE_ENTIRE_PATH_FOR_NETROOT 1
  121.  
  122.  /* debugging printout defines */
  123. +#if defined(_DEBUG)
  124. +/* Debug build defines follow... */
  125.  #define DEBUG_MARSHAL_HEADER
  126.  #define DEBUG_MARSHAL_DETAIL
  127.  //#define DEBUG_MARSHAL_DETAIL_RW
  128. @@ -71,6 +73,12 @@
  129.  
  130.  //#define ENABLE_TIMINGS
  131.  //#define ENABLE_INDV_TIMINGS
  132. +#elif defined(NDEBUG)
  133. +/* Release build defines follow... */
  134. +#else
  135. +#error Neither _DEBUG NOR _NDEBUG defined
  136. +#endif
  137. +
  138.  #ifdef ENABLE_TIMINGS
  139.  typedef struct __nfs41_timings {
  140.      LONG tops, sops;
  141. @@ -673,13 +681,14 @@ static NTSTATUS marshal_nfs41_header(
  142.       */
  143.      if (MmIsAddressValid(entry->filename) &&
  144.          (entry->filename != NULL) &&
  145. -        MmIsAddressValid(entry->filename->Buffer))
  146. +        MmIsAddressValid(entry->filename->Buffer)) {
  147.  #ifdef DEBUG_MARSHAL_HEADER
  148.          DbgP("[upcall header] xid=%lld opcode='%s' filename='%wZ' version=%d "
  149.              "session=0x%x open_state=0x%x\n", entry->xid,
  150.              ENTRY_OPCODE2STRING(entry), entry->filename,
  151.              entry->version, entry->session, entry->open_state);
  152.  #endif /* DEBUG_MARSHAL_HEADER */
  153. +    }
  154.      else {
  155.          DbgP("[upcall header] Invalid filename 0x%p\n", entry);
  156.          status = STATUS_INTERNAL_ERROR;
  157. @@ -5976,9 +5985,9 @@ static NTSTATUS nfs41_QueryFileInformation(
  158.  #ifdef DEBUG_FILE_QUERY
  159.      DbgEn();
  160.      print_debug_filedirquery_header(RxContext);
  161. -#endif
  162.      DbgP("--> nfs41_QueryFileInformation, RxContext->Info.LengthRemaining=%ld\n",
  163.          (long)RxContext->Info.LengthRemaining);
  164. +#endif
  165.  
  166.      status = check_nfs41_dirquery_args(RxContext);
  167.      if (status) {
  168. @@ -5988,8 +5997,10 @@ static NTSTATUS nfs41_QueryFileInformation(
  169.  
  170.      RtlZeroMemory(RxContext->Info.Buffer, RxContext->Info.LengthRemaining);
  171.  
  172. +#ifdef DEBUG_FILE_QUERY
  173.      DbgP("nfs41_QueryFileInformation, RxContext->Info.LengthRemaining=%ld\n",
  174.          (long)RxContext->Info.LengthRemaining);
  175. +#endif
  176.  
  177.      switch (InfoClass) {
  178.      case FileEaInformation:
  179. @@ -6077,7 +6088,9 @@ static NTSTATUS nfs41_QueryFileInformation(
  180.          print_error("entry->status == STATUS_BUFFER_TOO_SMALL\n");
  181.          status = STATUS_BUFFER_TOO_SMALL;
  182.      } else if (entry->status == STATUS_SUCCESS) {
  183. +#ifdef DEBUG_FILE_QUERY
  184.          print_error("entry->status == STATUS_SUCCESS\n");
  185. +#endif
  186.          BOOLEAN DeletePending = FALSE;
  187.  #ifdef ENABLE_TIMINGS
  188.          InterlockedIncrement(&getattr.sops);
  189. @@ -6158,8 +6171,8 @@ out:
  190.  #endif
  191.  #ifdef DEBUG_FILE_QUERY
  192.      DbgEx();
  193. -#endif
  194.      DbgP("<-- nfs41_QueryFileInformation, status=0x%lx\n", (long)status);
  195. +#endif
  196.      return status;
  197.  }
  198.  
  199. @@ -6455,7 +6468,10 @@ static NTSTATUS nfs41_ComputeNewBufferingState(
  200.      OUT ULONG *pNewBufferingState)
  201.  {
  202.      NTSTATUS status = STATUS_SUCCESS;
  203. -    ULONG flag = PtrToUlong(pMRxContext), oldFlags = pSrvOpen->BufferingFlags;
  204. +    ULONG flag = PtrToUlong(pMRxContext);
  205. +#ifdef DEBUG_TIME_BASED_COHERENCY
  206. +    ULONG oldFlags = pSrvOpen->BufferingFlags;
  207. +#endif
  208.  
  209.      switch(flag) {
  210.      case DISABLE_CACHING:
  211. --
  212. 2.45.1
  213.  
  214. From 20f59f5c2fab22d54fd3ac7fb0f7d9b7ac52ca5a Mon Sep 17 00:00:00 2001
  215. From: Roland Mainz <roland.mainz@nrubsig.org>
  216. Date: Tue, 3 Sep 2024 12:06:18 +0200
  217. Subject: [PATCH 2/3] cygwin: mount_sshnfs.ksh should use
  218.  posix=1,notexec,sparse
  219.  
  220. mount_sshnfs.ksh should use the Cygwin mount options
  221. posix=1,notexec,sparse.
  222.  
  223. Reported-by: Martin Wege <martin.l.wege@gmail.com>
  224. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  225. ---
  226. cygwin/utils/mount_sshnfs/mount_sshnfs.ksh | 12 ++++++------
  227.  1 file changed, 6 insertions(+), 6 deletions(-)
  228.  
  229. diff --git a/cygwin/utils/mount_sshnfs/mount_sshnfs.ksh b/cygwin/utils/mount_sshnfs/mount_sshnfs.ksh
  230. index f323382..861a010 100644
  231. --- a/cygwin/utils/mount_sshnfs/mount_sshnfs.ksh
  232. +++ b/cygwin/utils/mount_sshnfs/mount_sshnfs.ksh
  233. @@ -422,7 +422,7 @@ function cmd_mount
  234.  
  235.         # fixme: Need better text layout for $ mount_sshnfs mount --man #
  236.         typeset -r mount_sshnfs_cmdmount_usage=$'+
  237. -       [-?\n@(#)\$Id: mount_sshnfs mount (Roland Mainz) 2024-07-08 \$\n]
  238. +       [-?\n@(#)\$Id: mount_sshnfs mount (Roland Mainz) 2024-09-03 \$\n]
  239.         [-author?Roland Mainz <roland.mainz@nrubsig.org>]
  240.         [+NAME?mount_sshnfs mount - mount NFSv4 filesystem through ssh
  241.                 tunnel]
  242. @@ -701,8 +701,8 @@ function cmd_mount
  243.                                         print -u2 -f $"%s: NFS filesystem mounted to drive %q.\n" \
  244.                                                 "$0" "${c.windows_drive_letter}"
  245.  
  246. -                                       # Cygwin bind mount
  247. -                                       mount -o bind "/cygdrive/${c.windows_drive_letter}" "${c.mountpoint}"
  248. +                                       # Cygwin mount
  249. +                                       mount -o posix=1,notexec,sparse "${c.windows_drive_letter}:" "${c.mountpoint}"
  250.                                 fi
  251.                         else
  252.                                 #
  253. @@ -788,7 +788,7 @@ function cmd_umount
  254.         typeset mydebug=false # fixme: should be "bool" for ksh93v
  255.         # fixme: Need better text layout for $ mount_sshnfs mount --man #
  256.         typeset -r mount_sshnfs_cmdumount_usage=$'+
  257. -       [-?\n@(#)\$Id: mount_sshnfs umount (Roland Mainz) 2024-07-08 \$\n]
  258. +       [-?\n@(#)\$Id: mount_sshnfs umount (Roland Mainz) 2024-09-03 \$\n]
  259.         [-author?Roland Mainz <roland.mainz@nrubsig.org>]
  260.         [+NAME?mount_sshnfs umount - unmount NFSv4 filesystem mounted
  261.                 via mount_sshnfs mount]
  262. @@ -862,7 +862,7 @@ function cmd_umount
  263.                 "${c.msnfsv41_nfsmountcmd}" -d "${mnt_config.windows_drive_letter}"
  264.                 (( retval=$? ))
  265.  
  266. -               # remove the Cygwin bind mount
  267. +               # remove the Cygwin mount
  268.                 (( retval == 0 )) && umount "${c.mountpoint}"
  269.         else
  270.                 umount "${c.mountpoint}"
  271. @@ -892,7 +892,7 @@ function main
  272.  
  273.         # fixme: Need better text layout for $ mount_sshnfs --man #
  274.         typeset -r mount_sshnfs_usage=$'+
  275. -       [-?\n@(#)\$Id: mount_sshnfs (Roland Mainz) 2024-07-08 \$\n]
  276. +       [-?\n@(#)\$Id: mount_sshnfs (Roland Mainz) 2024-09-03 \$\n]
  277.         [-author?Roland Mainz <roland.mainz@nrubsig.org>]
  278.         [+NAME?mount_sshnfs - mount/umount NFSv4 filesystem via ssh
  279.                 tunnel]
  280. --
  281. 2.45.1
  282.  
  283. From e693288dd39d6137620d227301ddaddfb39f6199 Mon Sep 17 00:00:00 2001
  284. From: Roland Mainz <roland.mainz@nrubsig.org>
  285. Date: Tue, 3 Sep 2024 17:49:09 +0200
  286. Subject: [PATCH 3/3] cygwin,dll,nfs41_build_features.h,sys: Implement
  287.  machine-wide/global mounts
  288.  
  289. Implement mounts which are available by all users/logons. Mounts
  290. made by user "SYSTEM"/SYSTEM_LUID are now usable by all users/logons.
  291.  
  292. See $ msnfs41client sys_mount_globaldirs # for an example how
  293. to mount a NFSv4.1 filesystem globally.
  294.  
  295. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  296. ---
  297. cygwin/README.bintarball.txt    |  6 ++-
  298.  cygwin/devel/msnfs41client.bash | 67 +++++++++++++++++++++-------
  299.  dll/nfs41_np.c                  | 79 +++++++++++++++++++++++++--------
  300.  nfs41_build_features.h          |  7 +++
  301.  sys/nfs41_driver.c              | 45 ++++++++++++++++---
  302.  5 files changed, 162 insertions(+), 42 deletions(-)
  303.  mode change 100644 => 100755 cygwin/devel/msnfs41client.bash
  304.  
  305. diff --git a/cygwin/README.bintarball.txt b/cygwin/README.bintarball.txt
  306. index 17fd91f..e64fdc9 100644
  307. --- a/cygwin/README.bintarball.txt
  308. +++ b/cygwin/README.bintarball.txt
  309. @@ -207,7 +207,11 @@ $ sc start ms-nfs41-client-service
  310.  #   "disabled" and therefore always requires a "manual" start (e.g.
  311.  #   $ sc start ms-nfs41-client-service #)
  312.  # - note that DOS devices are virtualised per LSA Logon, so each Logon
  313. -#   needs to do a separare nfs_mount.exe to mount a NFSv4 share
  314. +#   needs to do a separare nfs_mount.exe to mount a NFSv4 share.
  315. +#   The exception are mounts created by user "SYSTEM", such mounts
  316. +#   are available to all users/logons.
  317. +#   (see PsExec or function "su_system" in msnfs41client.bash how
  318. +#   to run a process as user "SYSTEM")
  319.  # - nfsd_debug.exe will run as user "SYSTEM", but will do user
  320.  #   impersonation for each request
  321.  # - stopping the service will NOT unmount filesystems, and due to a
  322. diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
  323. old mode 100644
  324. new mode 100755
  325. index 352344a..dca774f
  326. --- a/cygwin/devel/msnfs41client.bash
  327. +++ b/cygwin/devel/msnfs41client.bash
  328. @@ -25,7 +25,7 @@
  329.  # - PsExec from https://download.sysinternals.com/files/PSTools.zip in /home/roland_mainz/work/win_pstools/)
  330.  # * Usage:
  331.  # Shell1: cd /cygdrive/c/Users/roland_mainz/Downloads/ms-nfs41-client-x64/ms-nfs41-client-x64 && bash ../msnfs41client.bash sys_run_deamon
  332. -# Shell2: cd /cygdrive/c/Users/roland_mainz/Downloads/ms-nfs41-client-x64/ms-nfs41-client-x64 && bash ../msnfs41client.bash sys_mount_homedir
  333. +# Shell2: cd /cygdrive/c/Users/roland_mainz/Downloads/ms-nfs41-client-x64/ms-nfs41-client-x64 && bash ../msnfs41client.bash sys_mount_globaldirs
  334.  #
  335.  
  336.  function is_windows_admin_account
  337. @@ -518,34 +518,55 @@ function watch_kernel_debuglog
  338.         return 0
  339.  }
  340.  
  341. -function nfsclient_mount_homedir
  342. +function nfsclient_system_mount_globaldirs
  343.  {
  344.         set -o xtrace
  345.         set -o nounset
  346.         set -o errexit
  347.  
  348. -       #nfs_mount -p -o sec=sys H 'derfwpc5131:/export/home2/rmainz'
  349. -       #nfs_mount -p -o sec=sys H '[fe80::219:99ff:feae:73ce]:/export/home2/rmainz'
  350. -       nfs_mount -p -o sec=sys H 'derfwpc5131_ipv6linklocal:/export/home2/rmainz'
  351. -       mkdir -p '/home/rmainz'
  352. -       # FIXME: is "notexec" correct in this case =
  353. -       mount -o posix=1,sparse,notexec 'H:' '/home/rmainz'
  354. +       #
  355. +       # ToDo: Add a /etc/fstab.msnfs41client file
  356. +       # which is parsed for NFSv4.1 mounts like Linux/etc/fstab
  357. +       # or SysV/Solaris/Illumos /etc/vfstab
  358. +       #
  359. +
  360. +       # purge any leftover persistent mappings to device P:
  361. +       su_system net use 'P:' /delete || true
  362. +       su_system nfs_mount -o sec=sys,rw 'P' 'nfs://derfwnb4966_ipv6linklocal//bigdisk'
  363. +
  364.         return $?
  365.  }
  366.  
  367. -function nfsclient_system_mount_homedir
  368. +function nfsclient_system_umount_globaldirs
  369.  {
  370.         set -o xtrace
  371.         set -o nounset
  372.         set -o errexit
  373.  
  374. -       # purge any leftover persistent mappings to device H:
  375. -       su_system net use H: /delete || true
  376. +       #
  377. +       # ToDo: Add a /etc/fstab.msnfs41client file
  378. +       # which is parsed for NFSv4.1 mounts like Linux/etc/fstab
  379. +       # or SysV/Solaris/Illumos /etc/vfstab
  380. +       #
  381. +
  382. +       # purge any leftover persistent mappings to device P:
  383. +       su_system net use 'P:' /delete || true
  384.  
  385. -       #su_system nfs_mount -p -o sec=sys H 'derfwpc5131:/export/home2/rmainz'
  386. -       #su_system nfs_mount -p -o sec=sys H '[fe80::219:99ff:feae:73ce]:/export/home2/rmainz'
  387. -       su_system nfs_mount -p -o sec=sys H 'derfwpc5131_ipv6linklocal:/export/home2/rmainz'
  388. +       return $?
  389. +}
  390. +
  391. +function nfsclient_mount_homedir
  392. +{
  393. +       set -o xtrace
  394. +       set -o nounset
  395. +       set -o errexit
  396.  
  397. +       #nfs_mount -p -o sec=sys H 'derfwpc5131:/export/home2/rmainz'
  398. +       #nfs_mount -p -o sec=sys H '[fe80::219:99ff:feae:73ce]:/export/home2/rmainz'
  399. +       nfs_mount -p -o sec=sys H 'derfwpc5131_ipv6linklocal:/export/home2/rmainz'
  400. +       mkdir -p '/home/rmainz'
  401. +       # FIXME: is "notexec" correct in this case ?
  402. +       mount -o posix=1,sparse,notexec 'H:' '/home/rmainz'
  403.         return $?
  404.  }
  405.  
  406. @@ -710,16 +731,30 @@ function main
  407.                         nfsclient_system_rundeamon
  408.                         return $?
  409.                         ;;
  410. -               'sys_mount_homedir')
  411. +               'sys_mount_globaldirs')
  412.                         check_machine_arch || (( numerr++ ))
  413.                         require_cmd 'nfs_mount.exe' || (( numerr++ ))
  414. +                       require_cmd 'PsExec.exe' || (( numerr++ ))
  415. +                       if ! is_windows_admin_account ; then
  416. +                               printf $"%s: %q requires Windows Adminstator permissions.\n" "$0" "$cmd"
  417. +                               (( numerr++ ))
  418. +                       fi
  419. +                       (( numerr > 0 )) && return 1
  420. +
  421. +                       nfsclient_system_mount_globaldirs
  422. +                       return $?
  423. +                       ;;
  424. +               'sys_umount_globaldirs')
  425. +                       check_machine_arch || (( numerr++ ))
  426. +                       require_cmd 'nfs_mount.exe' || (( numerr++ ))
  427. +                       require_cmd 'PsExec.exe' || (( numerr++ ))
  428.                         if ! is_windows_admin_account ; then
  429.                                 printf $"%s: %q requires Windows Adminstator permissions.\n" "$0" "$cmd"
  430.                                 (( numerr++ ))
  431.                         fi
  432.                         (( numerr > 0 )) && return 1
  433.  
  434. -                       nfsclient_system_mount_homedir
  435. +                       nfsclient_system_umount_globaldirs
  436.                         return $?
  437.                         ;;
  438.                 'mount_homedir')
  439. diff --git a/dll/nfs41_np.c b/dll/nfs41_np.c
  440. index 5538ab3..5d2c8eb 100644
  441. --- a/dll/nfs41_np.c
  442. +++ b/dll/nfs41_np.c
  443. @@ -48,6 +48,10 @@
  444.  #define PTR2PTRDIFF_T(p) (((char *)(p))-((char *)0))
  445.  #define HANDLE2INT(h) ((int)PTR2PTRDIFF_T(h))
  446.  
  447. +#ifdef NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL
  448. +const LUID SystemLuid = SYSTEM_LUID;
  449. +#endif /* NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL */
  450. +
  451.  ULONG _cdecl NFS41DbgPrint(__in LPTSTR fmt, ...)
  452.  {
  453.      ULONG rc = 0;
  454. @@ -79,7 +83,7 @@ ULONG _cdecl NFS41DbgPrint(__in LPTSTR fmt, ...)
  455.   * we cannot use |memcpy()|!
  456.   */
  457.  static
  458. -bool equal_luid(LUID *l1, LUID *l2)
  459. +bool equal_luid(const LUID *restrict l1, const LUID *restrict l2)
  460.  {
  461.      return((l1->LowPart == l2->LowPart) &&
  462.          (l1->HighPart == l2->HighPart));
  463. @@ -757,6 +761,7 @@ NPCancelConnection(
  464.          if (pNetResource->InUse) {
  465.              if (
  466.  #ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  467. +                /* Need exact match here, not |SYSTEM_LUID|! */
  468.                  equal_luid(&authenticationid,
  469.                      &pNetResource->MountAuthId) &&
  470.  #endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  471. @@ -844,6 +849,10 @@ NPGetConnection(
  472.  
  473.      INT  Index;
  474.      PNFS41NP_NETRESOURCE pNetResource;
  475. +    PNFS41NP_NETRESOURCE foundNetResource = NULL;
  476. +#ifdef NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL
  477. +    PNFS41NP_NETRESOURCE foundSystemLuidNetResource = NULL;
  478. +#endif /* NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL */
  479.      Status = WN_NOT_CONNECTED;
  480.  
  481.      for (Index = 0; Index < pSharedMemory->NextAvailableIndex; Index++)
  482. @@ -851,31 +860,57 @@ NPGetConnection(
  483.          pNetResource = &pSharedMemory->NetResources[Index];
  484.  
  485.          if (pNetResource->InUse) {
  486. -            if (
  487. -#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  488. -                equal_luid(&authenticationid,
  489. -                    &pNetResource->MountAuthId) &&
  490. -#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  491. -                (((wcslen(lpLocalName)+1)*sizeof(WCHAR)) ==
  492. -
  493. +            if ((((wcslen(lpLocalName)+1)*sizeof(WCHAR)) ==
  494.                      pNetResource->LocalNameLength) &&
  495.                      (!wcscmp(lpLocalName, pNetResource->LocalName))) {
  496. -                if (*lpBufferSize < pNetResource->RemoteNameLength) {
  497. -                    *lpBufferSize = pNetResource->RemoteNameLength;
  498. -                    Status = WN_MORE_DATA;
  499. +#ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  500. +                if (equal_luid(&authenticationid,
  501. +                    &pNetResource->MountAuthId)) {
  502. +                    foundNetResource = pNetResource;
  503. +                    break;
  504.                  }
  505. -                else {
  506. -                    *lpBufferSize = pNetResource->RemoteNameLength;
  507. -                    CopyMemory(lpRemoteName,
  508. -                        pNetResource->RemoteName,
  509. -                        pNetResource->RemoteNameLength);
  510. -                    Status = WN_SUCCESS;
  511. +#ifdef NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL
  512. +                else if (equal_luid(&SystemLuid,
  513. +                    &pNetResource->MountAuthId)) {
  514. +                    /*
  515. +                     * Found netresource for user "SYSTEM", but
  516. +                     * continue searching |pSharedMemory->NetResources|
  517. +                     * for an exact match...
  518. +                     */
  519. +                    foundSystemLuidNetResource = pNetResource;
  520.                  }
  521. -                break;
  522. +#endif /* NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL */
  523. +#else /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  524. +                foundNetResource = pNetResource;
  525. +#endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  526.              }
  527.          }
  528.      }
  529.  
  530. +#ifdef NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL
  531. +    /*
  532. +     * No exact match found ? Then fall-back to any match we found for
  533. +     * user "SYSTEM"
  534. +     */
  535. +    if (foundNetResource == NULL) {
  536. +        foundNetResource = foundSystemLuidNetResource;
  537. +    }
  538. +#endif /* NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL */
  539. +
  540. +    if (foundNetResource) {
  541. +        if (*lpBufferSize < foundNetResource->RemoteNameLength) {
  542. +            *lpBufferSize = foundNetResource->RemoteNameLength;
  543. +            Status = WN_MORE_DATA;
  544. +        }
  545. +        else {
  546. +            *lpBufferSize = foundNetResource->RemoteNameLength;
  547. +            (void)memcpy(lpRemoteName,
  548. +                foundNetResource->RemoteName,
  549. +                foundNetResource->RemoteNameLength);
  550. +            Status = WN_SUCCESS;
  551. +        }
  552. +    }
  553. +
  554.      CloseSharedMemory( &hMutex, &hMemory, (PVOID)&pSharedMemory);
  555.  out:
  556.      DbgP((L"<-- NPGetConnection returns %d\n", (int)Status));
  557. @@ -976,8 +1011,16 @@ NPEnumResource(
  558.  
  559.          if (pNfsNetResource->InUse
  560.  #ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
  561. +#ifdef NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL
  562. +            && (equal_luid(&authenticationid,
  563. +                &pNfsNetResource->MountAuthId) ||
  564. +                equal_luid(&SystemLuid,
  565. +                &pNfsNetResource->MountAuthId)
  566. +            )
  567. +#else /* NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL */
  568.              && equal_luid(&authenticationid,
  569.                  &pNfsNetResource->MountAuthId)
  570. +#endif /* NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL */
  571.  #endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
  572.                  ) {
  573.              SpaceNeeded  = sizeof(NETRESOURCE);
  574. diff --git a/nfs41_build_features.h b/nfs41_build_features.h
  575. index 37c5995..02f2840 100644
  576. --- a/nfs41_build_features.h
  577. +++ b/nfs41_build_features.h
  578. @@ -117,6 +117,13 @@
  579.   */
  580.  #define NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE 1
  581.  
  582. +/*
  583. + * NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL - mounts created
  584. + * with user "SYSTEM" should be available for ALL users on
  585. + * a machine.
  586. + */
  587. +#define NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL 1
  588. +
  589.  /*
  590.   * Default POSIX permission mode bits for new files
  591.   * Can be ovrriden with a "NfsV3Attributes" EA
  592. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  593. index 7d72b55..49a10c5 100644
  594. --- a/sys/nfs41_driver.c
  595. +++ b/sys/nfs41_driver.c
  596. @@ -129,6 +129,10 @@ DECLARE_CONST_ANSI_STRING(NfsV3Attributes, EA_NFSV3ATTRIBUTES);
  597.  DECLARE_CONST_ANSI_STRING(NfsSymlinkTargetName, EA_NFSSYMLINKTARGETNAME);
  598.  DECLARE_CONST_ANSI_STRING(NfsActOnLink, EA_NFSACTONLINK);
  599.  
  600. +#ifdef NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL
  601. +const LUID SystemLuid = SYSTEM_LUID;
  602. +#endif /* NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL */
  603. +
  604.  INLINE BOOL AnsiStrEq(
  605.      IN const ANSI_STRING *lhs,
  606.      IN const CHAR *rhs,
  607. @@ -3511,6 +3515,10 @@ static NTSTATUS nfs41_CreateVNetRoot(
  608.  #endif
  609.  
  610.          PLIST_ENTRY pEntry;
  611. +        nfs41_mount_entry *found_mount_entry = NULL;
  612. +#ifdef NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL
  613. +        nfs41_mount_entry *found_system_mount_entry = NULL;
  614. +#endif /* NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL */
  615.  
  616.          status = STATUS_NFS_SHARE_NOT_MOUNTED;
  617.  
  618. @@ -3531,19 +3539,42 @@ static NTSTATUS nfs41_CreateVNetRoot(
  619.  #endif
  620.  
  621.              if (RtlEqualLuid(&luid, &existing_mount->login_id)) {
  622. -                /* found existing mount */
  623. -                copy_nfs41_mount_config(Config, &existing_mount->Config);
  624. -                DbgP("Found existing mount: LUID=(0x%lx.0x%lx) Entry Config->MntPt='%wZ'\n",
  625. -                    (long)existing_mount->login_id.HighPart,
  626. -                    (long)existing_mount->login_id.LowPart,
  627. -                    &Config->MntPt);
  628. -                status = STATUS_SUCCESS;
  629. +                /* found existing mount with exact LUID match */
  630. +                found_mount_entry = existing_mount;
  631.                  break;
  632.              }
  633. +#ifdef NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL
  634. +            else if (RtlEqualLuid(&SystemLuid,
  635. +                &existing_mount->login_id)) {
  636. +                /*
  637. +                 * found existing mount for user "SYSTEM"
  638. +                 * We continue searching the |pNetRootContext->mounts|
  639. +                 * list for an exact match ...
  640. +                 */
  641. +                found_system_mount_entry = existing_mount;
  642. +            }
  643. +#endif /* NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL */
  644.              if (pEntry->Flink == &pNetRootContext->mounts.head)
  645.                  break;
  646.              pEntry = pEntry->Flink;
  647.          }
  648. +
  649. +        if (found_mount_entry) {
  650. +            copy_nfs41_mount_config(Config, &found_mount_entry->Config);
  651. +            DbgP("Found existing mount: LUID=(0x%lx.0x%lx) Entry Config->MntPt='%wZ'\n",
  652. +                (long)found_mount_entry->login_id.HighPart,
  653. +                (long)found_mount_entry->login_id.LowPart,
  654. +                &Config->MntPt);
  655. +            status = STATUS_SUCCESS;
  656. +        }
  657. +#ifdef NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL
  658. +        else if (found_system_mount_entry) {
  659. +            copy_nfs41_mount_config(Config, &found_system_mount_entry->Config);
  660. +            DbgP("Found existing SYSTEM mount: Entry Config->MntPt='%wZ'\n",
  661. +                &Config->MntPt);
  662. +            status = STATUS_SUCCESS;
  663. +        }
  664. +#endif /* NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL */
  665.          ExReleaseFastMutex(&pNetRootContext->mountLock);
  666.  
  667.          if (status != STATUS_SUCCESS) {
  668. --
  669. 2.45.1

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.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at