pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for DrMemory hits, code cleanup, startup dependencies checks+misc, 2024-07-27
Posted by Anonymous on Sat 27th Jul 2024 16:58
raw | new post

  1. From 88665bc5c1be353497e79ebc923995e94c7f47ff Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Fri, 26 Jul 2024 12:47:53 +0200
  4. Subject: [PATCH 1/6] daemon: Add |bitmap4_cpy()|+|bitmap4_clear()| utility
  5.  functions
  6.  
  7. Add |bitmap4_cpy()| and |bitmap4_clear()| utility functions, so we
  8. have a typesafe way to init+copy |bitmap4| types.
  9.  
  10. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  11. ---
  12. daemon/lookup.c    |  8 ++++----
  13.  daemon/nfs41.h     |  2 +-
  14.  daemon/nfs41_ops.c | 44 +++++++++++++++-----------------------------
  15.  daemon/nfs41_xdr.c |  4 ++--
  16.  daemon/util.h      | 19 +++++++++++++++++++
  17.  5 files changed, 41 insertions(+), 36 deletions(-)
  18.  
  19. diff --git a/daemon/lookup.c b/daemon/lookup.c
  20. index ade3354..e895612 100644
  21. --- a/daemon/lookup.c
  22. +++ b/daemon/lookup.c
  23. @@ -224,8 +224,8 @@ static int server_lookup(
  24.          last_component(path, count ? args->lookup[0].name->name : path_end, &name);
  25.  
  26.          /* add the file handle and attributes to the name cache */
  27. -        memcpy(&res->getrootattr.info->attrmask,
  28. -            &res->getrootattr.obj_attributes.attrmask, sizeof(bitmap4));
  29. +        bitmap4_cpy(&res->getrootattr.info->attrmask,
  30. +            &res->getrootattr.obj_attributes.attrmask);
  31.          nfs41_name_cache_insert(session_name_cache(session), path, &name,
  32.              &dir->fh, res->getrootattr.info, NULL, OPEN_DELEGATE_NONE);
  33.      }
  34. @@ -274,8 +274,8 @@ static int server_lookup(
  35.              break;
  36.  
  37.          /* add the file handle and attributes to the name cache */
  38. -        memcpy(&res->getattr[i].info->attrmask,
  39. -            &res->getattr[i].obj_attributes.attrmask, sizeof(bitmap4));
  40. +        bitmap4_cpy(&res->getattr[i].info->attrmask,
  41. +            &res->getattr[i].obj_attributes.attrmask);
  42.          nfs41_name_cache_insert(session_name_cache(session),
  43.              path, args->lookup[i].name, &res->file[i].fh,
  44.              res->getattr[i].info, NULL, OPEN_DELEGATE_NONE);
  45. diff --git a/daemon/nfs41.h b/daemon/nfs41.h
  46. index f69f79d..fd2373a 100644
  47. --- a/daemon/nfs41.h
  48. +++ b/daemon/nfs41.h
  49. @@ -482,7 +482,7 @@ static __inline void nfs41_superblock_getattr_mask(
  50.      IN const nfs41_superblock *superblock,
  51.      OUT bitmap4 *attrs)
  52.  {
  53. -    memcpy(attrs, &superblock->default_getattr, sizeof(bitmap4));
  54. +    bitmap4_cpy(attrs, &superblock->default_getattr);
  55.  }
  56.  static __inline void nfs41_superblock_supported_attrs(
  57.      IN const nfs41_superblock *superblock,
  58. diff --git a/daemon/nfs41_ops.c b/daemon/nfs41_ops.c
  59. index 9bf8832..fbb4fad 100644
  60. --- a/daemon/nfs41_ops.c
  61. +++ b/daemon/nfs41_ops.c
  62. @@ -397,13 +397,11 @@ static void open_update_cache(
  63.      uint32_t status;
  64.  
  65.      /* update the attributes of the parent directory */
  66. -    memcpy(&dir_attrs->info->attrmask, &dir_attrs->obj_attributes.attrmask,
  67. -        sizeof(bitmap4));
  68. +    bitmap4_cpy(&dir_attrs->info->attrmask, &dir_attrs->obj_attributes.attrmask);
  69.      nfs41_attr_cache_update(cache, parent->fh.fileid, dir_attrs->info);
  70.  
  71.      /* add the file handle and attributes to the name cache */
  72. -    memcpy(&file_attrs->info->attrmask, &file_attrs->obj_attributes.attrmask,
  73. -        sizeof(bitmap4));
  74. +    bitmap4_cpy(&file_attrs->info->attrmask, &file_attrs->obj_attributes.attrmask);
  75.  retry_cache_insert:
  76.      AcquireSRWLockShared(&file->path->lock);
  77.      status = nfs41_name_cache_insert(cache, file->path->path, &file->name,
  78. @@ -672,14 +670,12 @@ int nfs41_create(
  79.      file->fh.superblock = parent->fh.superblock;
  80.  
  81.      /* update the attributes of the parent directory */
  82. -    memcpy(&dir_info.attrmask, &pgetattr_res.obj_attributes.attrmask,
  83. -        sizeof(bitmap4));
  84. +    bitmap4_cpy(&dir_info.attrmask, &pgetattr_res.obj_attributes.attrmask);
  85.      nfs41_attr_cache_update(session_name_cache(session),
  86.          parent->fh.fileid, &dir_info);
  87.  
  88.      /* add the new file handle and attributes to the name cache */
  89. -    memcpy(&info->attrmask, &getattr_res.obj_attributes.attrmask,
  90. -        sizeof(bitmap4));
  91. +    bitmap4_cpy(&info->attrmask, &getattr_res.obj_attributes.attrmask);
  92.      AcquireSRWLockShared(&file->path->lock);
  93.      nfs41_name_cache_insert(session_name_cache(session),
  94.          file->path->path, &file->name, &file->fh,
  95. @@ -741,8 +737,7 @@ int nfs41_close(
  96.          goto out;
  97.  
  98.      /* update the attributes of the parent directory */
  99. -    memcpy(&info.attrmask, &getattr_res.obj_attributes.attrmask,
  100. -        sizeof(bitmap4));
  101. +    bitmap4_cpy(&info.attrmask, &getattr_res.obj_attributes.attrmask);
  102.      nfs41_attr_cache_update(session_name_cache(session),
  103.          file->fh.fileid, &info);
  104.  out:
  105. @@ -817,8 +812,7 @@ int nfs41_write(
  106.  
  107.      if (stable != UNSTABLE4 && pinfo->type != NF4NAMEDATTR) {
  108.          /* update the attribute cache */
  109. -        memcpy(&pinfo->attrmask, &getattr_res.obj_attributes.attrmask,
  110. -            sizeof(bitmap4));
  111. +        bitmap4_cpy(&pinfo->attrmask, &getattr_res.obj_attributes.attrmask);
  112.          nfs41_attr_cache_update(session_name_cache(session),
  113.              file->fh.fileid, pinfo);
  114.      }
  115. @@ -958,8 +952,7 @@ int nfs41_commit(
  116.  
  117.      if (do_getattr) {
  118.          /* update the attribute cache */
  119. -        memcpy(&pinfo->attrmask, &getattr_res.obj_attributes.attrmask,
  120. -            sizeof(bitmap4));
  121. +        bitmap4_cpy(&pinfo->attrmask, &getattr_res.obj_attributes.attrmask);
  122.          nfs41_attr_cache_update(session_name_cache(session),
  123.              file->fh.fileid, pinfo);
  124.      }
  125. @@ -1176,8 +1169,7 @@ int nfs41_getattr(
  126.  
  127.      if (file) {
  128.          /* update the name cache with whatever attributes we got */
  129. -        memcpy(&info->attrmask, &getattr_res.obj_attributes.attrmask,
  130. -            sizeof(bitmap4));
  131. +        bitmap4_cpy(&info->attrmask, &getattr_res.obj_attributes.attrmask);
  132.          nfs41_attr_cache_update(session_name_cache(session),
  133.              file->fh.fileid, info);
  134.      }
  135. @@ -1300,8 +1292,7 @@ int nfs41_remove(
  136.          goto out;
  137.  
  138.      /* update the attributes of the parent directory */
  139. -    memcpy(&info.attrmask, &getattr_res.obj_attributes.attrmask,
  140. -        sizeof(bitmap4));
  141. +    bitmap4_cpy(&info.attrmask, &getattr_res.obj_attributes.attrmask);
  142.      nfs41_attr_cache_update(session_name_cache(session),
  143.          parent->fh.fileid, &info);
  144.  
  145. @@ -1382,14 +1373,12 @@ int nfs41_rename(
  146.          goto out;
  147.  
  148.      /* update the attributes of the source directory */
  149. -    memcpy(&src_info.attrmask, &src_getattr_res.obj_attributes.attrmask,
  150. -        sizeof(bitmap4));
  151. +    bitmap4_cpy(&src_info.attrmask, &src_getattr_res.obj_attributes.attrmask);
  152.      nfs41_attr_cache_update(session_name_cache(session),
  153.          src_dir->fh.fileid, &src_info);
  154.  
  155.      /* update the attributes of the destination directory */
  156. -    memcpy(&dst_info.attrmask, &dst_getattr_res.obj_attributes.attrmask,
  157. -        sizeof(bitmap4));
  158. +    bitmap4_cpy(&dst_info.attrmask, &dst_getattr_res.obj_attributes.attrmask);
  159.      nfs41_attr_cache_update(session_name_cache(session),
  160.          dst_dir->fh.fileid, &dst_info);
  161.  
  162. @@ -1491,7 +1480,7 @@ int nfs41_setattr(
  163.      if (compound_error(status = compound.res.status))
  164.          goto out;
  165.  
  166. -    memcpy(&info->attrmask, &attr_request, sizeof(bitmap4));
  167. +    bitmap4_cpy(&info->attrmask, &attr_request);
  168.      nfs41_attr_cache_update(session_name_cache(session),
  169.          file->fh.fileid, info);
  170.  
  171. @@ -1586,14 +1575,12 @@ int nfs41_link(
  172.          goto out;
  173.  
  174.      /* update the attributes of the destination directory */
  175. -    memcpy(&info.attrmask, &getattr_res[0].obj_attributes.attrmask,
  176. -        sizeof(bitmap4));
  177. +    bitmap4_cpy(&info.attrmask, &getattr_res[0].obj_attributes.attrmask);
  178.      nfs41_attr_cache_update(session_name_cache(session),
  179.          info.fileid, &info);
  180.  
  181.      /* add the new file handle and attributes to the name cache */
  182. -    memcpy(&cinfo->attrmask, &getattr_res[1].obj_attributes.attrmask,
  183. -        sizeof(bitmap4));
  184. +    bitmap4_cpy(&cinfo->attrmask, &getattr_res[1].obj_attributes.attrmask);
  185.      AcquireSRWLockShared(&dst_dir->path->lock);
  186.      nfs41_name_cache_insert(session_name_cache(session),
  187.          dst_dir->path->path, target, &file.fh,
  188. @@ -2160,8 +2147,7 @@ enum nfsstat4 pnfs_rpc_layoutcommit(
  189.          goto out;
  190.  
  191.      /* update the attribute cache */
  192. -    memcpy(&info->attrmask, &getattr_res.obj_attributes.attrmask,
  193. -        sizeof(bitmap4));
  194. +    bitmap4_cpy(&info->attrmask, &getattr_res.obj_attributes.attrmask);
  195.      nfs41_attr_cache_update(session_name_cache(session),
  196.          file->fh.fileid, info);
  197.  out:
  198. diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
  199. index d2f65be..3a1ff8d 100644
  200. --- a/daemon/nfs41_xdr.c
  201. +++ b/daemon/nfs41_xdr.c
  202. @@ -2371,7 +2371,7 @@ static bool_t decode_readdir_entry(
  203.          xdrmem_create(&fattr_xdr, (char *)attrs.attr_vals, attrs.attr_vals_len, XDR_DECODE);
  204.          if (!(decode_file_attrs(&fattr_xdr, &attrs, &entry->attr_info)))
  205.              entry->attr_info.rdattr_error = NFS4ERR_BADXDR;
  206. -        (void)memcpy(&entry->attr_info.attrmask, &attrs.attrmask, sizeof(bitmap4));
  207. +        bitmap4_cpy(&entry->attr_info.attrmask, &attrs.attrmask);
  208.          StringCchCopyA(entry->name, name_len, (STRSAFE_LPCSTR)name);
  209.  
  210.          it->buf_pos += (size_t)entry_len + name_len;
  211. @@ -2617,7 +2617,7 @@ static bool_t encode_file_attrs(
  212.      xdrmem_create(&localxdr, (char *)attrs->attr_vals, NFS4_OPAQUE_LIMIT, XDR_ENCODE);
  213.  
  214.      attrs->attr_vals_len = 0;
  215. -    ZeroMemory(&attrs->attrmask, sizeof(bitmap4));
  216. +    bitmap4_clear(&attrs->attrmask);
  217.      attrs->attrmask.count = info->attrmask.count;
  218.  
  219.      if (info->attrmask.count > 0) {
  220. diff --git a/daemon/util.h b/daemon/util.h
  221. index 7f7d585..e4876ba 100644
  222. --- a/daemon/util.h
  223. +++ b/daemon/util.h
  224. @@ -126,6 +126,25 @@ static __inline void bitmap_intersect(
  225.      dst->count = min(dst->count, count);
  226.  }
  227.  
  228. +static __inline void bitmap4_cpy(
  229. +    OUT bitmap4 *restrict dst,
  230. +    IN  const bitmap4 *restrict src)
  231. +{
  232. +    (void)memcpy(dst, src, sizeof(bitmap4));
  233. +}
  234. +
  235. +static __inline void bitmap4_clear(
  236. +    OUT bitmap4 *restrict dst)
  237. +{
  238. +    /*
  239. +     * gisburn: FIXME: Only set the count field to 0, and use
  240. +     * Rational Purify/DrMemory to see if someone does not play
  241. +     * by the rules
  242. +     */
  243. +    (void)memset(dst, 0, sizeof(bitmap4));
  244. +}
  245. +
  246. +
  247.  ULONG nfs_file_info_to_attributes(
  248.      IN const nfs41_file_info *info);
  249.  void nfs_to_basic_info(
  250. --
  251. 2.45.1
  252.  
  253. From a57074aa1be78c0fc85ca9e14b3700869379fcd6 Mon Sep 17 00:00:00 2001
  254. From: Roland Mainz <roland.mainz@nrubsig.org>
  255. Date: Fri, 26 Jul 2024 12:50:13 +0200
  256. Subject: [PATCH 2/6] daemon: Fix DrMemory "UNINITIALIZED READ" hits in
  257.  |attr_cache_update()|
  258.  
  259. Fix DrMemory hits in |attr_cache_update()|, which were triggered by
  260. using the request |bitmap4| instead of the response |bitmap4|
  261.  
  262. DrMemory hits look like this:
  263. ---- snip ----
  264. Error #1: UNINITIALIZED READ: reading 8 byte(s)
  265. attr_cache_update                     [ms-nfs41-client\daemon\name_cache.c:323]
  266. nfs41_attr_cache_update               [ms-nfs41-client\daemon\name_cache.c:957]
  267. nfs41_setattr                         [ms-nfs41-client\daemon\nfs41_ops.c:1495]
  268. handle_setexattr                      [ms-nfs41-client\daemon\ea.c:186]
  269. upcall_handle                         [ms-nfs41-client\daemon\upcall.c:220]
  270. nfsd_worker_thread_main               [ms-nfs41-client\daemon\nfs41_daemon.c:188]
  271. nfsd_thread_main                      [ms-nfs41-client\daemon\nfs41_daemon.c:226]
  272. KERNEL32.dll!BaseThreadInitThunk     +0x13     (0x00007ffe78f47374 <KERNEL32.dll+0x17374>)
  273.  
  274. Error #2: UNINITIALIZED READ: reading 4 byte(s)
  275. attr_cache_update                     [ms-nfs41-client\daemon\name_cache.c:324]
  276. nfs41_attr_cache_update               [ms-nfs41-client\daemon\name_cache.c:957]
  277. nfs41_setattr                         [ms-nfs41-client\daemon\nfs41_ops.c:1495]
  278. handle_setexattr                      [ms-nfs41-client\daemon\ea.c:186]
  279. upcall_handle                         [ms-nfs41-client\daemon\upcall.c:220]
  280. nfsd_worker_thread_main               [ms-nfs41-client\daemon\nfs41_daemon.c:188]
  281. nfsd_thread_main                      [ms-nfs41-client\daemon\nfs41_daemon.c:226]
  282. KERNEL32.dll!BaseThreadInitThunk     +0x13     (0x00007ffe78f47374 <KERNEL32.dll+0x17374>)
  283. ---- snip ----
  284.  
  285. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  286. ---
  287. daemon/nfs41_ops.c | 2 +-
  288.  1 file changed, 1 insertion(+), 1 deletion(-)
  289.  
  290. diff --git a/daemon/nfs41_ops.c b/daemon/nfs41_ops.c
  291. index fbb4fad..837d24a 100644
  292. --- a/daemon/nfs41_ops.c
  293. +++ b/daemon/nfs41_ops.c
  294. @@ -1480,7 +1480,7 @@ int nfs41_setattr(
  295.      if (compound_error(status = compound.res.status))
  296.          goto out;
  297.  
  298. -    bitmap4_cpy(&info->attrmask, &attr_request);
  299. +    bitmap4_cpy(&info->attrmask, &getattr_res.obj_attributes.attrmask);
  300.      nfs41_attr_cache_update(session_name_cache(session),
  301.          file->fh.fileid, info);
  302.  
  303. --
  304. 2.45.1
  305.  
  306. From ec66d370ae8d252e7e8e0aa916c30be9497370d3 Mon Sep 17 00:00:00 2001
  307. From: Roland Mainz <roland.mainz@nrubsig.org>
  308. Date: Fri, 26 Jul 2024 13:24:00 +0200
  309. Subject: [PATCH 3/6] daemon: Add asserts for
  310.  |FATTR4_WORD0_CHANGE|+|FATTR4_WORD1_MODE| before using data
  311.  
  312. Add asserts to test for |FATTR4_WORD0_CHANGE|+|FATTR4_WORD1_MODE|
  313. before using the data for these attributes.
  314.  
  315. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  316. ---
  317. daemon/acl.c       |  4 ++++
  318.  daemon/ea.c        |  3 +++
  319.  daemon/getattr.c   |  2 ++
  320.  daemon/open.c      | 12 ++++++++++++
  321.  daemon/readwrite.c |  6 ++++++
  322.  daemon/setattr.c   |  6 ++++++
  323.  6 files changed, 33 insertions(+)
  324.  
  325. diff --git a/daemon/acl.c b/daemon/acl.c
  326. index 1a4f312..7ee91d9 100644
  327. --- a/daemon/acl.c
  328. +++ b/daemon/acl.c
  329. @@ -1428,7 +1428,11 @@ static int handle_setacl(void *daemon_context, nfs41_upcall *upcall)
  330.              print_nfs41_file_info("handle_setacl: nfs41_setattr() success info OUT:", &info);
  331.          }
  332.      }
  333. +
  334. +    EASSERT((info.attrmask.count >= 1) &&
  335. +        (info.attrmask.arr[0] & FATTR4_WORD0_CHANGE));
  336.      args->ctime = info.change;
  337. +
  338.      if (args->query & DACL_SECURITY_INFORMATION)
  339.          free(nfs4_acl.aces);
  340.  out:
  341. diff --git a/daemon/ea.c b/daemon/ea.c
  342. index d5e8d92..b7925c7 100644
  343. --- a/daemon/ea.c
  344. +++ b/daemon/ea.c
  345. @@ -3,6 +3,7 @@
  346.   *
  347.   * Olga Kornievskaia <aglo@umich.edu>
  348.   * Casey Bodley <cbodley@umich.edu>
  349. + * Roland Mainz <roland.mainz@nrubsig.org>
  350.   *
  351.   * This library is free software; you can redistribute it and/or modify it
  352.   * under the terms of the GNU Lesser General Public License as published by
  353. @@ -190,6 +191,8 @@ static int handle_setexattr(void *daemon_context, nfs41_upcall *upcall)
  354.              goto out;
  355.          }
  356.  
  357. +        EASSERT((info.attrmask.count >= 1) &&
  358. +            (info.attrmask.arr[0] & FATTR4_WORD0_CHANGE));
  359.          args->ctime = info.change;
  360.          goto out;
  361.      }
  362. diff --git a/daemon/getattr.c b/daemon/getattr.c
  363. index 2b8a91d..c3b79b6 100644
  364. --- a/daemon/getattr.c
  365. +++ b/daemon/getattr.c
  366. @@ -168,6 +168,8 @@ static int handle_getattr(void *daemon_context, nfs41_upcall *upcall)
  367.      switch (args->query_class) {
  368.      case FileBasicInformation:
  369.          nfs_to_basic_info(state->file.name.name, &info, &args->basic_info);
  370. +        EASSERT((info.attrmask.count >= 1) &&
  371. +            (info.attrmask.arr[0] & FATTR4_WORD0_CHANGE));
  372.          args->ctime = info.change;
  373.          break;
  374.      case FileStandardInformation:
  375. diff --git a/daemon/open.c b/daemon/open.c
  376. index 6769e93..a033a65 100644
  377. --- a/daemon/open.c
  378. +++ b/daemon/open.c
  379. @@ -760,7 +760,11 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  380.          }
  381.          nfs_to_basic_info(state->file.name.name, &info, &args->basic_info);
  382.          nfs_to_standard_info(&info, &args->std_info);
  383. +        EASSERT((info.attrmask.count >= 2) &&
  384. +            (info.attrmask.arr[1] & FATTR4_WORD1_MODE));
  385.          args->mode = info.mode;
  386. +        EASSERT((info.attrmask.count >= 1) &&
  387. +            (info.attrmask.arr[0] & FATTR4_WORD0_CHANGE));
  388.          args->changeattr = info.change;
  389.      } else if (open_for_attributes(state->type, args->access_mask,
  390.                  args->disposition, status)) {
  391. @@ -771,7 +775,11 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  392.  
  393.          nfs_to_basic_info(state->file.name.name, &info, &args->basic_info);
  394.          nfs_to_standard_info(&info, &args->std_info);
  395. +        EASSERT((info.attrmask.count >= 2) &&
  396. +            (info.attrmask.arr[1] & FATTR4_WORD1_MODE));
  397.          args->mode = info.mode;
  398. +        EASSERT((info.attrmask.count >= 1) &&
  399. +            (info.attrmask.arr[0] & FATTR4_WORD0_CHANGE));
  400.          args->changeattr = info.change;
  401.  
  402.  #ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  403. @@ -997,7 +1005,11 @@ create_chgrp_out:
  404.  
  405.              nfs_to_basic_info(state->file.name.name, &info, &args->basic_info);
  406.              nfs_to_standard_info(&info, &args->std_info);
  407. +            EASSERT((info.attrmask.count >= 2) &&
  408. +                (info.attrmask.arr[1] & FATTR4_WORD1_MODE));
  409.              args->mode = info.mode;
  410. +            EASSERT((info.attrmask.count >= 1) &&
  411. +                (info.attrmask.arr[0] & FATTR4_WORD0_CHANGE));
  412.              args->changeattr = info.change;
  413.          }
  414.  
  415. diff --git a/daemon/readwrite.c b/daemon/readwrite.c
  416. index 694ea88..a1e521b 100644
  417. --- a/daemon/readwrite.c
  418. +++ b/daemon/readwrite.c
  419. @@ -238,7 +238,11 @@ retry_write:
  420.                 if (status)
  421.                         goto out;
  422.         }
  423. +
  424. +    EASSERT((info.attrmask.count >= 1) &&
  425. +        (info.attrmask.arr[0] & FATTR4_WORD0_CHANGE));
  426.      args->ctime = info.change;
  427. +
  428.  out:
  429.      args->out_len = len;
  430.      return nfs_to_windows_error(status, ERROR_NET_WRITE_FAULT);
  431. @@ -268,6 +272,8 @@ static int write_to_pnfs(
  432.          status = ERROR_WRITE_FAULT;
  433.          goto out;
  434.      }
  435. +    EASSERT((info.attrmask.count >= 1) &&
  436. +        (info.attrmask.arr[0] & FATTR4_WORD0_CHANGE));
  437.      args->ctime = info.change;
  438.  out:
  439.      return status;
  440. diff --git a/daemon/setattr.c b/daemon/setattr.c
  441. index 8dc764d..9053e8e 100644
  442. --- a/daemon/setattr.c
  443. +++ b/daemon/setattr.c
  444. @@ -144,6 +144,8 @@ static int handle_nfs41_setattr(void *daemon_context, setattr_upcall_args *args)
  445.              nfs_error_string(status)));
  446.          status = nfs_to_windows_error(status, ERROR_NOT_SUPPORTED);
  447.      }
  448. +    EASSERT((info.attrmask.count >= 1) &&
  449. +        (info.attrmask.arr[0] & FATTR4_WORD0_CHANGE));
  450.      args->ctime = info.change;
  451.  out:
  452.      return status;
  453. @@ -382,6 +384,8 @@ static int handle_nfs41_set_size(void *daemon_context, setattr_upcall_args *args
  454.      AcquireSRWLockExclusive(&state->lock);
  455.      state->pnfs_last_offset = info.size ? info.size - 1 : 0;
  456.      ReleaseSRWLockExclusive(&state->lock);
  457. +    EASSERT((info.attrmask.count >= 1) &&
  458. +        (info.attrmask.arr[0] & FATTR4_WORD0_CHANGE));
  459.      args->ctime = info.change;
  460.  out:
  461.      return status = nfs_to_windows_error(status, ERROR_NOT_SUPPORTED);
  462. @@ -484,6 +488,8 @@ static int handle_nfs41_link(void *daemon_context, setattr_upcall_args *args)
  463.              nfs_error_string(status)));
  464.          status = nfs_to_windows_error(status, ERROR_INVALID_PARAMETER);
  465.      }
  466. +    EASSERT((info.attrmask.count >= 1) &&
  467. +        (info.attrmask.arr[0] & FATTR4_WORD0_CHANGE));
  468.      args->ctime = info.change;
  469.  out:
  470.      return status;
  471. --
  472. 2.45.1
  473.  
  474. From a5d5db25532a4f1e69c240217f90b735749c28b4 Mon Sep 17 00:00:00 2001
  475. From: Roland Mainz <roland.mainz@nrubsig.org>
  476. Date: Fri, 26 Jul 2024 13:53:35 +0200
  477. Subject: [PATCH 4/6] daemon: Add
  478.  |stateid4_cpy()|+|stateid4_clear()|+|stateid4_cmd()| utility functions
  479.  
  480. Add |stateid4_cpy()|, |stateid4_clear()| and |stateid4_cmd()| utility
  481. functions, so we have a typesafe way to init+copy |stateid4| types.
  482.  
  483. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  484. ---
  485. daemon/delegation.c  | 18 +++++++++---------
  486.  daemon/lock.c        |  9 +++++----
  487.  daemon/nfs41_ops.c   |  2 +-
  488.  daemon/open.c        | 12 ++++++------
  489.  daemon/pnfs_layout.c |  7 ++++---
  490.  daemon/readwrite.c   |  3 ++-
  491.  daemon/recovery.c    | 31 ++++++++++++++++---------------
  492.  daemon/util.h        | 19 +++++++++++++++++++
  493.  8 files changed, 62 insertions(+), 39 deletions(-)
  494.  
  495. diff --git a/daemon/delegation.c b/daemon/delegation.c
  496. index 5318d2c..d91eecd 100644
  497. --- a/daemon/delegation.c
  498. +++ b/daemon/delegation.c
  499. @@ -3,6 +3,7 @@
  500.   *
  501.   * Olga Kornievskaia <aglo@umich.edu>
  502.   * Casey Bodley <cbodley@umich.edu>
  503. + * Roland Mainz <roland.mainz@nrubsig.org>
  504.   *
  505.   * This library is free software; you can redistribute it and/or modify it
  506.   * under the terms of the GNU Lesser General Public License as published by
  507. @@ -226,10 +227,10 @@ static int delegation_flush_locks(
  508.      /* get the starting open/lock stateid */
  509.      AcquireSRWLockShared(&open->lock);
  510.      if (open->locks.stateid.seqid) {
  511. -        memcpy(&stateid.stateid, &open->locks.stateid, sizeof(stateid4));
  512. +        stateid4_cpy(&stateid.stateid, &open->locks.stateid);
  513.          stateid.type = STATEID_LOCK;
  514.      } else {
  515. -        memcpy(&stateid.stateid, &open->stateid, sizeof(stateid4));
  516. +        stateid4_cpy(&stateid.stateid, &open->stateid);
  517.          stateid.type = STATEID_OPEN;
  518.      }
  519.      ReleaseSRWLockShared(&open->lock);
  520. @@ -249,7 +250,7 @@ static int delegation_flush_locks(
  521.          AcquireSRWLockExclusive(&open->lock);
  522.          if (open->locks.stateid.seqid == 0) {
  523.              /* if it's a new lock stateid, copy it in */
  524. -            memcpy(&open->locks.stateid, &stateid.stateid, sizeof(stateid4));
  525. +            stateid4_cpy(&open->locks.stateid, &stateid.stateid);
  526.          } else if (stateid.stateid.seqid > open->locks.stateid.seqid) {
  527.              /* update the seqid if it's more recent */
  528.              open->locks.stateid.seqid = stateid.stateid.seqid;
  529. @@ -313,7 +314,7 @@ out_downcall:
  530.      stateid.open = NULL;
  531.      stateid.delegation = deleg;
  532.      AcquireSRWLockShared(&deleg->lock);
  533. -    memcpy(&stateid.stateid, &deleg->state.stateid, sizeof(stateid4));
  534. +    stateid4_cpy(&stateid.stateid, &deleg->state.stateid);
  535.      ReleaseSRWLockShared(&deleg->lock);
  536.  
  537.      status = nfs41_delegreturn(client->session,
  538. @@ -366,7 +367,7 @@ out:
  539.      return status;
  540.  
  541.  out_return: /* return the delegation on failure */
  542. -    memcpy(&stateid.stateid, &delegation->stateid, sizeof(stateid4));
  543. +    stateid4_cpy(&stateid.stateid, &delegation->stateid);
  544.      stateid.type = STATEID_DELEG_FILE;
  545.      stateid.open = NULL;
  546.      stateid.delegation = NULL;
  547. @@ -498,7 +499,7 @@ int nfs41_delegate_open(
  548.          stateid.open = NULL;
  549.          stateid.delegation = deleg;
  550.          stateid.type = STATEID_DELEG_FILE;
  551. -        memcpy(&stateid.stateid, &deleg->state.stateid, sizeof(stateid4));
  552. +        stateid4_cpy(&stateid.stateid, &deleg->state.stateid);
  553.      }
  554.      if (!status) {
  555.          DPRINTF(1, ("nfs41_delegate_open: updating srv_open from %x to %x\n",
  556. @@ -569,8 +570,7 @@ int nfs41_delegation_to_open(
  557.      deleg_stateid.open = open;
  558.      deleg_stateid.delegation = NULL;
  559.      deleg_stateid.type = STATEID_DELEG_FILE;
  560. -    memcpy(&deleg_stateid.stateid, &open->delegation.state->state.stateid,
  561. -        sizeof(stateid4));
  562. +    stateid4_cpy(&deleg_stateid.stateid, &open->delegation.state->state.stateid);
  563.      ReleaseSRWLockShared(&open->delegation.state->lock);
  564.  
  565.      ReleaseSRWLockExclusive(&open->lock);
  566. @@ -587,7 +587,7 @@ int nfs41_delegation_to_open(
  567.      AcquireSRWLockExclusive(&open->lock);
  568.      if (status == NFS4_OK) {
  569.          /* save the new open stateid */
  570. -        memcpy(&open->stateid, &open_stateid, sizeof(stateid4));
  571. +        stateid4_cpy(&open->stateid, &open_stateid);
  572.          open->do_close = 1;
  573.      } else if (open->do_close && (status == NFS4ERR_BAD_STATEID ||
  574.          status == NFS4ERR_STALE_STATEID || status == NFS4ERR_EXPIRED)) {
  575. diff --git a/daemon/lock.c b/daemon/lock.c
  576. index 01cbe66..da306cc 100644
  577. --- a/daemon/lock.c
  578. +++ b/daemon/lock.c
  579. @@ -3,6 +3,7 @@
  580.   *
  581.   * Olga Kornievskaia <aglo@umich.edu>
  582.   * Casey Bodley <cbodley@umich.edu>
  583. + * Roland Mainz <roland.mainz@nrubsig.org>
  584.   *
  585.   * This library is free software; you can redistribute it and/or modify it
  586.   * under the terms of the GNU Lesser General Public License as published by
  587. @@ -41,13 +42,13 @@ static void lock_stateid_arg(
  588.  
  589.      AcquireSRWLockShared(&state->lock);
  590.      if (state->locks.stateid.seqid) {
  591. -        memcpy(&arg->stateid, &state->locks.stateid, sizeof(stateid4));
  592. +        stateid4_cpy(&arg->stateid, &state->locks.stateid);
  593.          arg->type = STATEID_LOCK;
  594.      } else if (state->do_close) {
  595. -        memcpy(&arg->stateid, &state->stateid, sizeof(stateid4));
  596. +        stateid4_cpy(&arg->stateid, &state->stateid);
  597.          arg->type = STATEID_OPEN;
  598.      } else {
  599. -        memset(&arg->stateid, 0, sizeof(stateid4));
  600. +        stateid4_clear(&arg->stateid);
  601.          arg->type = STATEID_SPECIAL;
  602.      }
  603.      ReleaseSRWLockShared(&state->lock);
  604. @@ -60,7 +61,7 @@ static void lock_stateid_update(
  605.  {
  606.      if (state->locks.stateid.seqid == 0) {
  607.          /* if it's a new lock stateid, copy it in */
  608. -        memcpy(&state->locks.stateid, stateid, sizeof(stateid4));
  609. +        stateid4_cpy(&state->locks.stateid, stateid);
  610.      } else if (stateid->seqid > state->locks.stateid.seqid) {
  611.          /* update the seqid if it's more recent */
  612.          state->locks.stateid.seqid = stateid->seqid;
  613. diff --git a/daemon/nfs41_ops.c b/daemon/nfs41_ops.c
  614. index 837d24a..c1c72f5 100644
  615. --- a/daemon/nfs41_ops.c
  616. +++ b/daemon/nfs41_ops.c
  617. @@ -374,7 +374,7 @@ static void open_delegation_return(
  618.      stateid.open = NULL;
  619.      stateid.delegation = NULL;
  620.      stateid.type = STATEID_DELEG_FILE;
  621. -    memcpy(&stateid.stateid, &delegation->stateid, sizeof(stateid4));
  622. +    stateid4_cpy(&stateid.stateid, &delegation->stateid);
  623.  
  624.      status = nfs41_delegreturn(session, file, &stateid, try_recovery);
  625.  
  626. diff --git a/daemon/open.c b/daemon/open.c
  627. index a033a65..f7c1d04 100644
  628. --- a/daemon/open.c
  629. +++ b/daemon/open.c
  630. @@ -241,7 +241,7 @@ void nfs41_open_stateid_arg(
  631.          AcquireSRWLockShared(&deleg->lock);
  632.          if (deleg->status == DELEGATION_GRANTED) {
  633.              arg->type = STATEID_DELEG_FILE;
  634. -            memcpy(&arg->stateid, &deleg->state.stateid, sizeof(stateid4));
  635. +            stateid4_cpy(&arg->stateid, &deleg->state.stateid);
  636.          }
  637.          ReleaseSRWLockShared(&deleg->lock);
  638.  
  639. @@ -257,13 +257,13 @@ void nfs41_open_stateid_arg(
  640.      }
  641.  
  642.      if (state->locks.stateid.seqid) {
  643. -        memcpy(&arg->stateid, &state->locks.stateid, sizeof(stateid4));
  644. +        stateid4_cpy(&arg->stateid, &state->locks.stateid);
  645.          arg->type = STATEID_LOCK;
  646.      } else if (state->do_close) {
  647. -        memcpy(&arg->stateid, &state->stateid, sizeof(stateid4));
  648. +        stateid4_cpy(&arg->stateid, &state->stateid);
  649.          arg->type = STATEID_OPEN;
  650.      } else {
  651. -        memset(&arg->stateid, 0, sizeof(stateid4));
  652. +        stateid4_clear(&arg->stateid);
  653.          arg->type = STATEID_SPECIAL;
  654.      }
  655.  out:
  656. @@ -1089,7 +1089,7 @@ static void cancel_open(IN nfs41_upcall *upcall)
  657.          stateid.open = state;
  658.          stateid.delegation = NULL;
  659.          stateid.type = STATEID_OPEN;
  660. -        memcpy(&stateid.stateid, &state->stateid, sizeof(stateid4));
  661. +        stateid4_cpy(&stateid.stateid, &state->stateid);
  662.  
  663.          status = nfs41_close(state->session, &state->file, &stateid);
  664.          if (status) {
  665. @@ -1148,7 +1148,7 @@ static int do_nfs41_close(nfs41_open_state *state)
  666.      stateid.open = state;
  667.      stateid.delegation = NULL;
  668.      stateid.type = STATEID_OPEN;
  669. -    memcpy(&stateid.stateid, &state->stateid, sizeof(stateid4));
  670. +    stateid4_cpy(&stateid.stateid, &state->stateid);
  671.  
  672.      status = nfs41_close(state->session, &state->file, &stateid);
  673.      if (status) {
  674. diff --git a/daemon/pnfs_layout.c b/daemon/pnfs_layout.c
  675. index ec99840..a83a0e7 100644
  676. --- a/daemon/pnfs_layout.c
  677. +++ b/daemon/pnfs_layout.c
  678. @@ -3,6 +3,7 @@
  679.   *
  680.   * Olga Kornievskaia <aglo@umich.edu>
  681.   * Casey Bodley <cbodley@umich.edu>
  682. + * Roland Mainz <roland.mainz@nrubsig.org>
  683.   *
  684.   * This library is free software; you can redistribute it and/or modify it
  685.   * under the terms of the GNU Lesser General Public License as published by
  686. @@ -379,7 +380,7 @@ static enum pnfs_status layout_update_stateid(
  687.  
  688.      if (state->stateid.seqid == 0) {
  689.          /* save a new layout stateid */
  690. -        memcpy(&state->stateid, stateid, sizeof(stateid4));
  691. +        stateid4_cpy(&state->stateid, stateid);
  692.      } else if (memcmp(&state->stateid.other, stateid->other,
  693.                          NFS4_STATEID_OTHER) == 0) {
  694.          /* update an existing layout stateid */
  695. @@ -527,7 +528,7 @@ static enum pnfs_status layout_fetch(
  696.  
  697.      /* if there's an existing layout stateid, use it */
  698.      if (state->stateid.seqid) {
  699. -        memcpy(&layout_stateid.stateid, &state->stateid, sizeof(stateid4));
  700. +        stateid4_cpy(&layout_stateid.stateid, &state->stateid);
  701.          layout_stateid.type = STATEID_LAYOUT;
  702.          stateid = &layout_stateid;
  703.      }
  704. @@ -813,7 +814,7 @@ static enum pnfs_status file_layout_return(
  705.              /* 12.5.3. Layout Stateid: Once a client has no more
  706.               * layouts on a file, the layout stateid is no longer
  707.               * valid and MUST NOT be used. */
  708. -            ZeroMemory(&state->stateid, sizeof(stateid4));
  709. +            stateid4_clear(&state->stateid);
  710.          }
  711.      }
  712.  
  713. diff --git a/daemon/readwrite.c b/daemon/readwrite.c
  714. index a1e521b..9320970 100644
  715. --- a/daemon/readwrite.c
  716. +++ b/daemon/readwrite.c
  717. @@ -3,6 +3,7 @@
  718.   *
  719.   * Olga Kornievskaia <aglo@umich.edu>
  720.   * Casey Bodley <cbodley@umich.edu>
  721. + * Roland Mainz <roland.mainz@nrubsig.org>
  722.   *
  723.   * This library is free software; you can redistribute it and/or modify it
  724.   * under the terms of the GNU Lesser General Public License as published by
  725. @@ -80,7 +81,7 @@ static int read_from_mds(
  726.                  p, &bytes_read, &eof);
  727.          if (status == NFS4ERR_OPENMODE && !len) {
  728.              stateid->type = STATEID_SPECIAL;
  729. -            memcpy(&stateid->stateid, &special_read_stateid, sizeof(stateid4));
  730. +            stateid4_cpy(&stateid->stateid, &special_read_stateid);
  731.              continue;
  732.          } else if (status && !len) {
  733.              status = nfs_to_windows_error(status, ERROR_NET_WRITE_FAULT);
  734. diff --git a/daemon/recovery.c b/daemon/recovery.c
  735. index bce908f..7c45671 100644
  736. --- a/daemon/recovery.c
  737. +++ b/daemon/recovery.c
  738. @@ -3,6 +3,7 @@
  739.   *
  740.   * Olga Kornievskaia <aglo@umich.edu>
  741.   * Casey Bodley <cbodley@umich.edu>
  742. + * Roland Mainz <roland.mainz@nrubsig.org>
  743.   *
  744.   * This library is free software; you can redistribute it and/or modify it
  745.   * under the terms of the GNU Lesser General Public License as published by
  746. @@ -252,7 +253,7 @@ static int recover_open(
  747.  
  748.      AcquireSRWLockExclusive(&open->lock);
  749.      /* update the open stateid */
  750. -    memcpy(&open->stateid, &stateid, sizeof(stateid4));
  751. +    stateid4_cpy(&open->stateid, &stateid);
  752.      open->do_close = TRUE;
  753.  
  754.      if (open->delegation.state) {
  755. @@ -291,7 +292,7 @@ static int recover_locks(
  756.      AcquireSRWLockExclusive(&open->lock);
  757.  
  758.      /* initialize the open stateid for the first lock request */
  759. -    memcpy(&stateid.stateid, &open->stateid, sizeof(stateid4));
  760. +    stateid4_cpy(&stateid.stateid, &open->stateid);
  761.      stateid.type = STATEID_OPEN;
  762.      stateid.open = open;
  763.      stateid.delegation = NULL;
  764. @@ -325,7 +326,7 @@ static int recover_locks(
  765.      if (status != NFS4ERR_BADSESSION) {
  766.          /* if we got a lock stateid back, save the lock with the open */
  767.          if (stateid.type == STATEID_LOCK)
  768. -            memcpy(&open->locks.stateid, &stateid.stateid, sizeof(stateid4));
  769. +            stateid4_cpy(&open->locks.stateid, &stateid.stateid);
  770.          else
  771.              open->locks.stateid.seqid = 0;
  772.      }
  773. @@ -580,7 +581,7 @@ static uint32_t stateid_array(
  774.          deleg = list_container(entry, nfs41_delegation_state, client_entry);
  775.          AcquireSRWLockShared(&deleg->lock);
  776.          /* delegation stateid */
  777. -        memcpy(&stateids[i].stateid, &deleg->state.stateid, sizeof(stateid4));
  778. +        stateid4_cpy(&stateids[i].stateid, &deleg->state.stateid);
  779.          stateids[i].type = STATEID_DELEG_FILE;
  780.          stateids[i].delegation = deleg;
  781.          i++;
  782. @@ -592,13 +593,13 @@ static uint32_t stateid_array(
  783.  
  784.          AcquireSRWLockShared(&open->lock);
  785.          /* open stateid */
  786. -        memcpy(&stateids[i].stateid, &open->stateid, sizeof(stateid4));
  787. +        stateid4_cpy(&stateids[i].stateid, &open->stateid);
  788.          stateids[i].type = STATEID_OPEN;
  789.          stateids[i].open = open;
  790.          i++;
  791.  
  792.          if (open->locks.stateid.seqid) { /* lock stateid? */
  793. -            memcpy(&stateids[i].stateid, &open->locks.stateid, sizeof(stateid4));
  794. +            stateid4_cpy(&stateids[i].stateid, &open->locks.stateid);
  795.              stateids[i].type = STATEID_LOCK;
  796.              stateids[i].open = open;
  797.              i++;
  798. @@ -607,7 +608,7 @@ static uint32_t stateid_array(
  799.          if (open->layout) { /* layout stateid? */
  800.              AcquireSRWLockShared(&open->layout->lock);
  801.              if (open->layout->stateid.seqid) {
  802. -                memcpy(&stateids[i].stateid, &open->layout->stateid, sizeof(stateid4));
  803. +                stateid4_cpy(&stateids[i].stateid, &open->layout->stateid);
  804.                  stateids[i].type = STATEID_LAYOUT;
  805.                  stateids[i].open = open;
  806.                  i++;
  807. @@ -711,8 +712,8 @@ static bool_t recover_stateid_open(
  808.  
  809.          /* if the source stateid is different, update and retry */
  810.          AcquireSRWLockShared(&stateid->open->lock);
  811. -        if (memcmp(&stateid->stateid, source, sizeof(stateid4))) {
  812. -            memcpy(&stateid->stateid, source, sizeof(stateid4));
  813. +        if (stateid4_cmp(&stateid->stateid, source)) {
  814. +            stateid4_cpy(&stateid->stateid, source);
  815.              retry = TRUE;
  816.          }
  817.          ReleaseSRWLockShared(&stateid->open->lock);
  818. @@ -731,7 +732,7 @@ static bool_t recover_stateid_lock(
  819.  
  820.          /* if the source stateid is different, update and retry */
  821.          AcquireSRWLockShared(&stateid->open->lock);
  822. -        if (memcmp(&stateid->stateid, source, sizeof(stateid4))) {
  823. +        if (stateid4_cmp(&stateid->stateid, source)) {
  824.              if (argop->op == OP_LOCK && source->seqid == 0) {
  825.                  /* resend LOCK with an open stateid */
  826.                  nfs41_lock_args *lock = (nfs41_lock_args*)argop->arg;
  827. @@ -741,7 +742,7 @@ static bool_t recover_stateid_lock(
  828.                  source = &stateid->open->stateid;
  829.              }
  830.  
  831. -            memcpy(&stateid->stateid, source, sizeof(stateid4));
  832. +            stateid4_cpy(&stateid->stateid, source);
  833.              retry = TRUE;
  834.          }
  835.          ReleaseSRWLockShared(&stateid->open->lock);
  836. @@ -765,8 +766,8 @@ static bool_t recover_stateid_delegation(
  837.              nfs41_delegation_state *deleg = stateid->open->delegation.state;
  838.              stateid4 *source = &deleg->state.stateid;
  839.              AcquireSRWLockShared(&deleg->lock);
  840. -            if (memcmp(&stateid->stateid, source, sizeof(stateid4))) {
  841. -                memcpy(&stateid->stateid, source, sizeof(stateid4));
  842. +            if (stateid4_cmp(&stateid->stateid, source)) {
  843. +                stateid4_cpy(&stateid->stateid, source);
  844.                  retry = TRUE;
  845.              }
  846.              ReleaseSRWLockShared(&deleg->lock);
  847. @@ -776,8 +777,8 @@ static bool_t recover_stateid_delegation(
  848.          nfs41_delegation_state *deleg = stateid->delegation;
  849.          stateid4 *source = &deleg->state.stateid;
  850.          AcquireSRWLockShared(&deleg->lock);
  851. -        if (memcmp(&stateid->stateid, source, sizeof(stateid4))) {
  852. -            memcpy(&stateid->stateid, source, sizeof(stateid4));
  853. +        if (stateid4_cmp(&stateid->stateid, source)) {
  854. +            stateid4_cpy(&stateid->stateid, source);
  855.              retry = TRUE;
  856.          }
  857.          ReleaseSRWLockShared(&deleg->lock);
  858. diff --git a/daemon/util.h b/daemon/util.h
  859. index e4876ba..a191ffa 100644
  860. --- a/daemon/util.h
  861. +++ b/daemon/util.h
  862. @@ -144,6 +144,25 @@ static __inline void bitmap4_clear(
  863.      (void)memset(dst, 0, sizeof(bitmap4));
  864.  }
  865.  
  866. +static __inline void stateid4_cpy(
  867. +    OUT stateid4 *restrict dst,
  868. +    IN  const stateid4 *restrict src)
  869. +{
  870. +    (void)memcpy(dst, src, sizeof(stateid4));
  871. +}
  872. +
  873. +static __inline void stateid4_clear(
  874. +    OUT stateid4 *restrict dst)
  875. +{
  876. +    (void)memset(dst, 0, sizeof(stateid4));
  877. +}
  878. +
  879. +static __inline int stateid4_cmp(
  880. +    IN  const stateid4 *restrict s1,
  881. +    IN  const stateid4 *restrict s2)
  882. +{
  883. +    return memcmp(s1, s2, sizeof(stateid4));
  884. +}
  885.  
  886.  ULONG nfs_file_info_to_attributes(
  887.      IN const nfs41_file_info *info);
  888. --
  889. 2.45.1
  890.  
  891. From f6cff2b3f9de8376ac17556515df43c25117fb2d Mon Sep 17 00:00:00 2001
  892. From: Roland Mainz <roland.mainz@nrubsig.org>
  893. Date: Sat, 27 Jul 2024 16:11:22 +0200
  894. Subject: [PATCH 5/6] cygwin: msnfs41client *run_daemon should test for
  895.  idmapper dependencies
  896.  
  897. msnfs41client.bash run_daemon/sys_run_daemon should test for idmapper
  898. dependencies (e.g. /bin/ksh93, /lib/msnfs41client/cygwin_idmapper.ksh)
  899.  
  900. Reported-by: Dan Shelton <dan.f.shelton@gmail.com>
  901. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  902. ---
  903. cygwin/devel/msnfs41client.bash | 15 +++++++++++++++
  904.  1 file changed, 15 insertions(+)
  905.  
  906. diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
  907. index 34a9634..0553938 100644
  908. --- a/cygwin/devel/msnfs41client.bash
  909. +++ b/cygwin/devel/msnfs41client.bash
  910. @@ -561,6 +561,17 @@ function require_cmd
  911.         return 0
  912.  }
  913.  
  914. +function require_file
  915. +{
  916. +       typeset testfile="$1"
  917. +
  918. +       if [[ ! -f "$testfile" ]] ; then
  919. +               printf $"%s: File %q not found in %q\n" "$0" "$cmd" "$PWD" 1>&2
  920. +               return 1
  921. +       fi
  922. +       return 0
  923. +}
  924. +
  925.  # execute cmd as Windows user "SYSTEM"
  926.  function su_system
  927.  {
  928. @@ -658,6 +669,8 @@ function main
  929.                         require_cmd 'nfsd.exe' || (( numerr++ ))
  930.                         require_cmd 'nfsd_debug.exe' || (( numerr++ ))
  931.                         require_cmd 'nfs_mount.exe' || (( numerr++ ))
  932. +                       require_cmd 'ksh93.exe' || (( numerr++ ))
  933. +                       require_file '/lib/msnfs41client/cygwin_idmapper.ksh' || (( numerr++ ))
  934.                         (( numerr > 0 )) && return 1
  935.  
  936.                         nfsclient_rundeamon
  937. @@ -670,6 +683,8 @@ function main
  938.                         require_cmd 'nfsd.exe' || (( numerr++ ))
  939.                         require_cmd 'nfsd_debug.exe' || (( numerr++ ))
  940.                         require_cmd 'nfs_mount.exe' || (( numerr++ ))
  941. +                       require_cmd 'ksh93.exe' || (( numerr++ ))
  942. +                       require_file '/lib/msnfs41client/cygwin_idmapper.ksh' || (( numerr++ ))
  943.                         if ! is_windows_admin_account ; then
  944.                                 printf $"%s: %q requires Windows Adminstator permissions.\n" "$0" "$cmd"
  945.                                 (( numerr++ ))
  946. --
  947. 2.45.1
  948.  
  949. From 94f6c896fb914b98b5505e4c4c399db6e5e3da47 Mon Sep 17 00:00:00 2001
  950. From: Roland Mainz <roland.mainz@nrubsig.org>
  951. Date: Sat, 27 Jul 2024 16:29:10 +0200
  952. Subject: [PATCH 6/6] cygwin: make -f cygwin/Makefile installdest on a clean
  953.  repro fails
  954.  
  955. make -f cygwin/Makefile installdest on a clean repro fails due
  956. to missing dependencies.
  957.  
  958. Reported-by: Dan Shelton <dan.f.shelton@gmail.com>
  959. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  960. ---
  961. cygwin/Makefile | 8 ++++++++
  962.  1 file changed, 8 insertions(+)
  963.  
  964. diff --git a/cygwin/Makefile b/cygwin/Makefile
  965. index 15d5336..8a2a7b5 100644
  966. --- a/cygwin/Makefile
  967. +++ b/cygwin/Makefile
  968. @@ -30,6 +30,11 @@ $(VS_BUILD_DIR32)/nfsd.exe \
  969.         $(VS_BUILD_DIR64)/nfs41_driver.sys \
  970.         $(VS_BUILD_DIR64)/libtirpc.dll: build
  971.  
  972. +# trigger "build_testutils" target when these binaries are needed
  973. +$(PROJECT_BASEDIR_DIR)/tests/ea/nfs_ea.exe \
  974. +       $(PROJECT_BASEDIR_DIR)/tests/winfsinfo1/winfsinfo.exe \
  975. +       $(PROJECT_BASEDIR_DIR)/tests/winsg/winsg.exe: build_testutils
  976. +
  977.  #
  978.  # build the code
  979.  #
  980. @@ -86,6 +91,9 @@ installdest: \
  981.         $(PROJECT_BASEDIR_DIR)/nfs41rdr.inf \
  982.         $(PROJECT_BASEDIR_DIR)/etc_netconfig \
  983.         $(PROJECT_BASEDIR_DIR)/ms-nfs41-idmap.conf \
  984. +       $(PROJECT_BASEDIR_DIR)/tests/ea/nfs_ea.exe \
  985. +       $(PROJECT_BASEDIR_DIR)/tests/winfsinfo1/winfsinfo.exe \
  986. +       $(PROJECT_BASEDIR_DIR)/tests/winsg/winsg.exe \
  987.         $(CYGWIN_MAKEFILE_DIR)/devel/msnfs41client.bash
  988.         # installdest 32bit Windows
  989.         make -f $(CYGWIN_MAKEFILE_DIR)/Makefile.install \
  990. --
  991. 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