pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patch for FATTR4 enum sign issue, implementing FATTR4_WORD2_CLONE_BLKSIZE+misc, 2025-04-26
Posted by Anonymous on Sat 26th Apr 2025 21:08
raw | new post

  1. From ea84a6190bc08d42b674b0c90397eec28f1843b2 Mon Sep 17 00:00:00 2001
  2. From: Dan Shelton <dan.f.shelton@gmail.com>
  3. Date: Sat, 26 Apr 2025 20:30:48 +0200
  4. Subject: [PATCH 1/4] daemon: Fix arithmetic overflow issues
  5.  
  6. Fix arithmetic overflow issues.
  7.  
  8. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  9. ---
  10. daemon/nfs42_xdr.c | 6 +++---
  11.  1 file changed, 3 insertions(+), 3 deletions(-)
  12.  
  13. diff --git a/daemon/nfs42_xdr.c b/daemon/nfs42_xdr.c
  14. index ab7248e..1e9c731 100644
  15. --- a/daemon/nfs42_xdr.c
  16. +++ b/daemon/nfs42_xdr.c
  17. @@ -203,9 +203,9 @@ static bool_t decode_read_plus_res_ok(
  18.                          ("i=%d, decoding 'bytes' failed\n", (int)i));
  19.                      return FALSE;
  20.                  }
  21. -                read_data_len = __max(read_data_len,
  22. +                read_data_len = __max((size_t)read_data_len,
  23.                      ((size_t)(contents[i].u.data.data - res->data) +
  24. -                        contents[i].u.data.data_len));
  25. +                        (size_t)contents[i].u.data.data_len));
  26.              }
  27.                  break;
  28.              case NFS4_CONTENT_HOLE:
  29. @@ -232,7 +232,7 @@ static bool_t decode_read_plus_res_ok(
  30.                   */
  31.                  if (((hole_buff - res->data) + hole_length) >
  32.                      res->data_len) {
  33. -                    hole_length = res->data_len -
  34. +                    hole_length = (uint64_t)res->data_len -
  35.                          (hole_buff - res->data);
  36.                  }
  37.  
  38. --
  39. 2.45.1
  40.  
  41. From 073c79ec054d8345aa5e662ccf061501aabec736 Mon Sep 17 00:00:00 2001
  42. From: Roland Mainz <roland.mainz@nrubsig.org>
  43. Date: Sat, 26 Apr 2025 20:32:03 +0200
  44. Subject: [PATCH 2/4] daemon: |FATTR4_*| values cannot be an |enum|
  45.  
  46. |FATTR4_*| values cannot be an |enum|, because in ISO C17 an |enum|
  47. only has the type |signed int|, while any |MAKE_WORDx()| macro
  48. with a value of |31| will cause |signed|/|unsigned| issues.
  49.  
  50. Fix is to turn all |FATTR4_*| values into #define statements.
  51.  
  52. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  53. ---
  54. daemon/nfs41_const.h      | 171 ++++++++++++++++++++------------------
  55.  daemon/nfs41_superblock.c |   2 +-
  56.  2 files changed, 90 insertions(+), 83 deletions(-)
  57.  
  58. diff --git a/daemon/nfs41_const.h b/daemon/nfs41_const.h
  59. index 2d6f9c5..fcad41e 100644
  60. --- a/daemon/nfs41_const.h
  61. +++ b/daemon/nfs41_const.h
  62. @@ -250,96 +250,103 @@ enum nfsstat4 {
  63.      NFS4ERR_XATTR2BIG           = 10096
  64.  };
  65.  
  66. -#define MAKE_WORD0(XXX) (1 << (XXX))
  67. -#define MAKE_WORD1(XXX) (1 << ((XXX)-32))
  68. -#define MAKE_WORD2(XXX) (1 << ((XXX)-64))
  69. +/*
  70. + * NFSv4 attribute definitions
  71. + *
  72. + * Notes:
  73. + * - We cannot use |enum| because the default enum type is a
  74. + * |signed int|, which will not work for any |MAKE_WORDx()| macro
  75. + * with a value of 31
  76. + */
  77. +#define MAKE_WORD0(x) (1UL << (x))
  78. +#define MAKE_WORD1(x) (1UL << ((x)-32))
  79. +#define MAKE_WORD2(x) (1UL << ((x)-64))
  80.  
  81. -enum {
  82.  /*
  83.   * Mandatory Attributes
  84.   */
  85. -    FATTR4_WORD0_SUPPORTED_ATTRS    = MAKE_WORD0(0),
  86. -    FATTR4_WORD0_TYPE               = MAKE_WORD0(1),
  87. -    FATTR4_WORD0_FH_EXPIRE_TYPE     = MAKE_WORD0(2),
  88. -    FATTR4_WORD0_CHANGE             = MAKE_WORD0(3),
  89. -    FATTR4_WORD0_SIZE               = MAKE_WORD0(4),
  90. -    FATTR4_WORD0_LINK_SUPPORT       = MAKE_WORD0(5),
  91. -    FATTR4_WORD0_SYMLINK_SUPPORT    = MAKE_WORD0(6),
  92. -    FATTR4_WORD0_NAMED_ATTR         = MAKE_WORD0(7),
  93. -    FATTR4_WORD0_FSID               = MAKE_WORD0(8),
  94. -    FATTR4_WORD0_UNIQUE_HANDLES     = MAKE_WORD0(9),
  95. -    FATTR4_WORD0_LEASE_TIME         = MAKE_WORD0(10),
  96. -    FATTR4_WORD0_RDATTR_ERROR       = MAKE_WORD0(11),
  97. -    FATTR4_WORD0_FILEHANDLE         = MAKE_WORD0(19),
  98. -    FATTR4_WORD2_SUPPATTR_EXCLCREAT = MAKE_WORD2(75),
  99. +#define FATTR4_WORD0_SUPPORTED_ATTRS    MAKE_WORD0(0)
  100. +#define FATTR4_WORD0_TYPE               MAKE_WORD0(1)
  101. +#define FATTR4_WORD0_FH_EXPIRE_TYPE     MAKE_WORD0(2)
  102. +#define FATTR4_WORD0_CHANGE             MAKE_WORD0(3)
  103. +#define FATTR4_WORD0_SIZE               MAKE_WORD0(4)
  104. +#define FATTR4_WORD0_LINK_SUPPORT       MAKE_WORD0(5)
  105. +#define FATTR4_WORD0_SYMLINK_SUPPORT    MAKE_WORD0(6)
  106. +#define FATTR4_WORD0_NAMED_ATTR         MAKE_WORD0(7)
  107. +#define FATTR4_WORD0_FSID               MAKE_WORD0(8)
  108. +#define FATTR4_WORD0_UNIQUE_HANDLES     MAKE_WORD0(9)
  109. +#define FATTR4_WORD0_LEASE_TIME         MAKE_WORD0(10)
  110. +#define FATTR4_WORD0_RDATTR_ERROR       MAKE_WORD0(11)
  111. +#define FATTR4_WORD0_FILEHANDLE         MAKE_WORD0(19)
  112. +#define FATTR4_WORD2_SUPPATTR_EXCLCREAT MAKE_WORD2(75)
  113.  
  114.  /*
  115.   * Recommended Attributes
  116.   */
  117. -    FATTR4_WORD0_ACL                = MAKE_WORD0(12),
  118. -    FATTR4_WORD0_ACLSUPPORT         = MAKE_WORD0(13),
  119. -    FATTR4_WORD0_ARCHIVE            = MAKE_WORD0(14),
  120. -    FATTR4_WORD0_CANSETTIME         = MAKE_WORD0(15),
  121. -    FATTR4_WORD0_CASE_INSENSITIVE   = MAKE_WORD0(16),
  122. -    FATTR4_WORD0_CASE_PRESERVING    = MAKE_WORD0(17),
  123. -    FATTR4_WORD0_CHOWN_RESTRICTED   = MAKE_WORD0(18),
  124. -    FATTR4_WORD0_FILEID             = MAKE_WORD0(20),
  125. -    FATTR4_WORD0_FILES_AVAIL        = MAKE_WORD0(21),
  126. -    FATTR4_WORD0_FILES_FREE         = MAKE_WORD0(22),
  127. -    FATTR4_WORD0_FILES_TOTAL        = MAKE_WORD0(23),
  128. -    FATTR4_WORD0_FS_LOCATIONS       = MAKE_WORD0(24),
  129. -    FATTR4_WORD0_HIDDEN             = MAKE_WORD0(25),
  130. -    FATTR4_WORD0_HOMOGENEOUS        = MAKE_WORD0(26),
  131. -    FATTR4_WORD0_MAXFILESIZE        = MAKE_WORD0(27),
  132. -    FATTR4_WORD0_MAXLINK            = MAKE_WORD0(28),
  133. -    FATTR4_WORD0_MAXNAME            = MAKE_WORD0(29),
  134. -    FATTR4_WORD0_MAXREAD            = MAKE_WORD0(30),
  135. -    FATTR4_WORD0_MAXWRITE           = MAKE_WORD0(31),
  136. -    FATTR4_WORD1_MIMETYPE           = MAKE_WORD1(32),
  137. -    FATTR4_WORD1_MODE               = MAKE_WORD1(33),
  138. -    FATTR4_WORD1_NO_TRUNC           = MAKE_WORD1(34),
  139. -    FATTR4_WORD1_NUMLINKS           = MAKE_WORD1(35),
  140. -    FATTR4_WORD1_OWNER              = MAKE_WORD1(36),
  141. -    FATTR4_WORD1_OWNER_GROUP        = MAKE_WORD1(37),
  142. -    FATTR4_WORD1_QUOTA_AVAIL_HARD   = MAKE_WORD1(38),
  143. -    FATTR4_WORD1_QUOTA_AVAIL_SOFT   = MAKE_WORD1(39),
  144. -    FATTR4_WORD1_QUOTA_USED         = MAKE_WORD1(40),
  145. -    FATTR4_WORD1_RAWDEV             = MAKE_WORD1(41),
  146. -    FATTR4_WORD1_SPACE_AVAIL        = MAKE_WORD1(42),
  147. -    FATTR4_WORD1_SPACE_FREE         = MAKE_WORD1(43),
  148. -    FATTR4_WORD1_SPACE_TOTAL        = MAKE_WORD1(44),
  149. -    FATTR4_WORD1_SPACE_USED         = MAKE_WORD1(45),
  150. -    FATTR4_WORD1_SYSTEM             = MAKE_WORD1(46),
  151. -    FATTR4_WORD1_TIME_ACCESS        = MAKE_WORD1(47),
  152. -    FATTR4_WORD1_TIME_ACCESS_SET    = MAKE_WORD1(48),
  153. -    FATTR4_WORD1_TIME_BACKUP        = MAKE_WORD1(49),
  154. -    FATTR4_WORD1_TIME_CREATE        = MAKE_WORD1(50),
  155. -    FATTR4_WORD1_TIME_DELTA         = MAKE_WORD1(51),
  156. -    FATTR4_WORD1_TIME_METADATA      = MAKE_WORD1(52),
  157. -    FATTR4_WORD1_TIME_MODIFY        = MAKE_WORD1(53),
  158. -    FATTR4_WORD1_TIME_MODIFY_SET    = MAKE_WORD1(54),
  159. -    FATTR4_WORD1_MOUNTED_ON_FILEID  = MAKE_WORD1(55),
  160. -    FATTR4_WORD1_DIR_NOTIF_DELAY    = MAKE_WORD1(56),
  161. -    FATTR4_WORD1_DIRENT_NOTIF_DELAY = MAKE_WORD1(57),
  162. -    FATTR4_WORD1_DACL               = MAKE_WORD1(58),
  163. -    FATTR4_WORD1_SACL               = MAKE_WORD1(59),
  164. -    FATTR4_WORD1_CHANGE_POLICY      = MAKE_WORD1(60),
  165. -    FATTR4_WORD1_FS_STATUS          = MAKE_WORD1(61),
  166. -    FATTR4_WORD1_FS_LAYOUT_TYPE     = MAKE_WORD1(62),
  167. -    FATTR4_WORD1_LAYOUT_HINT        = MAKE_WORD1(63),
  168. -    FATTR4_WORD2_LAYOUT_TYPE        = MAKE_WORD2(64),
  169. -    FATTR4_WORD2_LAYOUT_BLKSIZE     = MAKE_WORD2(65),
  170. -    FATTR4_WORD2_LAYOUT_ALIGNMENT   = MAKE_WORD2(66),
  171. -    FATTR4_WORD2_FS_LOCATIONS_INFO  = MAKE_WORD2(67),
  172. -    FATTR4_WORD2_MDSTHRESHOLD       = MAKE_WORD2(68),
  173. -    FATTR4_WORD2_RETENTION_GET      = MAKE_WORD2(69),
  174. -    FATTR4_WORD2_RETENTION_SET      = MAKE_WORD2(70),
  175. -    FATTR4_WORD2_RETENTEVT_GET      = MAKE_WORD2(71),
  176. -    FATTR4_WORD2_RETENTEVT_SET      = MAKE_WORD2(72),
  177. -    FATTR4_WORD2_RETENTION_HOLD     = MAKE_WORD2(73),
  178. -    FATTR4_WORD2_MODE_SET_MASKED    = MAKE_WORD2(74),
  179. -    FATTR4_WORD2_FS_CHARSET_CAP     = MAKE_WORD2(76),
  180. -};
  181. +#define FATTR4_WORD0_ACL                MAKE_WORD0(12)
  182. +#define FATTR4_WORD0_ACLSUPPORT         MAKE_WORD0(13)
  183. +#define FATTR4_WORD0_ARCHIVE            MAKE_WORD0(14)
  184. +#define FATTR4_WORD0_CANSETTIME         MAKE_WORD0(15)
  185. +#define FATTR4_WORD0_CASE_INSENSITIVE   MAKE_WORD0(16)
  186. +#define FATTR4_WORD0_CASE_PRESERVING    MAKE_WORD0(17)
  187. +#define FATTR4_WORD0_CHOWN_RESTRICTED   MAKE_WORD0(18)
  188. +#define FATTR4_WORD0_FILEID             MAKE_WORD0(20)
  189. +#define FATTR4_WORD0_FILES_AVAIL        MAKE_WORD0(21)
  190. +#define FATTR4_WORD0_FILES_FREE         MAKE_WORD0(22)
  191. +#define FATTR4_WORD0_FILES_TOTAL        MAKE_WORD0(23)
  192. +#define FATTR4_WORD0_FS_LOCATIONS       MAKE_WORD0(24)
  193. +#define FATTR4_WORD0_HIDDEN             MAKE_WORD0(25)
  194. +#define FATTR4_WORD0_HOMOGENEOUS        MAKE_WORD0(26)
  195. +#define FATTR4_WORD0_MAXFILESIZE        MAKE_WORD0(27)
  196. +#define FATTR4_WORD0_MAXLINK            MAKE_WORD0(28)
  197. +#define FATTR4_WORD0_MAXNAME            MAKE_WORD0(29)
  198. +#define FATTR4_WORD0_MAXREAD            MAKE_WORD0(30)
  199. +#define FATTR4_WORD0_MAXWRITE           MAKE_WORD0(31)
  200. +#define FATTR4_WORD1_MIMETYPE           MAKE_WORD1(32)
  201. +#define FATTR4_WORD1_MODE               MAKE_WORD1(33)
  202. +#define FATTR4_WORD1_NO_TRUNC           MAKE_WORD1(34)
  203. +#define FATTR4_WORD1_NUMLINKS           MAKE_WORD1(35)
  204. +#define FATTR4_WORD1_OWNER              MAKE_WORD1(36)
  205. +#define FATTR4_WORD1_OWNER_GROUP        MAKE_WORD1(37)
  206. +#define FATTR4_WORD1_QUOTA_AVAIL_HARD   MAKE_WORD1(38)
  207. +#define FATTR4_WORD1_QUOTA_AVAIL_SOFT   MAKE_WORD1(39)
  208. +#define FATTR4_WORD1_QUOTA_USED         MAKE_WORD1(40)
  209. +#define FATTR4_WORD1_RAWDEV             MAKE_WORD1(41)
  210. +#define FATTR4_WORD1_SPACE_AVAIL        MAKE_WORD1(42)
  211. +#define FATTR4_WORD1_SPACE_FREE         MAKE_WORD1(43)
  212. +#define FATTR4_WORD1_SPACE_TOTAL        MAKE_WORD1(44)
  213. +#define FATTR4_WORD1_SPACE_USED         MAKE_WORD1(45)
  214. +#define FATTR4_WORD1_SYSTEM             MAKE_WORD1(46)
  215. +#define FATTR4_WORD1_TIME_ACCESS        MAKE_WORD1(47)
  216. +#define FATTR4_WORD1_TIME_ACCESS_SET    MAKE_WORD1(48)
  217. +#define FATTR4_WORD1_TIME_BACKUP        MAKE_WORD1(49)
  218. +#define FATTR4_WORD1_TIME_CREATE        MAKE_WORD1(50)
  219. +#define FATTR4_WORD1_TIME_DELTA         MAKE_WORD1(51)
  220. +#define FATTR4_WORD1_TIME_METADATA      MAKE_WORD1(52)
  221. +#define FATTR4_WORD1_TIME_MODIFY        MAKE_WORD1(53)
  222. +#define FATTR4_WORD1_TIME_MODIFY_SET    MAKE_WORD1(54)
  223. +#define FATTR4_WORD1_MOUNTED_ON_FILEID  MAKE_WORD1(55)
  224. +#define FATTR4_WORD1_DIR_NOTIF_DELAY    MAKE_WORD1(56)
  225. +#define FATTR4_WORD1_DIRENT_NOTIF_DELAY MAKE_WORD1(57)
  226. +#define FATTR4_WORD1_DACL               MAKE_WORD1(58)
  227. +#define FATTR4_WORD1_SACL               MAKE_WORD1(59)
  228. +#define FATTR4_WORD1_CHANGE_POLICY      MAKE_WORD1(60)
  229. +#define FATTR4_WORD1_FS_STATUS          MAKE_WORD1(61)
  230. +#define FATTR4_WORD1_FS_LAYOUT_TYPE     MAKE_WORD1(62)
  231. +#define FATTR4_WORD1_LAYOUT_HINT        MAKE_WORD1(63)
  232. +#define FATTR4_WORD2_LAYOUT_TYPE        MAKE_WORD2(64)
  233. +#define FATTR4_WORD2_LAYOUT_BLKSIZE     MAKE_WORD2(65)
  234. +#define FATTR4_WORD2_LAYOUT_ALIGNMENT   MAKE_WORD2(66)
  235. +#define FATTR4_WORD2_FS_LOCATIONS_INFO  MAKE_WORD2(67)
  236. +#define FATTR4_WORD2_MDSTHRESHOLD       MAKE_WORD2(68)
  237. +#define FATTR4_WORD2_RETENTION_GET      MAKE_WORD2(69)
  238. +#define FATTR4_WORD2_RETENTION_SET      MAKE_WORD2(70)
  239. +#define FATTR4_WORD2_RETENTEVT_GET      MAKE_WORD2(71)
  240. +#define FATTR4_WORD2_RETENTEVT_SET      MAKE_WORD2(72)
  241. +#define FATTR4_WORD2_RETENTION_HOLD     MAKE_WORD2(73)
  242. +#define FATTR4_WORD2_MODE_SET_MASKED    MAKE_WORD2(74)
  243. +#define FATTR4_WORD2_FS_CHARSET_CAP     MAKE_WORD2(76)
  244. +
  245.  
  246.  /*
  247.   * File types
  248. diff --git a/daemon/nfs41_superblock.c b/daemon/nfs41_superblock.c
  249. index 3787905..918cb6c 100644
  250. --- a/daemon/nfs41_superblock.c
  251. +++ b/daemon/nfs41_superblock.c
  252. @@ -87,7 +87,7 @@ static int get_superblock_attrs(
  253.          FATTR4_WORD0_LINK_SUPPORT | FATTR4_WORD0_SYMLINK_SUPPORT |
  254.          FATTR4_WORD0_ACLSUPPORT | FATTR4_WORD0_CANSETTIME |
  255.          FATTR4_WORD0_CASE_INSENSITIVE | FATTR4_WORD0_CASE_PRESERVING |
  256. -        FATTR4_WORD0_MAXREAD | (uint32_t)(FATTR4_WORD0_MAXWRITE);
  257. +        FATTR4_WORD0_MAXREAD | FATTR4_WORD0_MAXWRITE;
  258.      attr_request.arr[1] = FATTR4_WORD1_FS_LAYOUT_TYPE |
  259.          FATTR4_WORD1_TIME_DELTA;
  260.      attr_request.arr[2] = FATTR4_WORD2_SUPPATTR_EXCLCREAT;
  261. --
  262. 2.45.1
  263.  
  264. From 5dbaf6e8ce14903546afb07d7e697e1ae0ccc9bf Mon Sep 17 00:00:00 2001
  265. From: Roland Mainz <roland.mainz@nrubsig.org>
  266. Date: Sat, 26 Apr 2025 21:50:11 +0200
  267. Subject: [PATCH 3/4] daemon: Implement |FATTR4_WORD2_CLONE_BLKSIZE| support
  268.  
  269. Implement |FATTR4_WORD2_CLONE_BLKSIZE| support
  270.  
  271. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  272. ---
  273. daemon/daemon_debug.c | 11 +++++++++++
  274.  daemon/fileinfoutil.c |  3 +++
  275.  daemon/fsctl.c        | 26 +++++++++++++++++++++++++-
  276.  daemon/name_cache.c   | 18 +++++++++++++++++-
  277.  daemon/nfs41_const.h  |  1 +
  278.  daemon/nfs41_types.h  |  1 +
  279.  daemon/nfs41_xdr.c    |  4 ++++
  280.  7 files changed, 62 insertions(+), 2 deletions(-)
  281.  
  282. diff --git a/daemon/daemon_debug.c b/daemon/daemon_debug.c
  283. index 10fd4b9..7d81b9c 100644
  284. --- a/daemon/daemon_debug.c
  285. +++ b/daemon/daemon_debug.c
  286. @@ -1119,6 +1119,17 @@ void print_nfs41_file_info(
  287.              PRNFS41FI_FMT("system=%d, ", (int)info->system);
  288.          p += snprintf(p, (sizeof(buf)-(p-buf)), "} ");
  289.      }
  290. +    if (info->attrmask.count >= 3) {
  291. +        PRNFS41FI_FMT("{ attrmask.arr[2]=0x%x, ",
  292. +            (int)info->attrmask.arr[2]);
  293. +
  294. +        if (info->attrmask.arr[2] & FATTR4_WORD2_CLONE_BLKSIZE) {
  295. +            PRNFS41FI_FMT("clone_blksize=%ld, ",
  296. +                (long)info->clone_blksize);
  297. +        }
  298. +
  299. +        p += snprintf(p, (sizeof(buf)-(p-buf)), "} ");
  300. +    }
  301.  
  302.      dprintf_out("%s={ %s }\n", label, buf);
  303.  }
  304. diff --git a/daemon/fileinfoutil.c b/daemon/fileinfoutil.c
  305. index 85a36ae..644d235 100644
  306. --- a/daemon/fileinfoutil.c
  307. +++ b/daemon/fileinfoutil.c
  308. @@ -631,6 +631,9 @@ void nfs41_file_info_cpy(
  309.          if (attrmask->arr[2] & FATTR4_WORD2_SUPPATTR_EXCLCREAT) {
  310.              dest->suppattr_exclcreat = src->suppattr_exclcreat;
  311.          }
  312. +        if (attrmask->arr[2] & FATTR4_WORD2_CLONE_BLKSIZE) {
  313. +            dest->clone_blksize = src->clone_blksize;
  314. +        }
  315.      }
  316.  
  317.      if (flags & NFS41FILEINFOCPY_COPY_SYMLINK_DIR) {
  318. diff --git a/daemon/fsctl.c b/daemon/fsctl.c
  319. index 7d83c32..c191f39 100644
  320. --- a/daemon/fsctl.c
  321. +++ b/daemon/fsctl.c
  322. @@ -527,7 +527,12 @@ int handle_duplicatedata(void *daemon_context,
  323.  
  324.  #ifdef CLONE_PUNCH_HOLE_IF_CLONESIZE_BIGGER_THAN_SRCFILESIZE
  325.      int64_t src_file_size;
  326. -    bitmap4 attr_request = { .count = 1, .arr[0] = FATTR4_WORD0_SIZE };
  327. +    bitmap4 attr_request = {
  328. +        .count = 3,
  329. +        .arr[0] = FATTR4_WORD0_SIZE,
  330. +        .arr[1] = 0UL,
  331. +        .arr[2] = FATTR4_WORD2_CLONE_BLKSIZE
  332. +    };
  333.      status = nfs41_getattr(session, src_file, &attr_request, &info);
  334.      if (status) {
  335.          eprintf("handle_duplicatedata: "
  336. @@ -536,6 +541,21 @@ int handle_duplicatedata(void *daemon_context,
  337.          status = nfs_to_windows_error(status, ERROR_BAD_NET_RESP);
  338.          goto out;
  339.      }
  340. +
  341. +    EASSERT(bitmap_isset(&info.attrmask, 0, FATTR4_WORD0_SIZE));
  342. +    if (bitmap_isset(&info.attrmask, 2, FATTR4_WORD2_CLONE_BLKSIZE)) {
  343. +        DPRINTF(DDLVL,
  344. +            ("handle_duplicatedata: "
  345. +            "srcfile size=%lld, clone_blksize=%lu\n",
  346. +            (long long)info.size,
  347. +            (unsigned long)info.clone_blksize));
  348. +    }
  349. +    else {
  350. +        DPRINTF(DDLVL,
  351. +            ("handle_duplicatedata: srcfile size=%lld\n",
  352. +            (long long)info.size));
  353. +    }
  354. +
  355.      src_file_size = info.size;
  356.  
  357.      if ((args->srcfileoffset+args->bytecount) > src_file_size)
  358. @@ -543,6 +563,10 @@ int handle_duplicatedata(void *daemon_context,
  359.      else
  360.          bytecount = args->bytecount;
  361.  #else
  362. +    /*
  363. +     * FIXME: We should validate against |FATTR4_WORD2_CLONE_BLKSIZE|
  364. +     * (if supported by NFSv4.2 server) in this codepath
  365. +     */
  366.      bytecount = args->bytecount;
  367.  #endif /* CLONE_PUNCH_HOLE_IF_CLONESIZE_BIGGER_THAN_SRCFILESIZE */
  368.  
  369. diff --git a/daemon/name_cache.c b/daemon/name_cache.c
  370. index bee2b4f..ffb66d5 100644
  371. --- a/daemon/name_cache.c
  372. +++ b/daemon/name_cache.c
  373. @@ -91,6 +91,7 @@ static __inline bool_t is_delegation(
  374.  #define NC_ATTR_TIME_CREATE (1 << 12)
  375.  #define NC_ATTR_TIME_MODIFY (1 << 13)
  376.  #define NC_ATTR_SYSTEM      (1 << 14)
  377. +#define NC_ATTR_CLONE_BLKSIZE (1 << 15)
  378.  
  379.  /* attribute cache */
  380.  struct attr_cache_entry {
  381. @@ -114,6 +115,7 @@ struct attr_cache_entry {
  382.      unsigned                hidden : 1;
  383.      unsigned                system : 1;
  384.      unsigned                archive : 1;
  385. +    uint32_t                clone_blksize;
  386.      util_reltimestamp       expiration;
  387.      unsigned                ref_count : 26;
  388.      unsigned                type : 4;
  389. @@ -386,6 +388,12 @@ static void attr_cache_update(
  390.              entry->system = info->system;
  391.          }
  392.      }
  393. +    if (info->attrmask.count > 2) {
  394. +        if (info->attrmask.arr[2] & FATTR4_WORD2_CLONE_BLKSIZE) {
  395. +            entry->nc_attrs |= NC_ATTR_CLONE_BLKSIZE;
  396. +            entry->clone_blksize = info->clone_blksize;
  397. +        }
  398. +    }
  399.  
  400.      if (is_delegation(delegation))
  401.          entry->delegated = TRUE;
  402. @@ -397,6 +405,7 @@ static void copy_attrs(
  403.  {
  404.      dst->attrmask.arr[0] = 0;
  405.      dst->attrmask.arr[1] = 0;
  406. +    dst->attrmask.arr[2] = 0;
  407.  
  408.      dst->attrmask.arr[0] |= FATTR4_WORD0_FILEID;
  409.      dst->fileid = src->fileid;
  410. @@ -475,8 +484,15 @@ static void copy_attrs(
  411.          dst->attrmask.arr[1] |= FATTR4_WORD1_SYSTEM;
  412.          dst->system = src->system;
  413.      }
  414. +    if (src->nc_attrs & NC_ATTR_CLONE_BLKSIZE) {
  415. +        dst->attrmask.arr[2] |= FATTR4_WORD2_CLONE_BLKSIZE;
  416. +        dst->clone_blksize = src->clone_blksize;
  417. +    }
  418.  
  419. -    if (dst->attrmask.arr[1] != 0) {
  420. +    if (dst->attrmask.arr[2] != 0) {
  421. +        dst->attrmask.count = 3;
  422. +    }
  423. +    else if (dst->attrmask.arr[1] != 0) {
  424.          dst->attrmask.count = 2;
  425.      }
  426.      else {
  427. diff --git a/daemon/nfs41_const.h b/daemon/nfs41_const.h
  428. index fcad41e..2bc5c62 100644
  429. --- a/daemon/nfs41_const.h
  430. +++ b/daemon/nfs41_const.h
  431. @@ -346,6 +346,7 @@ enum nfsstat4 {
  432.  #define FATTR4_WORD2_RETENTION_HOLD     MAKE_WORD2(73)
  433.  #define FATTR4_WORD2_MODE_SET_MASKED    MAKE_WORD2(74)
  434.  #define FATTR4_WORD2_FS_CHARSET_CAP     MAKE_WORD2(76)
  435. +#define FATTR4_WORD2_CLONE_BLKSIZE      MAKE_WORD2(77)
  436.  
  437.  
  438.  /*
  439. diff --git a/daemon/nfs41_types.h b/daemon/nfs41_types.h
  440. index f3f6a12..8501674 100644
  441. --- a/daemon/nfs41_types.h
  442. +++ b/daemon/nfs41_types.h
  443. @@ -221,6 +221,7 @@ typedef struct __nfs41_file_info {
  444.      bool_t                  hidden;
  445.      bool_t                  system;
  446.      bool_t                  archive;
  447. +    uint32_t                clone_blksize;
  448.      bool_t                  case_insensitive;
  449.      bool_t                  case_preserving;
  450.      bool_t                  symlink_dir;
  451. diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
  452. index 2d651a4..c36b20a 100644
  453. --- a/daemon/nfs41_xdr.c
  454. +++ b/daemon/nfs41_xdr.c
  455. @@ -1917,6 +1917,10 @@ static bool_t decode_file_attrs(
  456.              if (!xdr_bitmap4(xdr, info->suppattr_exclcreat))
  457.                  return FALSE;
  458.          }
  459. +        if (attrs->attrmask.arr[2] & FATTR4_WORD2_CLONE_BLKSIZE) {
  460. +            if (!xdr_u_int32_t(xdr, &info->clone_blksize))
  461. +                return FALSE;
  462. +        }
  463.      }
  464.      return TRUE;
  465.  }
  466. --
  467. 2.45.1
  468.  
  469. From 8fa6e9e6bfde55297c6e5133a078699b2f073043 Mon Sep 17 00:00:00 2001
  470. From: Roland Mainz <roland.mainz@nrubsig.org>
  471. Date: Sat, 26 Apr 2025 21:58:11 +0200
  472. Subject: [PATCH 4/4] tests: nfsbuildtest: Generated mkinstalldirs should be
  473.  newline-terminated
  474.  
  475. nfsbuildtest: Generated mkinstalldirs should be newline-terminated.
  476.  
  477. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  478. ---
  479. tests/nfsbuildtest/nfsbuildtest.ksh93 | 4 ++--
  480.  1 file changed, 2 insertions(+), 2 deletions(-)
  481.  
  482. diff --git a/tests/nfsbuildtest/nfsbuildtest.ksh93 b/tests/nfsbuildtest/nfsbuildtest.ksh93
  483. index f642ff9..864eff4 100644
  484. --- a/tests/nfsbuildtest/nfsbuildtest.ksh93
  485. +++ b/tests/nfsbuildtest/nfsbuildtest.ksh93
  486. @@ -147,7 +147,7 @@ function gcc_build
  487.         patch_gcc13_1_0_libiberty_strsignal_psignal_prototype
  488.  
  489.         # original mkinstalldirs cannot handle UNC paths
  490. -       printf '#!/bin/sh\n# original mkinstalldirs cannot handle Cygwin UNC paths\nmkdir -p "$@"\nexit $?' >'mkinstalldirs'
  491. +       printf '#!/bin/sh\n# original mkinstalldirs cannot handle Cygwin UNC paths\nmkdir -p "$@"\nexit $?\n' >'mkinstalldirs'
  492.         chmod a+x 'mkinstalldirs'
  493.  
  494.         # Cygwin/MSYS2: workaround for configure using cp -p where ln -s should be used
  495. @@ -321,7 +321,7 @@ function bash_build
  496.         #
  497.  
  498.         # original mkinstalldirs cannot handle UNC paths
  499. -       printf '#!/bin/sh\n# original mkinstalldirs cannot handle Cygwin UNC paths\nmkdir -p "$@"\nexit $?' >'support/mkinstalldirs'
  500. +       printf '#!/bin/sh\n# original mkinstalldirs cannot handle Cygwin UNC paths\nmkdir -p "$@"\nexit $?\n' >'mkinstalldirs'
  501.         chmod a+x 'support/mkinstalldirs'
  502.  
  503.         # disable loadable plugins
  504. --
  505. 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