pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for Win32 named stream support, FreeBSD fixes, sparse streams, docs+misc, 2026-01-07
Posted by Anonymous on Wed 7th Jan 2026 12:50
raw | new post

  1. From 597fcd878fc4f00503bfc83e983a4d92493735f5 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Tue, 6 Jan 2026 19:16:17 +0100
  4. Subject: [PATCH 1/7] daemon: Fix lock setup in |nfs41_lookup()|
  5.  
  6. Fix lock setup in |nfs41_lookup()|, a SRWLock cannot be copied.
  7.  
  8. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  9. ---
  10. daemon/lookup.c | 3 ++-
  11.  1 file changed, 2 insertions(+), 1 deletion(-)
  12.  
  13. diff --git a/daemon/lookup.c b/daemon/lookup.c
  14. index 39074e2..6dd5905 100644
  15. --- a/daemon/lookup.c
  16. +++ b/daemon/lookup.c
  17. @@ -539,12 +539,13 @@ int nfs41_lookup(
  18.                  /*
  19.                   * Recursively lookup the base file ...
  20.                   */
  21. -                nfs41_abs_path base_path = path;
  22. +                nfs41_abs_path base_path;
  23.                  size_t base_len = strlen(base_name);
  24.  
  25.                  (void)memcpy(base_path.path, base_name, base_len);
  26.                  base_path.path[base_len] = '\0';
  27.                  base_path.len = (unsigned short)base_len;
  28. +                InitializeSRWLock(&base_path.lock);
  29.  
  30.                  nfs41_path_fh attr_target;
  31.                  if (target_out == NULL) {
  32. --
  33. 2.51.0
  34.  
  35. From d4b0f4c3c07a4608e9d25ec280ff73128c6f4002 Mon Sep 17 00:00:00 2001
  36. From: Cedric Blancher <cedric.blancher@gmail.com>
  37. Date: Tue, 6 Jan 2026 19:22:40 +0100
  38. Subject: [PATCH 2/7] tests: Update FreeBSD NFS server setup instructions for
  39.  FreeBSD 15.0 with NFSv4.1 named attributes
  40.  
  41. Update FreeBSD NFS server setup instructions for FreeBSD 15.0 with
  42. NFSv4/NFSv4.1 named attributes.
  43.  
  44. Signed-off-by: Roland Mainz <roland.mainz@nrubsig.org>
  45. ---
  46. tests/nfs_server_setup.txt | 9 ++++++++-
  47.  1 file changed, 8 insertions(+), 1 deletion(-)
  48.  
  49. diff --git a/tests/nfs_server_setup.txt b/tests/nfs_server_setup.txt
  50. index cafdaeb..65512aa 100644
  51. --- a/tests/nfs_server_setup.txt
  52. +++ b/tests/nfs_server_setup.txt
  53. @@ -205,7 +205,7 @@ See https://docs.oracle.com/en/operating-systems/solaris/oracle-solaris/11.4/man
  54.  
  55.  #
  56.  # FreeBSD NFSv4.2 server setup
  57. -# (tested with FreeBSD 14.3)
  58. +# (tested with FreeBSD 14.3 and FreeBSD 15.0)
  59.  #
  60.  
  61.  ##### 1. Server setup
  62. @@ -239,6 +239,11 @@ printf 'vfs.nfsd.issue_delegations=1\n' >>'/etc/sysctl.conf'
  63.  mkdir /nfsdata
  64.  chmod a+rwxt /nfsdata
  65.  
  66. +# configure ZFS pool so it can support NFSv4 named attributes
  67. +# (NFSv4 named attributes require FreeBSD >= 15.0-only)
  68. +zfs set xattr=dir zroot
  69. +zfs set xattr=dir zroot/ROOT/default
  70. +
  71.  # NFSv4.1 exports must come after the 'V4: /' line,
  72.  # otherwise you get a NFS4ERR_NOFILEHANDLE
  73.  printf 'V4: /\n' >'/etc/exports'
  74. @@ -251,6 +256,8 @@ service nfsd start
  75.  $ printf 'wheel:S-1-0-0:0:\n' >>'/etc/group'
  76.  
  77.  ##### 3. Misc FreeBSD commands:
  78. +# (assumes we want to add an account+groups for a Windows user called "ced"
  79. +# on a Windows with English locale)
  80.  pw groupadd group -n None -g 197121
  81.  pw groupadd group -n ced -g 197608
  82.  pw useradd -n ced -u 197608 -g None -G None,ced -m -s /bin/sh
  83. --
  84. 2.51.0
  85.  
  86. From c9e04a1324c7c26401755ec806832839850be473 Mon Sep 17 00:00:00 2001
  87. From: Roland Mainz <roland.mainz@nrubsig.org>
  88. Date: Tue, 6 Jan 2026 19:25:00 +0100
  89. Subject: [PATCH 3/7] daemon: Fix typo s/stream into/stream info/ in debug
  90.  message
  91.  
  92. Fix typo s/stream into/stream info/ in debug message.
  93.  
  94. Reported-by: Cedric Blancher <cedric.blancher@gmail.com>
  95. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  96. ---
  97. daemon/winstreams.c | 2 +-
  98.  1 file changed, 1 insertion(+), 1 deletion(-)
  99.  
  100. diff --git a/daemon/winstreams.c b/daemon/winstreams.c
  101. index 929fb81..c7ece55 100644
  102. --- a/daemon/winstreams.c
  103. +++ b/daemon/winstreams.c
  104. @@ -470,7 +470,7 @@ int get_streaminformation(
  105.      if (basefile_info->type == NF4NAMEDATTR) {
  106.          DPRINTF(0,
  107.              ("get_streaminformation(name='%.*s'): "
  108. -            "stream into for NF4NAMEDATTR not implemented yet\n",
  109. +            "stream info for NF4NAMEDATTR not implemented yet\n",
  110.              (int)state->file.name.len, state->file.name.name));
  111.          return ERROR_NOT_SUPPORTED;
  112.      }
  113. --
  114. 2.51.0
  115.  
  116. From a919962cfe4f2d038c52f1ab9092b34a6b8e138e Mon Sep 17 00:00:00 2001
  117. From: Roland Mainz <roland.mainz@nrubsig.org>
  118. Date: Tue, 6 Jan 2026 19:47:38 +0100
  119. Subject: [PATCH 4/7] daemon: |FileStreamInformation| should return a default
  120.  "::$DATA" entry if there is no NFSv4.1 named attr dir
  121.  
  122. |FileStreamInformation| should return a default "::$DATA" entry if there is no NFSv4.1
  123. named attr dir.
  124.  
  125. Solaris+Illumos always have an NFSv4.1 attribute directory because
  126. they store their SUNW_* attribute data there, but FreeBSD 15.0 does
  127. not have an attribute directory by default.
  128.  
  129. Reported-by: Cedric Blancher <cedric.blancher@gmail.com>
  130. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  131. ---
  132. daemon/winstreams.c | 37 +++++++++++++++++++++++++++++++++++--
  133.  1 file changed, 35 insertions(+), 2 deletions(-)
  134.  
  135. diff --git a/daemon/winstreams.c b/daemon/winstreams.c
  136. index c7ece55..1d42f6e 100644
  137. --- a/daemon/winstreams.c
  138. +++ b/daemon/winstreams.c
  139. @@ -478,13 +478,46 @@ int get_streaminformation(
  140.      status = nfs41_rpc_openattr(state->session, &state->file, FALSE,
  141.          &parent.fh);
  142.  
  143. -    /* No named attribute directory ? */
  144. +    /*
  145. +     * No named attribute directory ?
  146. +     *
  147. +     * (Solaris+Illumos always have an NFSv4.1 attribute directory because
  148. +     * they store their SUNW_* attribute data there, but FreeBSD 15.0 does
  149. +     * not have an attribute directory by default)
  150. +     */
  151.      if (status == NFS4ERR_NOENT) {
  152. -        /* FIXME: We should return a default "file::$DATA" entry */
  153. +        FILE_STREAM_INFORMATION *stream;
  154. +        size_t streamsize;
  155. +
  156. +        /* Return a default "file::$DATA" entry */
  157.          DPRINTF(0,
  158.              ("get_streaminformation(name='%.*s'): "
  159.              "no named attribute directory\n",
  160.              (int)state->file.name.len, state->file.name.name));
  161. +
  162. +        FILE_STREAM_INFORMATION base_stream = {
  163. +            .NextEntryOffset = 0,
  164. +            /* "::$DATA" == 8*sizeof(wchar_t) */
  165. +            .StreamNameLength = 8*sizeof(wchar_t),
  166. +            .StreamSize.QuadPart = basefile_info->size,
  167. +            .StreamAllocationSize.QuadPart = basefile_info->space_used
  168. +        };
  169. +
  170. +        streamsize = ALIGNED_STREAMINFOSIZE(base_stream.StreamNameLength);
  171. +        stream = calloc(1, streamsize);
  172. +        if (stream == NULL) {
  173. +            status = GetLastError();
  174. +            goto out;
  175. +        }
  176. +        (void)memcpy(stream, &base_stream, sizeof(base_stream));
  177. +        (void)memcpy(stream->StreamName, L"::$DATA", 8*sizeof(wchar_t));
  178. +        stream->NextEntryOffset = 0;
  179. +
  180. +        *streamlist_out = stream;
  181. +        *streamlist_out_size = (ULONG)streamsize;
  182. +
  183. +        status = NO_ERROR;
  184. +        goto out;
  185.      } else if (status) {
  186.          eprintf("get_streaminformation(name='%.*s'): "
  187.              "nfs41_rpc_openattr() failed with '%s'\n",
  188. --
  189. 2.51.0
  190.  
  191. From e53cb617eaaa8c1a498301aa4ae9bd5c3f374ac4 Mon Sep 17 00:00:00 2001
  192. From: Roland Mainz <roland.mainz@nrubsig.org>
  193. Date: Wed, 7 Jan 2026 11:57:31 +0100
  194. Subject: [PATCH 5/7] daemon: Do not use |EXCLUSIVE4|/|EXCLUSIVE4_1| for
  195.  NFSv4.1 named attributes
  196. MIME-Version: 1.0
  197. Content-Type: text/plain; charset=UTF-8
  198. Content-Transfer-Encoding: 8bit
  199.  
  200. Do not use |EXCLUSIVE4|/|EXCLUSIVE4_1| for NFSv4.1 named attributes,
  201. as https://datatracker.ietf.org/doc/html/rfc8881#section-18.16.3 says:
  202. "... Note that exclusive create of a named attribute is not supported.
  203. If the createmode is EXCLUSIVE4 or EXCLUSIVE4_1 and the current filehandle
  204. is a named attribute directory, the server will return EINVAL. ...".
  205.  
  206. Solaris 11.4 nfsd does not do that check, but FreeBSD 15.0 does
  207. enforce it.
  208.  
  209. Reported-by: Aurelien Couderc <aurelien.couderc2002@gmail.com>
  210. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  211. ---
  212. daemon/open.c | 9 +++++++++
  213.  1 file changed, 9 insertions(+)
  214.  
  215. diff --git a/daemon/open.c b/daemon/open.c
  216. index 7010e17..c67c86a 100644
  217. --- a/daemon/open.c
  218. +++ b/daemon/open.c
  219. @@ -1247,6 +1247,15 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  220.          if (status)
  221.              goto out_free_state;
  222.  
  223. +        if (is_stream_path(&state->path)) {
  224. +            /*
  225. +             * NFSv4.1 does not allow |EXCLUSIVE4|/|EXCLUSIVE4_1| for NFS
  226. +             * named attributes
  227. +             */
  228. +            if (createhowmode == EXCLUSIVE4_1)
  229. +                createhowmode = GUARDED4;
  230. +        }
  231. +
  232.          if (args->access_mask & FILE_EXECUTE && state->file.fh.len) {
  233.              status = check_execute_access(state);
  234.              if (status)
  235. --
  236. 2.51.0
  237.  
  238. From 3f4ccee8dbb218630d1eccdd0f8545973a25dc06 Mon Sep 17 00:00:00 2001
  239. From: Roland Mainz <roland.mainz@nrubsig.org>
  240. Date: Wed, 7 Jan 2026 12:02:59 +0100
  241. Subject: [PATCH 6/7] daemon: Do not do access checks for X bit on NFS named
  242.  attributes
  243. MIME-Version: 1.0
  244. Content-Type: text/plain; charset=UTF-8
  245. Content-Transfer-Encoding: 8bit
  246.  
  247. Do not do access checks for X bit on NFS named attributes.
  248.  
  249. Windows fsutil can set the |FILE_EXECUTE| bit when opening Win32
  250. named streams, but Solaris and FreeBSD NFS servers does not allow
  251. access checks with the X bit for NFS named attributes.
  252.  
  253. Reported-by: Aurelien Couderc <aurelien.couderc2002@gmail.com>
  254. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  255. ---
  256. daemon/open.c | 7 +++++++
  257.  1 file changed, 7 insertions(+)
  258.  
  259. diff --git a/daemon/open.c b/daemon/open.c
  260. index c67c86a..a86824c 100644
  261. --- a/daemon/open.c
  262. +++ b/daemon/open.c
  263. @@ -1254,6 +1254,13 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  264.               */
  265.              if (createhowmode == EXCLUSIVE4_1)
  266.                  createhowmode = GUARDED4;
  267. +
  268. +            /*
  269. +             * Windows fsutil can set the |FILE_EXECUTE| bit when opening
  270. +             * Win32 named streams, but NFS does not allow access checks
  271. +             * with the X bit for NFS named attributes
  272. +             */
  273. +            args->access_mask &= ~FILE_EXECUTE;
  274.          }
  275.  
  276.          if (args->access_mask & FILE_EXECUTE && state->file.fh.len) {
  277. --
  278. 2.51.0
  279.  
  280. From 65c48cf88ae199e3a103ff9a51905a2f245e904a Mon Sep 17 00:00:00 2001
  281. From: Roland Mainz <roland.mainz@nrubsig.org>
  282. Date: Wed, 7 Jan 2026 13:43:46 +0100
  283. Subject: [PATCH 7/7] README.md,docs: Document support for Win32 sparse named
  284.  streams
  285.  
  286. Document support for Win32 sparse named streams.
  287.  
  288. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  289. ---
  290. README.md       | 4 ++++
  291.  docs/README.xml | 3 +++
  292.  2 files changed, 7 insertions(+)
  293.  
  294. diff --git a/README.md b/README.md
  295. index df37c7b..49ce9c3 100644
  296. --- a/README.md
  297. +++ b/README.md
  298. @@ -145,6 +145,10 @@ NFSv4.2/NFSv4.1 filesystem driver for Windows 10/11 & Windows Server
  299.  
  300.    - Supports Win32 APIs `|FileStreamInformation|`
  301.  
  302. +  - Supports sparse streams (e.g. supports Win32 APIs
  303. +    `|FSCTL_QUERY_ALLOCATED_RANGES|`, `|FSCTL_SET_SPARSE|`,
  304. +    `|FSCTL_SET_ZERO_DATA|` etc. on Win32 named streams)
  305. +
  306.    - Requires NFSv4.1 server which supports the NFSv4.1 named attributes.
  307.  
  308.  - Case-insensitive filesystem support
  309. diff --git a/docs/README.xml b/docs/README.xml
  310. index 39e1fdf..fc8b96e 100644
  311. --- a/docs/README.xml
  312. +++ b/docs/README.xml
  313. @@ -147,6 +147,9 @@
  314.              <listitem>
  315.                <para>Supports Win32 APIs <literal>|<link xl:href="https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/ns-ntifs-_file_stream_information">FileStreamInformation</link>|</literal></para>
  316.              </listitem>
  317. +            <listitem>
  318. +              <para>Supports sparse streams (e.g. supports Win32 APIs <literal>|FSCTL_QUERY_ALLOCATED_RANGES|</literal>, <literal>|FSCTL_SET_SPARSE|</literal>, <literal>|FSCTL_SET_ZERO_DATA|</literal> etc. on Win32 named streams)</para>
  319. +            </listitem>
  320.              <listitem>
  321.                <para>Requires NFSv4.1 server which supports the NFSv4.1 named attributes.</para>
  322.              </listitem>
  323. --
  324. 2.51.0

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