pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: "createmode=" mount option, debug rework+misc, 2024-06-17
Posted by Anonymous on Mon 17th Jun 2024 17:55
raw | new post

  1. From 2058c172554416322d03970c4635263378ceb3b0 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Mon, 17 Jun 2024 13:36:00 +0200
  4. Subject: [PATCH 1/8] daemon: Rework
  5.  |print_nfs_access_mask()|+|print_windows_access_mask()|
  6.  
  7. Rework |print_nfs_access_mask()| and |print_windows_access_mask()|.
  8.  
  9. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  10. ---
  11. daemon/acl.c          |   8 +-
  12.  daemon/daemon_debug.c | 192 ++++++++++++++++++------------------------
  13.  daemon/daemon_debug.h |   5 +-
  14.  3 files changed, 90 insertions(+), 115 deletions(-)
  15.  
  16. diff --git a/daemon/acl.c b/daemon/acl.c
  17. index 54a5815..6f6512e 100644
  18. --- a/daemon/acl.c
  19. +++ b/daemon/acl.c
  20. @@ -528,7 +528,9 @@ static void map_winaccessmask2nfs4acemask(ACCESS_MASK mask, int file_type, uint3
  21.      DPRINTF(ACLLVL,
  22.          ("--> map_winaccessmask2nfs4acemask(mask=0x%x)\n",
  23.          (int)mask));
  24. -    print_windows_access_mask(ACLLVL, mask);
  25. +    if (DPRINTF_LEVEL_ENABLED(0)) {
  26. +        print_windows_access_mask(mask);
  27. +    }
  28.      /* check if any GENERIC bits set */
  29.      if (mask & 0xf000000) {
  30.          if (mask & GENERIC_ALL) {
  31. @@ -547,7 +549,9 @@ static void map_winaccessmask2nfs4acemask(ACCESS_MASK mask, int file_type, uint3
  32.      }
  33.      else /* ignoring generic and reserved bits */
  34.          *nfs4_mask = mask & 0x00ffffff;
  35. -    print_nfs_access_mask(ACLLVL, *nfs4_mask);
  36. +    if (DPRINTF_LEVEL_ENABLED(0)) {
  37. +        print_nfs_access_mask(*nfs4_mask);
  38. +    }
  39.      DPRINTF(ACLLVL,
  40.          ("<-- map_winaccessmask2nfs4acemask(mask=0x%x, *nfs4_mask=0x%x)\n",
  41.          (int)mask, (int)*nfs4_mask));
  42. diff --git a/daemon/daemon_debug.c b/daemon/daemon_debug.c
  43. index ab4cee6..2da8256 100644
  44. --- a/daemon/daemon_debug.c
  45. +++ b/daemon/daemon_debug.c
  46. @@ -801,121 +801,91 @@ const char* secflavorop2name(DWORD sec_flavor)
  47.      return "<Unknown RPCSEC_AUTH* flavour>";
  48.  }
  49.  
  50. -void print_windows_access_mask(int on, ACCESS_MASK m)
  51. +void print_windows_access_mask(ACCESS_MASK win_mask)
  52.  {
  53. -    if (!on)
  54. -        return;
  55. -    if (!DPRINTF_LEVEL_ENABLED(1))
  56. -        return;
  57. -
  58. -    dprintf_out("--> print_windows_access_mask: %x\n", m);
  59. -    if (m & GENERIC_READ)
  60. -        dprintf_out("\tGENERIC_READ\n");
  61. -    if (m & GENERIC_WRITE)
  62. -        dprintf_out("\tGENERIC_WRITE\n");
  63. -    if (m & GENERIC_EXECUTE)
  64. -        dprintf_out("\tGENERIC_EXECUTE\n");
  65. -    if (m & GENERIC_ALL)
  66. -        dprintf_out("\tGENERIC_ALL\n");
  67. -    if (m & MAXIMUM_ALLOWED)
  68. -        dprintf_out("\tMAXIMUM_ALLOWED\n");
  69. -    if (m & ACCESS_SYSTEM_SECURITY)
  70. -        dprintf_out("\tACCESS_SYSTEM_SECURITY\n");
  71. -    if ((m & SPECIFIC_RIGHTS_ALL) == SPECIFIC_RIGHTS_ALL)
  72. -        dprintf_out("\tSPECIFIC_RIGHTS_ALL\n");
  73. -    if ((m & STANDARD_RIGHTS_ALL) == STANDARD_RIGHTS_ALL)
  74. -        dprintf_out("\tSTANDARD_RIGHTS_ALL\n");
  75. -    if ((m & STANDARD_RIGHTS_REQUIRED) == STANDARD_RIGHTS_REQUIRED)
  76. -        dprintf_out("\tSTANDARD_RIGHTS_REQUIRED\n");
  77. -    if (m & SYNCHRONIZE)
  78. -        dprintf_out("\tSYNCHRONIZE\n");
  79. -    if (m & WRITE_OWNER)
  80. -        dprintf_out("\tWRITE_OWNER\n");
  81. -    if (m & WRITE_DAC)
  82. -        dprintf_out("\tWRITE_DAC\n");
  83. -    if (m & READ_CONTROL)
  84. -        dprintf_out("\tREAD_CONTROL\n");
  85. -    if (m & DELETE)
  86. -        dprintf_out("\tDELETE\n");
  87. -    if (m & FILE_READ_DATA)
  88. -        dprintf_out("\tFILE_READ_DATA\n");
  89. -    if (m & FILE_LIST_DIRECTORY)
  90. -        dprintf_out("\tFILE_LIST_DIRECTORY\n");
  91. -    if (m & FILE_WRITE_DATA)
  92. -        dprintf_out("\tFILE_WRITE_DATA\n");
  93. -    if (m & FILE_ADD_FILE)
  94. -        dprintf_out("\tFILE_ADD_FILE\n");
  95. -    if (m & FILE_APPEND_DATA)
  96. -        dprintf_out("\tFILE_APPEND_DATA\n");
  97. -    if (m & FILE_ADD_SUBDIRECTORY)
  98. -        dprintf_out("\tFILE_ADD_SUBDIRECTORY\n");
  99. -    if (m & FILE_CREATE_PIPE_INSTANCE)
  100. -        dprintf_out("\tFILE_CREATE_PIPE_INSTANCE\n");
  101. -    if (m & FILE_READ_EA)
  102. -        dprintf_out("\tFILE_READ_EA\n");
  103. -    if (m & FILE_WRITE_EA)
  104. -        dprintf_out("\tFILE_WRITE_EA\n");
  105. -    if (m & FILE_EXECUTE)
  106. -        dprintf_out("\tFILE_EXECUTE\n");
  107. -    if (m & FILE_TRAVERSE)
  108. -        dprintf_out("\tFILE_TRAVERSE\n");
  109. -    if (m & FILE_DELETE_CHILD)
  110. -        dprintf_out("\tFILE_DELETE_CHILD\n");
  111. -    if (m & FILE_READ_ATTRIBUTES)
  112. -        dprintf_out("\tFILE_READ_ATTRIBUTES\n");
  113. -    if (m & FILE_WRITE_ATTRIBUTES)
  114. -        dprintf_out("\tFILE_WRITE_ATTRIBUTES\n");
  115. -    if ((m & FILE_ALL_ACCESS) == FILE_ALL_ACCESS)
  116. -        dprintf_out("\tFILE_ALL_ACCESS\n");
  117. -    if ((m & FILE_GENERIC_READ) == FILE_GENERIC_READ)
  118. -        dprintf_out("\tFILE_GENERIC_READ\n");
  119. -    if ((m & FILE_GENERIC_WRITE) == FILE_GENERIC_WRITE)
  120. -        dprintf_out("\tFILE_GENERIC_WRITE\n");
  121. -    if ((m & FILE_GENERIC_EXECUTE) == FILE_GENERIC_EXECUTE)
  122. -        dprintf_out("\tFILE_GENERIC_EXECUTE\n");
  123. +    dprintf_out("--> print_windows_access_mask: 0x%lx\n", (long)win_mask);
  124. +#define PRINTWINACCESSMASKBITS(s) \
  125. +    if ((win_mask & (s)) == (s)) { \
  126. +        dprintf_out("\t" #s "\n"); \
  127. +        win_mask &= ~(s); \
  128. +    }
  129. +    PRINTWINACCESSMASKBITS(GENERIC_READ);
  130. +    PRINTWINACCESSMASKBITS(GENERIC_WRITE);
  131. +    PRINTWINACCESSMASKBITS(GENERIC_EXECUTE);
  132. +    PRINTWINACCESSMASKBITS(GENERIC_ALL);
  133. +    PRINTWINACCESSMASKBITS(MAXIMUM_ALLOWED);
  134. +    PRINTWINACCESSMASKBITS(ACCESS_SYSTEM_SECURITY);
  135. +    PRINTWINACCESSMASKBITS(SPECIFIC_RIGHTS_ALL);
  136. +    PRINTWINACCESSMASKBITS(STANDARD_RIGHTS_ALL);
  137. +    PRINTWINACCESSMASKBITS(STANDARD_RIGHTS_REQUIRED);
  138. +    PRINTWINACCESSMASKBITS(SYNCHRONIZE);
  139. +    PRINTWINACCESSMASKBITS(WRITE_OWNER);
  140. +    PRINTWINACCESSMASKBITS(WRITE_DAC);
  141. +    PRINTWINACCESSMASKBITS(READ_CONTROL);
  142. +    PRINTWINACCESSMASKBITS(DELETE);
  143. +    PRINTWINACCESSMASKBITS(FILE_READ_DATA);
  144. +    PRINTWINACCESSMASKBITS(FILE_LIST_DIRECTORY);
  145. +    PRINTWINACCESSMASKBITS(FILE_WRITE_DATA);
  146. +    PRINTWINACCESSMASKBITS(FILE_ADD_FILE);
  147. +    PRINTWINACCESSMASKBITS(FILE_APPEND_DATA);
  148. +    PRINTWINACCESSMASKBITS(FILE_ADD_SUBDIRECTORY);
  149. +    PRINTWINACCESSMASKBITS(FILE_CREATE_PIPE_INSTANCE);
  150. +    PRINTWINACCESSMASKBITS(FILE_READ_EA);
  151. +    PRINTWINACCESSMASKBITS(FILE_WRITE_EA);
  152. +    PRINTWINACCESSMASKBITS(FILE_EXECUTE);
  153. +    PRINTWINACCESSMASKBITS(FILE_TRAVERSE);
  154. +    PRINTWINACCESSMASKBITS(FILE_DELETE_CHILD);
  155. +    PRINTWINACCESSMASKBITS(FILE_READ_ATTRIBUTES);
  156. +    PRINTWINACCESSMASKBITS(FILE_WRITE_ATTRIBUTES);
  157. +    PRINTWINACCESSMASKBITS(FILE_ALL_ACCESS);
  158. +    PRINTWINACCESSMASKBITS(FILE_GENERIC_READ);
  159. +    PRINTWINACCESSMASKBITS(FILE_GENERIC_WRITE);
  160. +    PRINTWINACCESSMASKBITS(FILE_GENERIC_EXECUTE);
  161. +
  162. +    /* Print any "leftover" bits */
  163. +    if (win_mask) {
  164. +        dprintf_out("\t0x%lx\n", (long)win_mask);
  165. +    }
  166. +    dprintf_out("<-- print_windows_access_mask\n");
  167.  }
  168.  
  169. -void print_nfs_access_mask(int on, int m)
  170. +void print_nfs_access_mask(uint32_t nfs_mask)
  171.  {
  172. -    if (!on) return;
  173. -    if (!DPRINTF_LEVEL_ENABLED(1))
  174. -        return;
  175. -
  176. -    dprintf_out("--> print_nfs_access_mask: %x\n", m);
  177. -    if (m & ACE4_READ_DATA)
  178. -        dprintf_out("\tACE4_READ_DATA\n");
  179. -    if (m & ACE4_LIST_DIRECTORY)
  180. -        dprintf_out("\tACE4_LIST_DIRECTORY\n");
  181. -    if (m & ACE4_WRITE_DATA)
  182. -        dprintf_out("\tACE4_WRITE_DATA\n");
  183. -    if (m & ACE4_ADD_FILE)
  184. -        dprintf_out("\tACE4_ADD_FILE\n");
  185. -    if (m & ACE4_APPEND_DATA)
  186. -        dprintf_out("\tACE4_APPEND_DATA\n");
  187. -    if (m & ACE4_ADD_SUBDIRECTORY)
  188. -        dprintf_out("\tACE4_ADD_SUBDIRECTORY\n");
  189. -    if (m & ACE4_READ_NAMED_ATTRS)
  190. -        dprintf_out("\tACE4_READ_NAMED_ATTRS\n");
  191. -    if (m & ACE4_WRITE_NAMED_ATTRS)
  192. -        dprintf_out("\tACE4_WRITE_NAMED_ATTRS\n");
  193. -    if (m & ACE4_EXECUTE)
  194. -        dprintf_out("\tACE4_EXECUTE\n");
  195. -    if (m & ACE4_DELETE_CHILD)
  196. -        dprintf_out("\tACE4_DELETE_CHILD\n");
  197. -    if (m & ACE4_READ_ATTRIBUTES)
  198. -        dprintf_out("\tACE4_READ_ATTRIBUTES\n");
  199. -    if (m & ACE4_WRITE_ATTRIBUTES)
  200. -        dprintf_out("\tACE4_WRITE_ATTRIBUTES\n");
  201. -    if (m & ACE4_DELETE)
  202. -        dprintf_out("\tACE4_DELETE\n");
  203. -    if (m & ACE4_READ_ACL)
  204. -        dprintf_out("\tACE4_READ_ACL\n");
  205. -    if (m & ACE4_WRITE_ACL)
  206. -        dprintf_out("\tACE4_WRITE_ACL\n");
  207. -    if (m & ACE4_WRITE_OWNER)
  208. -        dprintf_out("\tACE4_WRITE_OWNER\n");
  209. -    if (m & ACE4_SYNCHRONIZE)
  210. -        dprintf_out("\tACE4_SYNCHRONIZE\n");
  211. +    dprintf_out("--> print_nfs_access_mask: 0x%lx\n", (long)nfs_mask);
  212. +#define PRINTNFSMASKBITS(s) \
  213. +    if ((nfs_mask & (s)) == (s)) { \
  214. +        dprintf_out("\t" #s "\n"); \
  215. +        nfs_mask &= ~(s); \
  216. +    }
  217. +    PRINTNFSMASKBITS(ACE4_READ_DATA);
  218. +    PRINTNFSMASKBITS(ACE4_LIST_DIRECTORY);
  219. +    PRINTNFSMASKBITS(ACE4_WRITE_DATA);
  220. +    PRINTNFSMASKBITS(ACE4_ADD_FILE);
  221. +    PRINTNFSMASKBITS(ACE4_APPEND_DATA);
  222. +    PRINTNFSMASKBITS(ACE4_ADD_SUBDIRECTORY);
  223. +    PRINTNFSMASKBITS(ACE4_READ_NAMED_ATTRS);
  224. +    PRINTNFSMASKBITS(ACE4_WRITE_NAMED_ATTRS);
  225. +    PRINTNFSMASKBITS(ACE4_EXECUTE);
  226. +    PRINTNFSMASKBITS(ACE4_DELETE_CHILD);
  227. +    PRINTNFSMASKBITS(ACE4_READ_ATTRIBUTES);
  228. +    PRINTNFSMASKBITS(ACE4_WRITE_ATTRIBUTES);
  229. +    PRINTNFSMASKBITS(ACE4_DELETE);
  230. +    PRINTNFSMASKBITS(ACE4_READ_ACL);
  231. +    PRINTNFSMASKBITS(ACE4_WRITE_ACL);
  232. +    PRINTNFSMASKBITS(ACE4_WRITE_OWNER);
  233. +    PRINTNFSMASKBITS(ACE4_SYNCHRONIZE);
  234. +    PRINTNFSMASKBITS(ACE4_ALL_FILE);
  235. +    PRINTNFSMASKBITS(ACE4_ALL_DIR);
  236. +    PRINTNFSMASKBITS(ACE4_GENERIC_READ);
  237. +    PRINTNFSMASKBITS(ACE4_GENERIC_WRITE);
  238. +    PRINTNFSMASKBITS(ACE4_GENERIC_EXECUTE);
  239. +    PRINTNFSMASKBITS(ACE4_FILE_ALL_ACCESS);
  240. +
  241. +    /* Print any "leftover" bits */
  242. +    if (nfs_mask) {
  243. +        dprintf_out("\t0x%lx\n", (long)nfs_mask);
  244. +    }
  245. +    dprintf_out("<-- print_nfs_access_mask\n");
  246.  }
  247.  
  248.  
  249. diff --git a/daemon/daemon_debug.h b/daemon/daemon_debug.h
  250. index 8f0c166..a1a22a2 100644
  251. --- a/daemon/daemon_debug.h
  252. +++ b/daemon/daemon_debug.h
  253. @@ -31,6 +31,7 @@
  254.  #else
  255.  # include <stdlib.h>
  256.  #endif
  257. +#include <stdint.h>
  258.  #include <stdbool.h>
  259.  
  260.  #define DEFAULT_DEBUG_LEVEL 1
  261. @@ -103,8 +104,8 @@ void dprintf_out(LPCSTR format, ...);
  262.  void eprintf_out(LPCSTR format, ...);
  263.  void eprintf(LPCSTR format, ...);
  264.  
  265. -void print_windows_access_mask(int on, ACCESS_MASK m);
  266. -void print_nfs_access_mask(int on, int m);
  267. +void print_windows_access_mask(ACCESS_MASK win_mask);
  268. +void print_nfs_access_mask(uint32_t nfs_mask);
  269.  void print_hexbuf_no_asci(const char *title, const unsigned char *buf, int len);
  270.  void print_hexbuf(const char *title, const unsigned char *buf, int len);
  271.  void print_create_attributes(int level, DWORD create_opts);
  272. --
  273. 2.45.1
  274.  
  275. From f5b1aa0d0f150c23874a5a3e4a7d8a8ed5718454 Mon Sep 17 00:00:00 2001
  276. From: Roland Mainz <roland.mainz@nrubsig.org>
  277. Date: Mon, 17 Jun 2024 13:47:06 +0200
  278. Subject: [PATCH 2/8] daemon: Add debug |map_nfs_ftype2str()| function
  279.  
  280. Add debug |map_nfs_ftype2str()| function
  281.  
  282. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  283. ---
  284. daemon/acl.c          |  9 +++++----
  285.  daemon/daemon_debug.c | 18 ++++++++++++++++++
  286.  daemon/daemon_debug.h |  1 +
  287.  3 files changed, 24 insertions(+), 4 deletions(-)
  288.  
  289. diff --git a/daemon/acl.c b/daemon/acl.c
  290. index 6f6512e..83bfd3b 100644
  291. --- a/daemon/acl.c
  292. +++ b/daemon/acl.c
  293. @@ -111,8 +111,8 @@ static int convert_nfs4acl_2_dacl(nfs41_daemon_globals *nfs41dg,
  294.      LPSTR domain = NULL;
  295.      BOOLEAN flag;
  296.  
  297. -    DPRINTF(ACLLVL, ("--> convert_nfs4acl_2_dacl(acl=0x%p,file_type=%d)\n",
  298. -        acl, file_type));
  299. +    DPRINTF(ACLLVL, ("--> convert_nfs4acl_2_dacl(acl=0x%p,file_type='%s'(=%d))\n",
  300. +        acl, map_nfs_ftype2str(file_type), file_type));
  301.  
  302.      sids = malloc(acl->count * sizeof(PSID));
  303.      if (sids == NULL) {
  304. @@ -210,8 +210,9 @@ static int convert_nfs4acl_2_dacl(nfs41_daemon_globals *nfs41dg,
  305.      *sids_out = sids;
  306.      *dacl_out = dacl;
  307.  out:
  308. -    DPRINTF(ACLLVL, ("<-- convert_nfs4acl_2_dacl(acl=0x%p,file_type=%d) returning %d\n",
  309. -        acl, file_type, status));
  310. +    DPRINTF(ACLLVL, ("<-- convert_nfs4acl_2_dacl("
  311. +        "acl=0x%p,file_type='%s'(=%d)) returning %d\n",
  312. +        acl, map_nfs_ftype2str(file_type), file_type, status));
  313.      return status;
  314.  out_free_dacl:
  315.      free(dacl);
  316. diff --git a/daemon/daemon_debug.c b/daemon/daemon_debug.c
  317. index 2da8256..dcf2f4d 100644
  318. --- a/daemon/daemon_debug.c
  319. +++ b/daemon/daemon_debug.c
  320. @@ -801,6 +801,24 @@ const char* secflavorop2name(DWORD sec_flavor)
  321.      return "<Unknown RPCSEC_AUTH* flavour>";
  322.  }
  323.  
  324. +const char *map_nfs_ftype2str(int ftype)
  325. +{
  326. +    switch(ftype) {
  327. +#define NFSTYPE2STRLITERAL(e) case e: return #e;
  328. +        NFSTYPE2STRLITERAL(NF4REG)
  329. +        NFSTYPE2STRLITERAL(NF4DIR)
  330. +        NFSTYPE2STRLITERAL(NF4BLK)
  331. +        NFSTYPE2STRLITERAL(NF4CHR)
  332. +        NFSTYPE2STRLITERAL(NF4LNK)
  333. +        NFSTYPE2STRLITERAL(NF4SOCK)
  334. +        NFSTYPE2STRLITERAL(NF4FIFO)
  335. +        NFSTYPE2STRLITERAL(NF4ATTRDIR)
  336. +        NFSTYPE2STRLITERAL(NF4NAMEDATTR)
  337. +    }
  338. +
  339. +    return "<Unknown nfs_ftype4 type>";
  340. +}
  341. +
  342.  void print_windows_access_mask(ACCESS_MASK win_mask)
  343.  {
  344.      dprintf_out("--> print_windows_access_mask: 0x%lx\n", (long)win_mask);
  345. diff --git a/daemon/daemon_debug.h b/daemon/daemon_debug.h
  346. index a1a22a2..78e5925 100644
  347. --- a/daemon/daemon_debug.h
  348. +++ b/daemon/daemon_debug.h
  349. @@ -104,6 +104,7 @@ void dprintf_out(LPCSTR format, ...);
  350.  void eprintf_out(LPCSTR format, ...);
  351.  void eprintf(LPCSTR format, ...);
  352.  
  353. +const char *map_nfs_ftype2str(int ftype);
  354.  void print_windows_access_mask(ACCESS_MASK win_mask);
  355.  void print_nfs_access_mask(uint32_t nfs_mask);
  356.  void print_hexbuf_no_asci(const char *title, const unsigned char *buf, int len);
  357. --
  358. 2.45.1
  359.  
  360. From d4dda3d20b3149704338fe77d4ec3e946939078f Mon Sep 17 00:00:00 2001
  361. From: Roland Mainz <roland.mainz@nrubsig.org>
  362. Date: Mon, 17 Jun 2024 13:59:21 +0200
  363. Subject: [PATCH 3/8] daemon: Add missing brackets in |ACE_*| macros
  364.  
  365. Add missing brackets in |ACE_*| macros
  366.  
  367. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  368. ---
  369. daemon/nfs41_const.h | 39 ++++++++++++++++++++++-----------------
  370.  1 file changed, 22 insertions(+), 17 deletions(-)
  371.  
  372. diff --git a/daemon/nfs41_const.h b/daemon/nfs41_const.h
  373. index 5010816..48a108d 100644
  374. --- a/daemon/nfs41_const.h
  375. +++ b/daemon/nfs41_const.h
  376. @@ -373,30 +373,35 @@ enum nfs_ftype4 {
  377.  #define ACE4_WRITE_OWNER          0x00080000
  378.  #define ACE4_SYNCHRONIZE          0x00100000
  379.  
  380. -#define ACE4_ALL_FILE ACE4_READ_DATA|ACE4_WRITE_DATA|ACE4_APPEND_DATA| \
  381. +#define ACE4_ALL_FILE \
  382. +        (ACE4_READ_DATA|ACE4_WRITE_DATA|ACE4_APPEND_DATA| \
  383.          ACE4_READ_NAMED_ATTRS|ACE4_WRITE_NAMED_ATTRS|ACE4_EXECUTE| \
  384.          ACE4_READ_ATTRIBUTES|ACE4_WRITE_ATTRIBUTES| \
  385.          ACE4_DELETE|ACE4_READ_ACL|ACE4_WRITE_ACL|ACE4_WRITE_OWNER| \
  386. -        ACE4_SYNCHRONIZE
  387. -#define ACE4_ALL_DIR ACE4_READ_DATA|ACE4_WRITE_DATA|ACE4_APPEND_DATA| \
  388. +        ACE4_SYNCHRONIZE)
  389. +#define ACE4_ALL_DIR \
  390. +        (ACE4_READ_DATA|ACE4_WRITE_DATA|ACE4_APPEND_DATA| \
  391.          ACE4_READ_NAMED_ATTRS|ACE4_WRITE_NAMED_ATTRS|ACE4_EXECUTE| \
  392.          ACE4_DELETE_CHILD|ACE4_READ_ATTRIBUTES|ACE4_WRITE_ATTRIBUTES| \
  393.          ACE4_DELETE|ACE4_READ_ACL|ACE4_WRITE_ACL|ACE4_WRITE_OWNER| \
  394. -        ACE4_SYNCHRONIZE
  395. -
  396. -#define ACE4_GENERIC_READ ACE4_READ_DATA|ACE4_READ_NAMED_ATTRS| \
  397. -        ACE4_READ_ATTRIBUTES|ACE4_READ_ACL|ACE4_SYNCHRONIZE
  398. -#define ACE4_GENERIC_WRITE ACE4_WRITE_DATA|ACE4_WRITE_NAMED_ATTRS| \
  399. -        ACE4_WRITE_ATTRIBUTES|ACE4_READ_ACL|ACE4_SYNCHRONIZE
  400. -#define ACE4_GENERIC_EXECUTE ACE4_EXECUTE|ACE4_READ_ATTRIBUTES| \
  401. -        ACE4_READ_ACL|ACE4_SYNCHRONIZE
  402. -        
  403. -
  404. -
  405. -#define ACE4_FILE_ALL_ACCESS ACE4_READ_DATA|ACE4_LIST_DIRECTORY| \
  406. -        ACE4_WRITE_DATA|ACE4_ADD_FILE|ACE4_APPEND_DATA|ACE4_ADD_SUBDIRECTORY| \
  407. +        ACE4_SYNCHRONIZE)
  408. +
  409. +#define ACE4_GENERIC_READ \
  410. +        (ACE4_READ_DATA|ACE4_READ_NAMED_ATTRS| \
  411. +        ACE4_READ_ATTRIBUTES|ACE4_READ_ACL|ACE4_SYNCHRONIZE)
  412. +#define ACE4_GENERIC_WRITE \
  413. +        (ACE4_WRITE_DATA|ACE4_WRITE_NAMED_ATTRS| \
  414. +        ACE4_WRITE_ATTRIBUTES|ACE4_READ_ACL|ACE4_SYNCHRONIZE)
  415. +#define ACE4_GENERIC_EXECUTE \
  416. +        (ACE4_EXECUTE|ACE4_READ_ATTRIBUTES| \
  417. +        ACE4_READ_ACL|ACE4_SYNCHRONIZE)
  418. +
  419. +#define ACE4_FILE_ALL_ACCESS \
  420. +        (ACE4_READ_DATA|ACE4_LIST_DIRECTORY| \
  421. +        ACE4_WRITE_DATA|ACE4_ADD_FILE|ACE4_APPEND_DATA| \
  422. +        ACE4_ADD_SUBDIRECTORY| \
  423.          ACE4_READ_NAMED_ATTRS|ACE4_WRITE_NAMED_ATTRS|ACE4_EXECUTE| \
  424. -        ACE4_READ_ATTRIBUTES|ACE4_WRITE_ATTRIBUTES
  425. +        ACE4_READ_ATTRIBUTES|ACE4_WRITE_ATTRIBUTES)
  426.  
  427.  /* ACLS aceflag4 field constants */
  428.  #define ACE4_FILE_INHERIT_ACE             0x00000001
  429. --
  430. 2.45.1
  431.  
  432. From 85600e90f322cd91f203490468ab5516536e106d Mon Sep 17 00:00:00 2001
  433. From: Roland Mainz <roland.mainz@nrubsig.org>
  434. Date: Mon, 17 Jun 2024 14:06:40 +0200
  435. Subject: [PATCH 4/8] daemon: Rework
  436.  |print_nfs_access_mask()|+|print_windows_access_mask()| [refix]
  437.  
  438. Refix, set correct debug level
  439.  
  440. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  441. ---
  442. daemon/acl.c | 4 ++--
  443.  1 file changed, 2 insertions(+), 2 deletions(-)
  444.  
  445. diff --git a/daemon/acl.c b/daemon/acl.c
  446. index 83bfd3b..0aff8d2 100644
  447. --- a/daemon/acl.c
  448. +++ b/daemon/acl.c
  449. @@ -529,7 +529,7 @@ static void map_winaccessmask2nfs4acemask(ACCESS_MASK mask, int file_type, uint3
  450.      DPRINTF(ACLLVL,
  451.          ("--> map_winaccessmask2nfs4acemask(mask=0x%x)\n",
  452.          (int)mask));
  453. -    if (DPRINTF_LEVEL_ENABLED(0)) {
  454. +    if (DPRINTF_LEVEL_ENABLED(ACLLVL)) {
  455.          print_windows_access_mask(mask);
  456.      }
  457.      /* check if any GENERIC bits set */
  458. @@ -550,7 +550,7 @@ static void map_winaccessmask2nfs4acemask(ACCESS_MASK mask, int file_type, uint3
  459.      }
  460.      else /* ignoring generic and reserved bits */
  461.          *nfs4_mask = mask & 0x00ffffff;
  462. -    if (DPRINTF_LEVEL_ENABLED(0)) {
  463. +    if (DPRINTF_LEVEL_ENABLED(ACLLVL)) {
  464.          print_nfs_access_mask(*nfs4_mask);
  465.      }
  466.      DPRINTF(ACLLVL,
  467. --
  468. 2.45.1
  469.  
  470. From bb3b1865ab0d4f8fd968ea6988e5adfdd503d07b Mon Sep 17 00:00:00 2001
  471. From: Roland Mainz <roland.mainz@nrubsig.org>
  472. Date: Mon, 17 Jun 2024 17:22:57 +0200
  473. Subject: [PATCH 5/8] sys,mount,nfs41_build_features.h: Add new "createmode="
  474.  mount option
  475.  
  476. Add new "createmode=" mount option to set the default POSIX
  477. permission mode for new files created on the NFS share (similar
  478. to the "fileaccess=" mount option in Microsofts NFSv3 driver).
  479.  
  480. This default mode value can be overridden by a "NfsV3Attributes" EA
  481. (e.g. like Cygwin uses), if the value for the "createmode" option
  482. was prefixed with "nfsv3attrmode+", e.g.
  483. "createmode=nfsv3attrmode+0o777".
  484.  
  485. The default value for this option is "nfsv3attrmode+0o755", the
  486. default mode can be defined at build time via the
  487. |NFS41_DRIVER_DEFAULT_CREATE_MODE| build option in
  488. "nfs41_build_features.h".
  489.  
  490. Note this changes the default mode from "0777" to "0755".
  491.  
  492. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  493. ---
  494. mount/mount.c          |  10 +++-
  495.  nfs41_build_features.h |   6 ++
  496.  sys/nfs41_driver.c     | 130 +++++++++++++++++++++++++++++++++++++----
  497.  3 files changed, 134 insertions(+), 12 deletions(-)
  498.  
  499. diff --git a/mount/mount.c b/mount/mount.c
  500. index 3c07cd5..2dffc91 100644
  501. --- a/mount/mount.c
  502. +++ b/mount/mount.c
  503. @@ -93,7 +93,13 @@ static VOID PrintUsage(LPTSTR pProcess)
  504.          TEXT("\tnowritethru\tturns on rdbss caching for writes (default)\n")
  505.          TEXT("\tcache\tturns on rdbss caching (default)\n")
  506.          TEXT("\tnocache\tturns off rdbss caching\n")
  507. -        TEXT("\ttimeout=#\tspecify upcall timeout value in seconds (default 120s)\n")
  508. +        TEXT("\twsize=#\twrite buffer size in bytes\n")
  509. +        TEXT("\tcreatemode=\tspecify default POSIX permission mode\n"
  510. +            "\t\tfor new files created on the NFS share.\n"
  511. +            "\t\tArgument is an octal value prefixed with '0o',\n"
  512. +            "\t\tif this value is prefixed with 'nfsv3attrmode+'\n"
  513. +            "\t\tthe mode value from a \"NfsV3Attributes\" EA will be used\n"
  514. +            "\t\t(defaults \"nfsv3attrmode+0o%o\").\n")
  515.          TEXT("* Hostname:\n")
  516.          TEXT("\tDNS name, or hostname in domain\n")
  517.          TEXT("\tentry in C:\\Windows\\System32\\drivers\\etc\\hosts\n")
  518. @@ -111,7 +117,7 @@ static VOID PrintUsage(LPTSTR pProcess)
  519.          TEXT("\tnfs_mount.exe -o sec=sys,rw '*' nfs://[fe80::21b:1bff:fec3:7713]//net_tmpfs2/test2\n")
  520.          TEXT("\tnfs_mount.exe -o sec=sys,rw S nfs://myhost1//dirwithspace/dir%%20space/test2\n")
  521.          TEXT("\tnfs_mount.exe -o sec=sys,rw S nfs://myhost1//dirwithspace/dir+space/test2\n"),
  522. -        pProcess);
  523. +        pProcess, (int)NFS41_DRIVER_DEFAULT_CREATE_MODE);
  524.  }
  525.  
  526.  DWORD __cdecl _tmain(DWORD argc, LPTSTR argv[])
  527. diff --git a/nfs41_build_features.h b/nfs41_build_features.h
  528. index 697f4d5..7ca7b45 100644
  529. --- a/nfs41_build_features.h
  530. +++ b/nfs41_build_features.h
  531. @@ -117,4 +117,10 @@
  532.   */
  533.  #define NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE 1
  534.  
  535. +/*
  536. + * Default POSIX permission mode bits for new files
  537. + * Can be ovrriden with a "NfsV3Attributes" EA
  538. + */
  539. +#define NFS41_DRIVER_DEFAULT_CREATE_MODE (0755)
  540. +
  541.  #endif /* !_NFS41_DRIVER_BUILDFEATURES_ */
  542. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  543. index 58a312c..ca3c813 100644
  544. --- a/sys/nfs41_driver.c
  545. +++ b/sys/nfs41_driver.c
  546. @@ -44,6 +44,7 @@
  547.  /* debugging printout defines */
  548.  #define DEBUG_MARSHAL_HEADER
  549.  #define DEBUG_MARSHAL_DETAIL
  550. +#define DEBUG_MOUNTCONFIG
  551.  //#define DEBUG_OPEN
  552.  //#define DEBUG_CLOSE
  553.  //#define DEBUG_CACHE
  554. @@ -304,6 +305,10 @@ typedef struct _NFS41_MOUNT_CONFIG {
  555.      WCHAR sec_flavor_buffer[MAX_SEC_FLAVOR_LEN];
  556.      UNICODE_STRING SecFlavor;
  557.      DWORD timeout;
  558. +    struct {
  559. +        BOOLEAN use_nfsv3attrsea_mode;
  560. +        DWORD mode;
  561. +    } createmode;
  562.  } NFS41_MOUNT_CONFIG, *PNFS41_MOUNT_CONFIG;
  563.  
  564.  typedef struct _nfs41_mount_entry {
  565. @@ -387,6 +392,10 @@ typedef struct _NFS41_V_NET_ROOT_EXTENSION {
  566.      FILE_FS_ATTRIBUTE_INFORMATION FsAttrs;
  567.      DWORD                   sec_flavor;
  568.      DWORD                   timeout;
  569. +    struct {
  570. +        BOOLEAN use_nfsv3attrsea_mode;
  571. +        DWORD mode;
  572. +    } createmode;
  573.      USHORT                  MountPathLen;
  574.      BOOLEAN                 read_only;
  575.      BOOLEAN                 write_thru;
  576. @@ -2842,6 +2851,8 @@ void nfs41_MountConfig_InitDefaults(
  577.      Config->SecFlavor.Buffer = Config->sec_flavor_buffer;
  578.      RtlCopyUnicodeString(&Config->SecFlavor, &AUTH_SYS_NAME);
  579.      Config->timeout = UPCALL_TIMEOUT_DEFAULT;
  580. +    Config->createmode.use_nfsv3attrsea_mode = TRUE;
  581. +    Config->createmode.mode = NFS41_DRIVER_DEFAULT_CREATE_MODE;
  582.  }
  583.  
  584.  NTSTATUS nfs41_MountConfig_ParseBoolean(
  585. @@ -3001,6 +3012,71 @@ NTSTATUS nfs41_MountConfig_ParseOptions(
  586.              else
  587.                  RtlCopyUnicodeString(&Config->SecFlavor, &usValue);
  588.          }
  589. +        else if (wcsncmp(L"createmode", Name, NameLen) == 0) {
  590. +#define NFSV3ATTRMODE_WSTR L"nfsv3attrmode+"
  591. +#define NFSV3ATTRMODE_WCSLEN (14)
  592. +#define NFSV3ATTRMODE_BYTELEN (NFSV3ATTRMODE_WCSLEN*sizeof(WCHAR))
  593. +            if ((usValue.Length >= NFSV3ATTRMODE_BYTELEN) &&
  594. +                (!wcsncmp(NFSV3ATTRMODE_WSTR,
  595. +                    usValue.Buffer,
  596. +                    min(NFSV3ATTRMODE_WCSLEN,
  597. +                        usValue.Length/sizeof(WCHAR))))) {
  598. +                usValue.Buffer += NFSV3ATTRMODE_WCSLEN;
  599. +                usValue.Length = usValue.MaximumLength =
  600. +                    usValue.Length - NFSV3ATTRMODE_BYTELEN;
  601. +#ifdef DEBUG_MOUNTCONFIG
  602. +                DbgP("nfs41_MountConfig_ParseOptions: createmode "
  603. +                    "nfs4attr "
  604. +                    "leftover option/usValue='%wZ'/%ld\n",
  605. +                    &usValue, (long)usValue.Length);
  606. +#endif /* DEBUG_MOUNTCONFIG */
  607. +
  608. +                Config->createmode.use_nfsv3attrsea_mode = TRUE;
  609. +            }
  610. +            else {
  611. +#ifdef DEBUG_MOUNTCONFIG
  612. +                DbgP("nfs41_MountConfig_ParseOptions: createmode "
  613. +                    "leftover option/usValue='%wZ'/%ld\n",
  614. +                    &usValue, (long)usValue.Length);
  615. +#endif /* DEBUG_MOUNTCONFIG */
  616. +                Config->createmode.use_nfsv3attrsea_mode = FALSE;
  617. +            }
  618. +
  619. +            /*
  620. +             * Reject mode values not prefixed with "0o", as
  621. +             * |RtlUnicodeStringToInteger()| uses
  622. +             * 0o (e.g. "0o123") as prefix for octal values,
  623. +             * and does not understand the traditional
  624. +             * UNIX/POSIX/ISO C "0" (e.g. "0123") prefix
  625. +             */
  626. +            if ((usValue.Length >= (3*sizeof(WCHAR))) &&
  627. +                (usValue.Buffer[0] == L'0') &&
  628. +                (usValue.Buffer[1] == L'o')) {
  629. +                status = nfs41_MountConfig_ParseDword(Option,
  630. +                    &usValue,
  631. +                    &Config->createmode.mode, 0,
  632. +                    0777);
  633. +                if (status == STATUS_SUCCESS) {
  634. +                    if (Config->createmode.mode > 0777) {
  635. +                        status = STATUS_INVALID_PARAMETER;
  636. +                        print_error("mode 0o%o out of bounds\n",
  637. +                            (int)Config->createmode.mode);
  638. +                    }
  639. +                }
  640. +            }
  641. +            else {
  642. +                status = STATUS_INVALID_PARAMETER;
  643. +                print_error("Invalid createmode '%wZ'\n",
  644. +                    usValue);
  645. +            }
  646. +
  647. +            DbgP("nfs41_MountConfig_ParseOptions: createmode: "
  648. +                "status=0x%lx, "
  649. +                "createmode=(use_nfsv3attrsea_mode=%d, mode=0o%o\n",
  650. +                (long)status,
  651. +                (int)Config->createmode.use_nfsv3attrsea_mode,
  652. +                (int)Config->createmode.mode);
  653. +        }
  654.          else {
  655.              status = STATUS_INVALID_PARAMETER;
  656.              print_error("Unrecognized option '%ls' -> '%wZ'\n",
  657. @@ -3015,7 +3091,7 @@ NTSTATUS nfs41_MountConfig_ParseOptions(
  658.      }
  659.  
  660.  out:
  661. -    DbgP("<-- nfs41_MountConfig_ParseOptions, status=%ld\n", (long)status);
  662. +    DbgP("<-- nfs41_MountConfig_ParseOptions, status=0x%lx\n", (long)status);
  663.      return status;
  664.  }
  665.  
  666. @@ -3288,15 +3364,31 @@ NTSTATUS nfs41_CreateVNetRoot(
  667.          pVNetRootContext->nocache = Config->nocache;
  668.      }
  669.  
  670. -    DbgP("Config->{ MntPt='%wZ', SrvName='%wZ', ReadOnly=%d, write_thru=%d, nocache=%d }\n",
  671. +    DbgP("Config->{ "
  672. +        "MntPt='%wZ', "
  673. +        "SrvName='%wZ', "
  674. +        "ReadOnly=%d, "
  675. +        "write_thru=%d, "
  676. +        "nocache=%d "
  677. +        "timeout=%d "
  678. +        "createmode.use_nfsv3attrsea_mode=%d "
  679. +        "Config->createmode.mode=0o%o "
  680. +        "}\n",
  681.          &Config->MntPt,
  682.          &Config->SrvName,
  683.          Config->ReadOnly?1:0,
  684.          Config->write_thru?1:0,
  685. -        Config->nocache?1:0);
  686. +        Config->nocache?1:0,
  687. +        Config->timeout,
  688. +        Config->createmode.use_nfsv3attrsea_mode?1:0,
  689. +        Config->createmode.mode);
  690.  
  691.      pVNetRootContext->MountPathLen = Config->MntPt.Length;
  692.      pVNetRootContext->timeout = Config->timeout;
  693. +    pVNetRootContext->createmode.use_nfsv3attrsea_mode =
  694. +        Config->createmode.use_nfsv3attrsea_mode;
  695. +    pVNetRootContext->createmode.mode =
  696. +        Config->createmode.mode;
  697.  
  698.      status = map_sec_flavor(&Config->SecFlavor, &pVNetRootContext->sec_flavor);
  699.      if (status != STATUS_SUCCESS) {
  700. @@ -3949,16 +4041,34 @@ NTSTATUS nfs41_Create(
  701.          entry->u.Open.open_owner_id = InterlockedIncrement(&open_owner_id);
  702.      // if we are creating a file check if nfsv3attributes were passed in
  703.      if (params->Disposition != FILE_OPEN && params->Disposition != FILE_OVERWRITE) {
  704. -        entry->u.Open.mode = 0777;
  705. -        if (ea && AnsiStrEq(&NfsV3Attributes, ea->EaName, ea->EaNameLength)) {
  706. -            nfs3_attrs *attrs = (nfs3_attrs *)(ea->EaName + ea->EaNameLength + 1);
  707. +        /* Get default mode */
  708. +        entry->u.Open.mode = pVNetRootContext->createmode.mode;
  709. +
  710. +        /* Use mode from NfsV3Attributes */
  711. +        if (pVNetRootContext->createmode.use_nfsv3attrsea_mode &&
  712. +            ea && AnsiStrEq(&NfsV3Attributes,
  713. +            ea->EaName, ea->EaNameLength)) {
  714. +            nfs3_attrs *attrs =
  715. +                (nfs3_attrs *)(ea->EaName + ea->EaNameLength + 1);
  716. +
  717. +            entry->u.Open.mode = attrs->mode;
  718.  #ifdef DEBUG_OPEN
  719. -            DbgP("creating file with mode 0%o\n", attrs->mode);
  720. +            DbgP("creating file with EA mode 0%o\n",
  721. +                entry->u.Open.mode);
  722.  #endif
  723. -            entry->u.Open.mode = attrs->mode;
  724.          }
  725. -        if (params->FileAttributes & FILE_ATTRIBUTE_READONLY)
  726. -            entry->u.Open.mode = 0444;
  727. +        else {
  728. +#ifdef DEBUG_OPEN
  729. +            DbgP("creating file with default mode 0%o\n",
  730. +                entry->u.Open.mode);
  731. +#endif
  732. +        }
  733. +
  734. +        if (params->FileAttributes & FILE_ATTRIBUTE_READONLY) {
  735. +            entry->u.Open.mode &= ~0222;
  736. +            DbgP("FILE_ATTRIBUTE_READONLY set, using mode 0%o\n",
  737. +                entry->u.Open.mode);
  738. +        }
  739.      }
  740.      if (entry->u.Open.disp == FILE_CREATE && ea &&
  741.              AnsiStrEq(&NfsSymlinkTargetName, ea->EaName, ea->EaNameLength)) {
  742. --
  743. 2.45.1
  744.  
  745. From 860311def30d30c3984a6bad41795ba2ce07dd4a Mon Sep 17 00:00:00 2001
  746. From: Roland Mainz <roland.mainz@nrubsig.org>
  747. Date: Mon, 17 Jun 2024 17:44:35 +0200
  748. Subject: [PATCH 6/8] sys: Debug: Use %lx for |NTSTATUS|
  749.  
  750. Use %lx for |NTSTATUS| when printing debug messages
  751.  
  752. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  753. ---
  754. sys/nfs41_driver.c | 46 +++++++++++++++++++++++++---------------------
  755.  1 file changed, 25 insertions(+), 21 deletions(-)
  756.  
  757. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  758. index ca3c813..6a237e4 100644
  759. --- a/sys/nfs41_driver.c
  760. +++ b/sys/nfs41_driver.c
  761. @@ -1649,7 +1649,7 @@ retry_wait:
  762.      case STATUS_USER_APC:
  763.      case STATUS_ALERTED:
  764.          DbgP("nfs41_UpcallWaitForReply: KeWaitForSingleObject() "
  765. -            "returned status(=%ld), "
  766. +            "returned status(=0x%lx), "
  767.              "retry waiting for '%s' entry=0x%p xid=%lld\n",
  768.              (long)status,
  769.              ENTRY_OPCODE2STRING(entry),
  770. @@ -1723,7 +1723,7 @@ retry_wait:
  771.              case STATUS_USER_APC:
  772.              case STATUS_ALERTED:
  773.                  DbgP("nfs41_upcall: KeWaitForSingleObject() "
  774. -                    "returned status(=%ld)"
  775. +                    "returned status(=0x%lx)"
  776.  #ifdef NFSV41_UPCALL_RETRY_WAIT
  777.                      ", retry waiting"
  778.  #endif /* NFSV41_UPCALL_RETRY_WAIT */
  779. @@ -1736,7 +1736,7 @@ retry_wait:
  780.  #endif /* NFSV41_UPCALL_RETRY_WAIT */
  781.              default:
  782.                  DbgP("nfs41_upcall: KeWaitForSingleObject() "
  783. -                    "returned UNEXPECTED status(=%ld)\n",
  784. +                    "returned UNEXPECTED status(=0x%lx)\n",
  785.                      (long)status);
  786.                  goto out;
  787.          }
  788. @@ -1760,8 +1760,10 @@ void unmarshal_nfs41_header(
  789.      RtlCopyMemory(&tmp->errno, *buf, sizeof(tmp->errno));
  790.      *buf += sizeof(tmp->errno);
  791.  #ifdef DEBUG_MARSHAL_HEADER
  792. -    DbgP("[downcall header] xid=%lld opcode='%s' status=0x%x errno=%d\n", tmp->xid,
  793. -        ENTRY_OPCODE2STRING(tmp), tmp->status, tmp->errno);
  794. +    DbgP("[downcall header] "
  795. +        "xid=%lld opcode='%s' status=0x%lx errno=%d\n",
  796. +        tmp->xid,
  797. +        ENTRY_OPCODE2STRING(tmp), (long)tmp->status, tmp->errno);
  798.  #endif
  799.  }
  800.  
  801. @@ -2921,9 +2923,9 @@ NTSTATUS nfs41_MountConfig_ParseOptions(
  802.  
  803.      status = IoCheckEaBufferValidity(EaBuffer, EaLength, &error_offset);
  804.      if (status) {
  805. -        DbgP("status(=0x%x)=IoCheckEaBufferValidity"
  806. +        DbgP("status(=0x%lx)=IoCheckEaBufferValidity"
  807.              "(eainfo=0x%p, buflen=%lu, &(error_offset=%d)) failed\n",
  808. -            (int)status, (void *)EaBuffer, EaLength,
  809. +            (long)status, (void *)EaBuffer, EaLength,
  810.              (int)error_offset);
  811.          goto out;
  812.      }
  813. @@ -3091,7 +3093,8 @@ NTSTATUS nfs41_MountConfig_ParseOptions(
  814.      }
  815.  
  816.  out:
  817. -    DbgP("<-- nfs41_MountConfig_ParseOptions, status=0x%lx\n", (long)status);
  818. +    DbgP("<-- nfs41_MountConfig_ParseOptions, status=0x%lx\n",
  819. +        (long)status);
  820.      return status;
  821.  }
  822.  
  823. @@ -5114,9 +5117,9 @@ NTSTATUS nfs41_SetEaInformation(
  824.          status = IoCheckEaBufferValidity(eainfo, buflen, &error_offset);
  825.          if (status) {
  826.              DbgP("nfs41_SetEaInformation: "
  827. -                "status(=0x%x)=IoCheckEaBufferValidity"
  828. +                "status(=0x%lx)=IoCheckEaBufferValidity"
  829.                  "(eainfo=0x%p, buflen=%lu, &(error_offset=%d))\n",
  830. -                (int)status, (void *)eainfo, buflen,
  831. +                (long)status, (void *)eainfo, buflen,
  832.                  (int)error_offset);
  833.              nfs41_UpcallDestroy(entry);
  834.              entry = NULL;
  835. @@ -5773,8 +5776,8 @@ NTSTATUS nfs41_QueryFileInformation(
  836.          pVNetRootContext->session, nfs41_fobx->nfs41_open_state,
  837.          pNetRootContext->nfs41d_version, SrvOpen->pAlreadyPrefixedName, &entry);
  838.      if (status) {
  839. -        print_error("nfs41_UpcallCreate() failed, status=0x%x\n",
  840. -            status);
  841. +        print_error("nfs41_UpcallCreate() failed, status=0x%lx\n",
  842. +            (long)status);
  843.          goto out;
  844.      }
  845.  
  846. @@ -5784,8 +5787,8 @@ NTSTATUS nfs41_QueryFileInformation(
  847.  
  848.      status = nfs41_UpcallWaitForReply(entry, pVNetRootContext->timeout);
  849.      if (status) {
  850. -        print_error("nfs41_UpcallWaitForReply() failed, status=0x%x\n",
  851. -            status);
  852. +        print_error("nfs41_UpcallWaitForReply() failed, status=0x%lx\n",
  853. +            (long)status);
  854.          goto out;
  855.      }
  856.  
  857. @@ -5855,7 +5858,8 @@ NTSTATUS nfs41_QueryFileInformation(
  858.          }
  859.      } else {
  860.          status = map_queryfile_error(entry->status);
  861. -        print_error("status(0x%lx) = map_queryfile_error(entry->status(0x%lx));\n", (long)status, (long)entry->status);
  862. +        print_error("status(0x%lx) = map_queryfile_error(entry->status(0x%lx));\n",
  863. +            (long)status, (long)entry->status);
  864.      }
  865.      nfs41_UpcallDestroy(entry);
  866.  out:
  867. @@ -7081,12 +7085,12 @@ NTSTATUS nfs41_FsCtl(
  868.      const char *fsctl_str = fsctl2string(fscontrolcode);
  869.  
  870.      if (fsctl_str) {
  871. -        DbgP("nfs41_FsCtl: FsControlCode='%s', status=0x%x\n",
  872. -            fsctl_str, (int)status);
  873. +        DbgP("nfs41_FsCtl: FsControlCode='%s', status=0x%lx\n",
  874. +            fsctl_str, (long)status);
  875.      }
  876.      else {
  877. -        DbgP("nfs41_FsCtl: FsControlCode=0x%lx, status=0x%x\n",
  878. -            (unsigned long)fscontrolcode, (int)status);
  879. +        DbgP("nfs41_FsCtl: FsControlCode=0x%lx, status=0x%lx\n",
  880. +            (unsigned long)fscontrolcode, (long)status);
  881.      }
  882.  #endif /* DEBUG_FSCTL */
  883.  
  884. @@ -7135,8 +7139,8 @@ NTSTATUS nfs41_FsdDispatch (
  885.  
  886.  out:
  887.  #ifdef DEBUG_FSDDISPATCH
  888. -    DbgP("IoStatus status = 0x%x info = 0x%x\n",
  889. -        Irp->IoStatus.Status,
  890. +    DbgP("IoStatus status = 0x%lx info = 0x%x\n",
  891. +        (long)Irp->IoStatus.Status,
  892.          Irp->IoStatus.Information);
  893.      DbgEx();
  894.  #endif
  895. --
  896. 2.45.1
  897.  
  898. From 07569b1489a9a390138808f1e146b606d2dabc81 Mon Sep 17 00:00:00 2001
  899. From: Roland Mainz <roland.mainz@nrubsig.org>
  900. Date: Mon, 17 Jun 2024 17:51:50 +0200
  901. Subject: [PATCH 7/8] cygwin,tests: Add workaround for $ svn checkout # failure
  902.  to README+tests
  903.  
  904. Add workaround for $ svn checkout # failure to the bintarball README
  905. and add this to the list of manual tests.
  906.  
  907. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  908. ---
  909. cygwin/README.bintarball.txt | 31 +++++++++++++++++++++++++++++
  910.  tests/manual_testing.txt     | 38 ++++++++++++++++++++++++++++++++++++
  911.  2 files changed, 69 insertions(+)
  912.  
  913. diff --git a/cygwin/README.bintarball.txt b/cygwin/README.bintarball.txt
  914. index 81e8ab3..5a366bc 100644
  915. --- a/cygwin/README.bintarball.txt
  916. +++ b/cygwin/README.bintarball.txt
  917. @@ -388,6 +388,37 @@ $ /sbin/nfs_mount
  918.  - Win10/32bit-only: $ net use H: /delete # does not work,
  919.    use $ nfs_mount -d 'H' instead #
  920.  
  921. +- Bug: Subversion checkout can fail with
  922. +  "sqlite[S11]: database disk image is malformed" like this:
  923. +  ---- snip ----
  924. +  $ svn checkout https://svn.FreeBSD.org/base/head/share/man
  925. +  A    man/man4
  926. +  A    man/man4/tcp.4
  927. +  A    man/man4/ndis.4
  928. +  A    man/man4/Makefile
  929. +  A    man/man4/altq.4
  930. +  A    man/man4/miibus.4
  931. +  A    man/man4/vlan.4
  932. +  A    man/man4/ng_macfilter.4
  933. +  A    man/man4/mn.4
  934. +  A    man/man4/ossl.4
  935. +  A    man/man4/ktls.4
  936. +  A    man/man4/ftwd.4
  937. +  A    man/man4/inet6.4
  938. +  A    man/man4/crypto.4
  939. +  A    man/man4/rtsx.4
  940. +  A    man/man4/isp.4
  941. +  svn: E200030: sqlite[S11]: database disk image is malformed
  942. +  svn: E200042: Additional errors:
  943. +  svn: E200030: sqlite[S11]: database disk image is malformed
  944. +  svn: E200030: sqlite[S11]: database disk image is malformed
  945. +  svn: E200030: sqlite[S11]: database disk image is malformed
  946. +  ---- snip ----
  947. +  Workaround is to mount the NFS filesystem with the "writethru"
  948. +  option, e.g.
  949. +  $ /sbin/nfs_mount -o rw,writethru 'j' derfwpc5131:/export/home/rmainz #
  950. +
  951. +
  952.  #
  953.  # 11. Notes for troubleshooting && finding bugs/debugging:
  954.  #
  955. diff --git a/tests/manual_testing.txt b/tests/manual_testing.txt
  956. index 7ce7c2f..3e1cfb1 100644
  957. --- a/tests/manual_testing.txt
  958. +++ b/tests/manual_testing.txt
  959. @@ -279,4 +279,42 @@ chmod a+rx setup-x86_64.exe
  960.  # check whether this will open the Cygwin installer window
  961.  ./setup-x86_64 --no-admin
  962.  
  963. +
  964. +#
  965. +# Subversion checkout:
  966. +#
  967. +# Currently fails like this:
  968. +# ---- snip ----
  969. +# $ svn checkout https://svn.FreeBSD.org/base/head/share/man
  970. +# A    man/man4
  971. +# A    man/man4/tcp.4
  972. +# A    man/man4/ndis.4
  973. +# A    man/man4/Makefile
  974. +# A    man/man4/altq.4
  975. +# A    man/man4/miibus.4
  976. +# A    man/man4/vlan.4
  977. +# A    man/man4/ng_macfilter.4
  978. +# A    man/man4/mn.4
  979. +# A    man/man4/ossl.4
  980. +# A    man/man4/ktls.4
  981. +# A    man/man4/ftwd.4
  982. +# A    man/man4/inet6.4
  983. +# A    man/man4/crypto.4
  984. +# A    man/man4/rtsx.4
  985. +# A    man/man4/isp.4
  986. +# svn: E200030: sqlite[S11]: database disk image is malformed
  987. +# svn: E200042: Additional errors:
  988. +# svn: E200030: sqlite[S11]: database disk image is malformed
  989. +# svn: E200030: sqlite[S11]: database disk image is malformed
  990. +# svn: E200030: sqlite[S11]: database disk image is malformed
  991. +# ---- snip ----
  992. +#
  993. +# Workaround is to mount the NFS filesystem with the "writethru"
  994. +# option, e.g.
  995. +# $ /sbin/nfs_mount -o rw,writethru 'j' derfwpc5131:/export/home/rmainz #
  996. +#
  997. +# Test:
  998. +svn checkout https://svn.FreeBSD.org/base/head/share/man
  999. +
  1000. +
  1001.  # EOF.
  1002. --
  1003. 2.45.1
  1004.  
  1005. From fe4e8a32714ce886c46f2d2652363a77608d44a7 Mon Sep 17 00:00:00 2001
  1006. From: Roland Mainz <roland.mainz@nrubsig.org>
  1007. Date: Mon, 17 Jun 2024 18:45:23 +0200
  1008. Subject: [PATCH 8/8] sys,nfs41_build_features.h: Add
  1009.  |NFS41_DRIVER_DEBUG_FS_NAME| to set fs name
  1010.  
  1011. Add |NFS41_DRIVER_DEBUG_FS_NAME| to set fs name returned by
  1012. |FileFsAttributeInfo|.
  1013.  
  1014. This is STRICTLY for debugging only, as any other name than "NFS"
  1015. breaks compatibilty with SFU and other applications, and breaks
  1016. backwards compatibility with the Microsoft NFSv3 driver.
  1017.  
  1018. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  1019. ---
  1020. nfs41_build_features.h | 10 ++++++++++
  1021.  sys/nfs41_driver.c     |  6 ++++++
  1022.  2 files changed, 16 insertions(+)
  1023.  
  1024. diff --git a/nfs41_build_features.h b/nfs41_build_features.h
  1025. index 7ca7b45..0fb2882 100644
  1026. --- a/nfs41_build_features.h
  1027. +++ b/nfs41_build_features.h
  1028. @@ -123,4 +123,14 @@
  1029.   */
  1030.  #define NFS41_DRIVER_DEFAULT_CREATE_MODE (0755)
  1031.  
  1032. +/*
  1033. + * NFS41_DRIVER_DEBUG_FS_NAME - define which filesystem name should
  1034. + * be returned by |FileFsAttributeInfo|
  1035. + * 1 == "NFS" (like Microsoft, Exceed and OpenText NFS drivers)
  1036. + * 2 == "DEBUG-NFS41" (custom value, used for disabling
  1037. + *     hardcoded codepaths for "nfs" drivers, and just treat
  1038. + *     this like a normal non-NFS MiniRDR driver
  1039. + */
  1040. +#define NFS41_DRIVER_DEBUG_FS_NAME 1
  1041. +
  1042.  #endif /* !_NFS41_DRIVER_BUILDFEATURES_ */
  1043. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  1044. index 6a237e4..09dd881 100644
  1045. --- a/sys/nfs41_driver.c
  1046. +++ b/sys/nfs41_driver.c
  1047. @@ -376,7 +376,13 @@ typedef struct _NFS41_NETROOT_EXTENSION {
  1048.          (PNFS41_NETROOT_EXTENSION)((pNetRoot)->Context))
  1049.  
  1050.  /* FileSystemName as reported by FileFsAttributeInfo query */
  1051. +#if ((NFS41_DRIVER_DEBUG_FS_NAME) == 1)
  1052.  #define FS_NAME     L"NFS"
  1053. +#elif  ((NFS41_DRIVER_DEBUG_FS_NAME) == 2)
  1054. +#define FS_NAME     L"DEBUG-NFS41"
  1055. +#else
  1056. +#error NFS41_DRIVER_DEBUG_FS_NAME not defined
  1057. +#endif
  1058.  #define FS_NAME_LEN (sizeof(FS_NAME) - sizeof(WCHAR))
  1059.  #define FS_ATTR_LEN (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + FS_NAME_LEN)
  1060.  
  1061. --
  1062. 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