pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for cleanup, debuggging code, testing+misc, 2024-08-29
Posted by Anonymous on Thu 29th Aug 2024 15:45
raw | new post

  1. From a4df2b5d735d8b0e1028686679b84c74f187baaa Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Thu, 29 Aug 2024 12:51:42 +0200
  4. Subject: [PATCH 1/9] sys: Add infrastructure for file
  5.  IOCTLs/|MRxLowIOSubmit[LOWIO_OP_IOCTL]|
  6.  
  7. Add infrastructure for file IOCTLs/|MRxLowIOSubmit[LOWIO_OP_IOCTL]|
  8.  
  9. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  10. ---
  11. sys/nfs41_driver.c | 22 ++++++++++++++++++++++
  12.  1 file changed, 22 insertions(+)
  13.  
  14. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  15. index 0c339d1..2a3f80a 100644
  16. --- a/sys/nfs41_driver.c
  17. +++ b/sys/nfs41_driver.c
  18. @@ -64,6 +64,7 @@
  19.  //#define DEBUG_EA_SET
  20.  //#define DEBUG_LOCK
  21.  #define DEBUG_FSCTL
  22. +#define DEBUG_IOCTL
  23.  #define DEBUG_TIME_BASED_COHERENCY
  24.  #define DEBUG_MOUNT
  25.  //#define DEBUG_VOLUME_QUERY
  26. @@ -7383,6 +7384,26 @@ static NTSTATUS nfs41_FsCtl(
  27.      return status;
  28.  }
  29.  
  30. +static NTSTATUS nfs41_IoCtl(
  31. +    IN OUT PRX_CONTEXT RxContext)
  32. +{
  33. +    NTSTATUS status = STATUS_INVALID_DEVICE_REQUEST;
  34. +#ifdef DEBUG_IOCTL
  35. +    DbgEn();
  36. +    print_debug_header(RxContext);
  37. +#endif /* DEBUG_IOCTL */
  38. +    const ULONG iocontrolcode =
  39. +        RxContext->LowIoContext.ParamsFor.IoCtl.IoControlCode;
  40. +
  41. +    DbgP("nfs41_IoCtl: IoControlCode=0x%lx, status=0x%lx\n",
  42. +        (unsigned long)iocontrolcode, (long)status);
  43. +
  44. +#ifdef DEBUG_IOCTL
  45. +    DbgEx();
  46. +#endif
  47. +    return status;
  48. +}
  49. +
  50.  static NTSTATUS nfs41_CompleteBufferingStateChangeRequest(
  51.      IN OUT PRX_CONTEXT RxContext,
  52.      IN OUT PMRX_SRV_OPEN SrvOpen,
  53. @@ -7562,6 +7583,7 @@ static NTSTATUS nfs41_init_ops()
  54.      nfs41_ops.MRxLowIOSubmit[LOWIO_OP_UNLOCK]          = nfs41_Unlock;
  55.      nfs41_ops.MRxLowIOSubmit[LOWIO_OP_UNLOCK_MULTIPLE] = nfs41_Unlock;
  56.      nfs41_ops.MRxLowIOSubmit[LOWIO_OP_FSCTL]           = nfs41_FsCtl;
  57. +    nfs41_ops.MRxLowIOSubmit[LOWIO_OP_IOCTL]           = nfs41_IoCtl;
  58.  
  59.      //
  60.      // Miscellanous
  61. --
  62. 2.45.1
  63.  
  64. From aa26f3d74bc843da596858f8eb6da3fd006e1d30 Mon Sep 17 00:00:00 2001
  65. From: Roland Mainz <roland.mainz@nrubsig.org>
  66. Date: Thu, 29 Aug 2024 13:11:49 +0200
  67. Subject: [PATCH 2/9] sys: |IOCTL_NFS41_INVALCACHE| should return errors
  68.  
  69. |IOCTL_NFS41_INVALCACHE| should return errors, e.g. if passed
  70. |HANDLE| is invalid.
  71.  
  72. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  73. ---
  74. sys/nfs41_driver.c | 18 ++++++++++++++----
  75.  1 file changed, 14 insertions(+), 4 deletions(-)
  76.  
  77. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  78. index 2a3f80a..83b415b 100644
  79. --- a/sys/nfs41_driver.c
  80. +++ b/sys/nfs41_driver.c
  81. @@ -1419,23 +1419,34 @@ static NTSTATUS marshal_nfs41_shutdown(
  82.      return marshal_nfs41_header(entry, buf, buf_len, len);
  83.  }
  84.  
  85. -static void nfs41_invalidate_cache(
  86. +static NTSTATUS nfs41_invalidate_cache(
  87.      IN PRX_CONTEXT RxContext)
  88.  {
  89.      PLOWIO_CONTEXT LowIoContext = &RxContext->LowIoContext;
  90.      unsigned char *buf = LowIoContext->ParamsFor.IoCtl.pInputBuffer;
  91.      ULONG flag = DISABLE_CACHING;
  92.      PMRX_SRV_OPEN srv_open;
  93. +    NTSTATUS status;
  94.  
  95.      RtlCopyMemory(&srv_open, buf, sizeof(HANDLE));
  96.  #ifdef DEBUG_INVALIDATE_CACHE
  97.      DbgP("nfs41_invalidate_cache: received srv_open=0x%p '%wZ'\n",
  98.          srv_open, srv_open->pAlreadyPrefixedName);
  99.  #endif
  100. -    if (MmIsAddressValid(srv_open))
  101. +    if (MmIsAddressValid(srv_open)) {
  102.          RxIndicateChangeOfBufferingStateForSrvOpen(
  103.              srv_open->pFcb->pNetRoot->pSrvCall, srv_open,
  104.              srv_open->Key, ULongToPtr(flag));
  105. +        status = STATUS_SUCCESS;
  106. +    }
  107. +    else {
  108. +        print_error("nfs41_invalidate_cache: "
  109. +            "invalid ptr srv_open=0x%p file='%wZ'\n",
  110. +            srv_open, srv_open->pAlreadyPrefixedName);
  111. +        status = STATUS_INVALID_HANDLE;
  112. +    }
  113. +
  114. +    return status;
  115.  }
  116.  
  117.  static NTSTATUS handle_upcall(
  118. @@ -2590,8 +2601,7 @@ static NTSTATUS nfs41_DevFcbXXXControlFile(
  119.          print_fs_ioctl(0, fsop);
  120.          switch (fsop) {
  121.          case IOCTL_NFS41_INVALCACHE:
  122. -            nfs41_invalidate_cache(RxContext);
  123. -            status = STATUS_SUCCESS;
  124. +            status = nfs41_invalidate_cache(RxContext);
  125.              break;
  126.          case IOCTL_NFS41_READ:
  127.              status = nfs41_upcall(RxContext);
  128. --
  129. 2.45.1
  130.  
  131. From baf9a85ffab7259ded12145513c8ce159b9d0385 Mon Sep 17 00:00:00 2001
  132. From: Dan Shelton <dan.f.shelton@gmail.com>
  133. Date: Thu, 29 Aug 2024 14:35:36 +0200
  134. Subject: [PATCH 3/9] daemon: Add more asserts to verify whether
  135.  nfs41_file_info data are valid
  136.  
  137. Add more asserts to verify whether nfs41_file_info data are valid
  138.  
  139. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  140. ---
  141. daemon/util.c | 10 ++++++++++
  142.  1 file changed, 10 insertions(+)
  143.  
  144. diff --git a/daemon/util.c b/daemon/util.c
  145. index 178c285..30081c7 100644
  146. --- a/daemon/util.c
  147. +++ b/daemon/util.c
  148. @@ -158,6 +158,8 @@ ULONG nfs_file_info_to_attributes(
  149.              info->type));
  150.      }
  151.  
  152. +    EASSERT((info->attrmask.count > 1) &&
  153. +        (info->attrmask.arr[1] & FATTR4_WORD1_MODE));
  154.      if (info->mode == 0444) /* XXX: 0444 for READONLY */
  155.          attrs |= FILE_ATTRIBUTE_READONLY;
  156.  
  157. @@ -175,6 +177,8 @@ void nfs_to_basic_info(
  158.      IN const nfs41_file_info *info,
  159.      OUT PFILE_BASIC_INFO basic_out)
  160.  {
  161. +    EASSERT(info->attrmask.count > 1);
  162. +
  163.      if (info->attrmask.arr[1] & FATTR4_WORD1_TIME_CREATE) {
  164.          nfs_time_to_file_time(&info->time_create, &basic_out->CreationTime);
  165.      }
  166. @@ -221,6 +225,10 @@ void nfs_to_standard_info(
  167.  {
  168.      const ULONG FileAttributes = nfs_file_info_to_attributes(info);
  169.  
  170. +    EASSERT(info->attrmask.arr[0] & FATTR4_WORD0_SIZE);
  171. +    EASSERT((info->attrmask.count > 1) &&
  172. +        (info->attrmask.arr[1] & FATTR4_WORD1_NUMLINKS));
  173. +
  174.      std_out->AllocationSize.QuadPart =
  175.          std_out->EndOfFile.QuadPart = (LONGLONG)info->size;
  176.      std_out->NumberOfLinks = info->numlinks;
  177. @@ -234,6 +242,8 @@ void nfs_to_network_openinfo(
  178.      IN const nfs41_file_info *info,
  179.      OUT PFILE_NETWORK_OPEN_INFORMATION net_out)
  180.  {
  181. +    EASSERT(info->attrmask.count > 1);
  182. +
  183.      if (info->attrmask.arr[1] & FATTR4_WORD1_TIME_CREATE) {
  184.          nfs_time_to_file_time(&info->time_create, &net_out->CreationTime);
  185.      }
  186. --
  187. 2.45.1
  188.  
  189. From 70c42e3c36fb2ad1e8db57244108c577034ec620 Mon Sep 17 00:00:00 2001
  190. From: Dan Shelton <dan.f.shelton@gmail.com>
  191. Date: Thu, 29 Aug 2024 14:38:24 +0200
  192. Subject: [PATCH 4/9] daemon: Unify info.attrmask.count tests
  193.  
  194. Unify info.attrmask.count tests
  195.  
  196. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  197. ---
  198. daemon/acl.c        |  6 +++---
  199.  daemon/ea.c         |  2 +-
  200.  daemon/getattr.c    |  2 +-
  201.  daemon/name_cache.c |  4 ++--
  202.  daemon/nfs41_xdr.c  |  6 +++---
  203.  daemon/open.c       | 12 ++++++------
  204.  daemon/readwrite.c  |  4 ++--
  205.  daemon/setattr.c    |  6 +++---
  206.  8 files changed, 21 insertions(+), 21 deletions(-)
  207.  
  208. diff --git a/daemon/acl.c b/daemon/acl.c
  209. index 3c5ba5b..8622678 100644
  210. --- a/daemon/acl.c
  211. +++ b/daemon/acl.c
  212. @@ -332,7 +332,7 @@ use_nfs41_getattr:
  213.              goto out;
  214.          }
  215.  
  216. -        EASSERT(info.attrmask.count >= 2);
  217. +        EASSERT(info.attrmask.count > 1);
  218.  
  219.          /*
  220.           * In rare cases owner/owner_group are not in the cache
  221. @@ -346,7 +346,7 @@ use_nfs41_getattr:
  222.          }
  223.      }
  224.  
  225. -    EASSERT(info.attrmask.count >= 2);
  226. +    EASSERT(info.attrmask.count > 1);
  227.      EASSERT((info.attrmask.arr[1] & (FATTR4_WORD1_OWNER|FATTR4_WORD1_OWNER_GROUP)) == (FATTR4_WORD1_OWNER|FATTR4_WORD1_OWNER_GROUP));
  228.      if (args->query & DACL_SECURITY_INFORMATION) {
  229.          EASSERT((info.attrmask.arr[0] & (FATTR4_WORD0_ACL)) == (FATTR4_WORD0_ACL));
  230. @@ -1426,7 +1426,7 @@ static int handle_setacl(void *daemon_context, nfs41_upcall *upcall)
  231.      else {
  232.          args->ctime = info.change;
  233.  
  234. -        EASSERT((info.attrmask.count >= 1) &&
  235. +        EASSERT((info.attrmask.count > 0) &&
  236.              (info.attrmask.arr[0] & FATTR4_WORD0_CHANGE));
  237.  
  238.          if (DPRINTF_LEVEL_ENABLED(ACLLVL1)) {
  239. diff --git a/daemon/ea.c b/daemon/ea.c
  240. index 7fb2091..ae967df 100644
  241. --- a/daemon/ea.c
  242. +++ b/daemon/ea.c
  243. @@ -193,7 +193,7 @@ static int handle_setexattr(void *daemon_context, nfs41_upcall *upcall)
  244.              goto out;
  245.          }
  246.  
  247. -        EASSERT((info.attrmask.count >= 1) &&
  248. +        EASSERT((info.attrmask.count > 0) &&
  249.              (info.attrmask.arr[0] & FATTR4_WORD0_CHANGE));
  250.          args->ctime = info.change;
  251.          goto out;
  252. diff --git a/daemon/getattr.c b/daemon/getattr.c
  253. index c3b79b6..c193d40 100644
  254. --- a/daemon/getattr.c
  255. +++ b/daemon/getattr.c
  256. @@ -168,7 +168,7 @@ static int handle_getattr(void *daemon_context, nfs41_upcall *upcall)
  257.      switch (args->query_class) {
  258.      case FileBasicInformation:
  259.          nfs_to_basic_info(state->file.name.name, &info, &args->basic_info);
  260. -        EASSERT((info.attrmask.count >= 1) &&
  261. +        EASSERT((info.attrmask.count > 0) &&
  262.              (info.attrmask.arr[0] & FATTR4_WORD0_CHANGE));
  263.          args->ctime = info.change;
  264.          break;
  265. diff --git a/daemon/name_cache.c b/daemon/name_cache.c
  266. index a21aaf2..dc0e615 100644
  267. --- a/daemon/name_cache.c
  268. +++ b/daemon/name_cache.c
  269. @@ -286,7 +286,7 @@ static void attr_cache_update(
  270.      IN enum open_delegation_type4 delegation)
  271.  {
  272.      /* update the attributes present in mask */
  273. -    if (info->attrmask.count >= 1) {
  274. +    if (info->attrmask.count > 0) {
  275.          if (info->attrmask.arr[0] & FATTR4_WORD0_TYPE)
  276.              entry->type = (unsigned char)(info->type & NFS_FTYPE_MASK);
  277.          if (info->attrmask.arr[0] & FATTR4_WORD0_CHANGE) {
  278. @@ -302,7 +302,7 @@ static void attr_cache_update(
  279.          if (info->attrmask.arr[0] & FATTR4_WORD0_ARCHIVE)
  280.              entry->archive = info->archive;
  281.      }
  282. -    if (info->attrmask.count >= 2) {
  283. +    if (info->attrmask.count > 1) {
  284.          if (info->attrmask.arr[1] & FATTR4_WORD1_MODE)
  285.              entry->mode = info->mode;
  286.          if (info->attrmask.arr[1] & FATTR4_WORD1_OWNER) {
  287. diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
  288. index 2d3f11c..382feb7 100644
  289. --- a/daemon/nfs41_xdr.c
  290. +++ b/daemon/nfs41_xdr.c
  291. @@ -1735,7 +1735,7 @@ static bool_t decode_file_attrs(
  292.      fattr4 *attrs,
  293.      nfs41_file_info *info)
  294.  {
  295. -    if (attrs->attrmask.count >= 1) {
  296. +    if (attrs->attrmask.count > 0) {
  297.          if (attrs->attrmask.arr[0] & FATTR4_WORD0_SUPPORTED_ATTRS) {
  298.              if (!xdr_bitmap4(xdr, info->supported_attrs))
  299.                  return FALSE;
  300. @@ -1819,7 +1819,7 @@ static bool_t decode_file_attrs(
  301.                  return FALSE;
  302.          }
  303.      }
  304. -    if (attrs->attrmask.count >= 2) {
  305. +    if (attrs->attrmask.count > 1) {
  306.          if (attrs->attrmask.arr[1] & FATTR4_WORD1_MODE) {
  307.              if (!xdr_u_int32_t(xdr, &info->mode))
  308.                  return FALSE;
  309. @@ -1901,7 +1901,7 @@ static bool_t decode_file_attrs(
  310.                  return FALSE;
  311.          }
  312.      }
  313. -    if (attrs->attrmask.count >= 3) {
  314. +    if (attrs->attrmask.count > 2) {
  315.          if (attrs->attrmask.arr[2] & FATTR4_WORD2_MDSTHRESHOLD) {
  316.              if (!xdr_mdsthreshold(xdr, &info->mdsthreshold))
  317.                  return FALSE;
  318. diff --git a/daemon/open.c b/daemon/open.c
  319. index 5b1bf49..545adf6 100644
  320. --- a/daemon/open.c
  321. +++ b/daemon/open.c
  322. @@ -760,10 +760,10 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  323.          }
  324.          nfs_to_basic_info(state->file.name.name, &info, &args->basic_info);
  325.          nfs_to_standard_info(&info, &args->std_info);
  326. -        EASSERT((info.attrmask.count >= 2) &&
  327. +        EASSERT((info.attrmask.count > 1) &&
  328.              (info.attrmask.arr[1] & FATTR4_WORD1_MODE));
  329.          args->mode = info.mode;
  330. -        EASSERT((info.attrmask.count >= 1) &&
  331. +        EASSERT((info.attrmask.count > 0) &&
  332.              (info.attrmask.arr[0] & FATTR4_WORD0_CHANGE));
  333.          args->changeattr = info.change;
  334.      } else if (open_for_attributes(state->type, args->access_mask,
  335. @@ -775,10 +775,10 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  336.  
  337.          nfs_to_basic_info(state->file.name.name, &info, &args->basic_info);
  338.          nfs_to_standard_info(&info, &args->std_info);
  339. -        EASSERT((info.attrmask.count >= 2) &&
  340. +        EASSERT((info.attrmask.count > 1) &&
  341.              (info.attrmask.arr[1] & FATTR4_WORD1_MODE));
  342.          args->mode = info.mode;
  343. -        EASSERT((info.attrmask.count >= 1) &&
  344. +        EASSERT((info.attrmask.count > 0) &&
  345.              (info.attrmask.arr[0] & FATTR4_WORD0_CHANGE));
  346.          args->changeattr = info.change;
  347.  
  348. @@ -1005,10 +1005,10 @@ create_chgrp_out:
  349.  
  350.              nfs_to_basic_info(state->file.name.name, &info, &args->basic_info);
  351.              nfs_to_standard_info(&info, &args->std_info);
  352. -            EASSERT((info.attrmask.count >= 2) &&
  353. +            EASSERT((info.attrmask.count > 1) &&
  354.                  (info.attrmask.arr[1] & FATTR4_WORD1_MODE));
  355.              args->mode = info.mode;
  356. -            EASSERT((info.attrmask.count >= 1) &&
  357. +            EASSERT((info.attrmask.count > 0) &&
  358.                  (info.attrmask.arr[0] & FATTR4_WORD0_CHANGE));
  359.              args->changeattr = info.change;
  360.          }
  361. diff --git a/daemon/readwrite.c b/daemon/readwrite.c
  362. index e8b5a8a..bdfb902 100644
  363. --- a/daemon/readwrite.c
  364. +++ b/daemon/readwrite.c
  365. @@ -240,7 +240,7 @@ retry_write:
  366.                         goto out;
  367.         }
  368.  
  369. -    EASSERT((info.attrmask.count >= 1) &&
  370. +    EASSERT((info.attrmask.count > 0) &&
  371.          (info.attrmask.arr[0] & FATTR4_WORD0_CHANGE));
  372.      args->ctime = info.change;
  373.  
  374. @@ -273,7 +273,7 @@ static int write_to_pnfs(
  375.          status = ERROR_WRITE_FAULT;
  376.          goto out;
  377.      }
  378. -    EASSERT((info.attrmask.count >= 1) &&
  379. +    EASSERT((info.attrmask.count > 0) &&
  380.          (info.attrmask.arr[0] & FATTR4_WORD0_CHANGE));
  381.      args->ctime = info.change;
  382.  out:
  383. diff --git a/daemon/setattr.c b/daemon/setattr.c
  384. index bd8c0e8..13dee18 100644
  385. --- a/daemon/setattr.c
  386. +++ b/daemon/setattr.c
  387. @@ -145,7 +145,7 @@ static int handle_nfs41_setattr(void *daemon_context, setattr_upcall_args *args)
  388.          status = nfs_to_windows_error(status, ERROR_NOT_SUPPORTED);
  389.          goto out;
  390.      }
  391. -    EASSERT((info.attrmask.count >= 1) &&
  392. +    EASSERT((info.attrmask.count > 0) &&
  393.          (info.attrmask.arr[0] & FATTR4_WORD0_CHANGE));
  394.      args->ctime = info.change;
  395.  out:
  396. @@ -385,7 +385,7 @@ static int handle_nfs41_set_size(void *daemon_context, setattr_upcall_args *args
  397.      AcquireSRWLockExclusive(&state->lock);
  398.      state->pnfs_last_offset = info.size ? info.size - 1 : 0;
  399.      ReleaseSRWLockExclusive(&state->lock);
  400. -    EASSERT((info.attrmask.count >= 1) &&
  401. +    EASSERT((info.attrmask.count > 0) &&
  402.          (info.attrmask.arr[0] & FATTR4_WORD0_CHANGE));
  403.      args->ctime = info.change;
  404.  out:
  405. @@ -490,7 +490,7 @@ static int handle_nfs41_link(void *daemon_context, setattr_upcall_args *args)
  406.          status = nfs_to_windows_error(status, ERROR_INVALID_PARAMETER);
  407.          goto out;
  408.      }
  409. -    EASSERT((info.attrmask.count >= 1) &&
  410. +    EASSERT((info.attrmask.count > 0) &&
  411.          (info.attrmask.arr[0] & FATTR4_WORD0_CHANGE));
  412.      args->ctime = info.change;
  413.  out:
  414. --
  415. 2.45.1
  416.  
  417. From f1e164e17528b8d9c57d3e2f4b39dc01b3a82458 Mon Sep 17 00:00:00 2001
  418. From: Dan Shelton <dan.f.shelton@gmail.com>
  419. Date: Thu, 29 Aug 2024 14:52:19 +0200
  420. Subject: [PATCH 5/9] daemon: nfs41_delegate_open() should use
  421.  nfs41_file_info_cpy()
  422.  
  423. nfs41_delegate_open() should use nfs41_file_info_cpy() to copy
  424. a nfs41_file_info.
  425.  
  426. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  427. ---
  428. daemon/delegation.c | 3 ++-
  429.  1 file changed, 2 insertions(+), 1 deletion(-)
  430.  
  431. diff --git a/daemon/delegation.c b/daemon/delegation.c
  432. index c3bf58c..0578618 100644
  433. --- a/daemon/delegation.c
  434. +++ b/daemon/delegation.c
  435. @@ -514,7 +514,8 @@ int nfs41_delegate_open(
  436.          goto out_deleg;
  437.  
  438.      if (create == OPEN4_CREATE) {
  439. -        memcpy(info, createattrs, sizeof(nfs41_file_info));
  440. +        EASSERT(createattrs != NULL);
  441. +        nfs41_file_info_cpy(info, createattrs);
  442.  
  443.          /* write delegations allow us to simulate OPEN4_CREATE with SETATTR */
  444.          status = delegation_truncate(deleg, client, &stateid, info);
  445. --
  446. 2.45.1
  447.  
  448. From 2c159da4d726c3d4f3de36259411e95c5da9ea61 Mon Sep 17 00:00:00 2001
  449. From: Dan Shelton <dan.f.shelton@gmail.com>
  450. Date: Thu, 29 Aug 2024 14:53:56 +0200
  451. Subject: [PATCH 6/9] daemon: do_open() should use stateid4_cpy() to copy a
  452.  state id
  453.  
  454. do_open() should use stateid4_cpy() to copy a state id
  455.  
  456. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  457. ---
  458. daemon/open.c | 2 +-
  459.  1 file changed, 1 insertion(+), 1 deletion(-)
  460.  
  461. diff --git a/daemon/open.c b/daemon/open.c
  462. index 545adf6..04c40e0 100644
  463. --- a/daemon/open.c
  464. +++ b/daemon/open.c
  465. @@ -326,7 +326,7 @@ static int do_open(
  466.  
  467.      AcquireSRWLockExclusive(&state->lock);
  468.      /* update the stateid */
  469. -    memcpy(&state->stateid, &open_stateid, sizeof(open_stateid));
  470. +    stateid4_cpy(&state->stateid, &open_stateid);
  471.      state->do_close = 1;
  472.      state->delegation.state = deleg_state;
  473.      ReleaseSRWLockExclusive(&state->lock);
  474. --
  475. 2.45.1
  476.  
  477. From 9cb3c651fd11da123ef643ab1e9b4001fe9c162e Mon Sep 17 00:00:00 2001
  478. From: Roland Mainz <roland.mainz@nrubsig.org>
  479. Date: Thu, 29 Aug 2024 15:06:38 +0200
  480. Subject: [PATCH 7/9] daemon: Add |open_delegation4_cpy()| as a type-safe way
  481.  to copy an |open_delegation4|
  482.  
  483. Add |open_delegation4_cpy()| as a type-safe way to copy an
  484. |open_delegation4|.
  485.  
  486. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  487. ---
  488. daemon/delegation.c | 2 +-
  489.  daemon/recovery.c   | 6 +++---
  490.  daemon/util.h       | 7 +++++++
  491.  3 files changed, 11 insertions(+), 4 deletions(-)
  492.  
  493. diff --git a/daemon/delegation.c b/daemon/delegation.c
  494. index 0578618..a9e72a8 100644
  495. --- a/daemon/delegation.c
  496. +++ b/daemon/delegation.c
  497. @@ -49,7 +49,7 @@ static int delegation_create(
  498.          goto out;
  499.      }
  500.  
  501. -    memcpy(&state->state, delegation, sizeof(open_delegation4));
  502. +    open_delegation4_cpy(&state->state, delegation);
  503.  
  504.      abs_path_copy(&state->path, file->path);
  505.      path_fh_init(&state->file, &state->path);
  506. diff --git a/daemon/recovery.c b/daemon/recovery.c
  507. index e784b2f..83d176e 100644
  508. --- a/daemon/recovery.c
  509. +++ b/daemon/recovery.c
  510. @@ -266,7 +266,7 @@ static int recover_open(
  511.                  eprintf("recover_open() got delegation type %u, "
  512.                      "expected %u\n", delegation.type, deleg->state.type);
  513.              } else {
  514. -                memcpy(&deleg->state, &delegation, sizeof(open_delegation4));
  515. +                open_delegation4_cpy(&deleg->state, &delegation);
  516.                  deleg->revoked = FALSE;
  517.              }
  518.              ReleaseSRWLockExclusive(&deleg->lock);
  519. @@ -385,7 +385,7 @@ static int recover_delegation_want(
  520.          eprintf("recover_delegation_want() got delegation type %u, "
  521.              "expected %u\n", delegation.type, deleg->state.type);
  522.      } else {
  523. -        memcpy(&deleg->state, &delegation, sizeof(open_delegation4));
  524. +        open_delegation4_cpy(&deleg->state, &delegation);
  525.          deleg->revoked = FALSE;
  526.      }
  527.      ReleaseSRWLockExclusive(&deleg->lock);
  528. @@ -444,7 +444,7 @@ static int recover_delegation_open(
  529.          eprintf("recover_delegation_open() got delegation type %u, "
  530.              "expected %u\n", delegation.type, deleg->state.type);
  531.      } else {
  532. -        memcpy(&deleg->state, &delegation, sizeof(open_delegation4));
  533. +        open_delegation4_cpy(&deleg->state, &delegation);
  534.          deleg->revoked = FALSE;
  535.      }
  536.      ReleaseSRWLockExclusive(&deleg->lock);
  537. diff --git a/daemon/util.h b/daemon/util.h
  538. index a9053db..2b13d06 100644
  539. --- a/daemon/util.h
  540. +++ b/daemon/util.h
  541. @@ -164,6 +164,13 @@ static __inline int stateid4_cmp(
  542.      return memcmp(s1, s2, sizeof(stateid4));
  543.  }
  544.  
  545. +static __inline void open_delegation4_cpy(
  546. +    OUT open_delegation4 *restrict dst,
  547. +    IN  const open_delegation4 *restrict src)
  548. +{
  549. +    (void)memcpy(dst, src, sizeof(open_delegation4));
  550. +}
  551. +
  552.  ULONG nfs_file_info_to_attributes(
  553.      IN const nfs41_file_info *info);
  554.  void nfs_to_basic_info(
  555. --
  556. 2.45.1
  557.  
  558. From 64552a0fddf26a8620e2349976d9b0265c1e3c34 Mon Sep 17 00:00:00 2001
  559. From: Roland Mainz <roland.mainz@nrubsig.org>
  560. Date: Thu, 29 Aug 2024 16:02:13 +0200
  561. Subject: [PATCH 8/9] daemon: Use |memcpy()|, not |CopyMemory()|
  562.  
  563. Use |memcpy()|, not |CopyMemory()| - |CopyMemory()| is a define to
  564. |memcpy()| anyway, and just confuses people.
  565.  
  566. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  567. ---
  568. daemon/util.c | 4 ++--
  569.  1 file changed, 2 insertions(+), 2 deletions(-)
  570.  
  571. diff --git a/daemon/util.c b/daemon/util.c
  572. index 30081c7..c0d0f15 100644
  573. --- a/daemon/util.c
  574. +++ b/daemon/util.c
  575. @@ -43,7 +43,7 @@ int safe_read(unsigned char **pos, uint32_t *remaining, void *dest, uint32_t des
  576.      if (*remaining < dest_len)
  577.          return ERROR_BUFFER_OVERFLOW;
  578.  
  579. -    CopyMemory(dest, *pos, dest_len);
  580. +    (void)memcpy(dest, *pos, dest_len);
  581.      *pos += dest_len;
  582.      *remaining -= dest_len;
  583.      return 0;
  584. @@ -54,7 +54,7 @@ int safe_write(unsigned char **pos, uint32_t *remaining, void *src, uint32_t src
  585.      if (*remaining < src_len)
  586.          return ERROR_BUFFER_OVERFLOW;
  587.  
  588. -    CopyMemory(*pos, src, src_len);
  589. +    (void)memcpy(*pos, src, src_len);
  590.      *pos += src_len;
  591.      *remaining -= src_len;
  592.      return 0;
  593. --
  594. 2.45.1
  595.  
  596. From 1156e51fd4d86a7b3489c900412729f277cdb30d Mon Sep 17 00:00:00 2001
  597. From: Roland Mainz <roland.mainz@nrubsig.org>
  598. Date: Thu, 29 Aug 2024 16:37:29 +0200
  599. Subject: [PATCH 9/9] tests: Document Windows kernel debugger setup
  600.  
  601. Document how to setup and use the Windows kernel debugger.
  602.  
  603. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  604. ---
  605. tests/manual_testing.txt | 16 ++++++++++++++++
  606.  1 file changed, 16 insertions(+)
  607.  
  608. diff --git a/tests/manual_testing.txt b/tests/manual_testing.txt
  609. index 380d618..154b8d3 100644
  610. --- a/tests/manual_testing.txt
  611. +++ b/tests/manual_testing.txt
  612. @@ -70,6 +70,22 @@
  613.  #   sc query cygserver
  614.  #   ---- snip ----
  615.  #
  616. +# - Windows Kernel debugger setup:
  617. +#   1. Install "winsdksetup.exe" from
  618. +#     https://go.microsoft.com/fwlink/?linkid=2164145 on all machines
  619. +#     involved
  620. +#   2. Machine "A" runs ms-nfs41-client, and has the IPv4 address
  621. +#     10.49.202.87
  622. +#   3. Machine "B" runs the "kd" kernel debugger frontend, and has the
  623. +#     IPv4 address 10.49.202.231
  624. +#   4. Setup on machine "A":
  625. +#     $ PATH+=':/cygdrive/c/Program Files (x86)/Windows Kits/10/Debuggers/x64/'
  626. +#     $ bcdedit /dbgsettings net hostip:10.49.202.87 port:50000 key:1.1.1.1
  627. +#     $ kdnet 10.49.202.231 50000
  628. +#   5. Run kernel debugger frontend on machine "B":
  629. +#     $ PATH+=':/cygdrive/c/Program Files (x86)/Windows Kits/10/Debuggers/x64/'
  630. +#     $ kd -loga kdlog.log -k net:port=50000,key=1.1.1.1,target=10.49.202.87 #
  631. +#
  632.  
  633.  #
  634.  # Tests for cp -p/mv/chmod/chgrp
  635. --
  636. 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