pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches to implement |FileNormalizedNameInformation| support+NFS traffic watcher script subcmd, 2025-02-27
Posted by Anonymous on Thu 27th Feb 2025 13:45
raw | new post

  1. From 2dcf3e2806282633000d55e626ba4526c86dc077 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Thu, 27 Feb 2025 13:13:50 +0100
  4. Subject: [PATCH 1/2] sys: Implement |FileNormalizedNameInformation|
  5.  
  6. Implement support for |FileNormalizedNameInformation|, assuming we do
  7. not build 8.3 filename support (which we do not have) and the exported
  8. NFS filesystem is case-sensitive.
  9.  
  10. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  11. ---
  12. sys/nfs41sys_fileinfo.c | 60 +++++++++++++++++++++++++++++++++++++++++
  13.  1 file changed, 60 insertions(+)
  14.  
  15. diff --git a/sys/nfs41sys_fileinfo.c b/sys/nfs41sys_fileinfo.c
  16. index 5f59d7d..c8ae273 100644
  17. --- a/sys/nfs41sys_fileinfo.c
  18. +++ b/sys/nfs41sys_fileinfo.c
  19. @@ -220,6 +220,66 @@ NTSTATUS nfs41_QueryFileInformation(
  20.  #endif
  21.  
  22.      switch (InfoClass) {
  23. +#ifdef NFS41_DRIVER_DISABLE_8DOT3_SHORTNAME_GENERATION
  24. +    /*
  25. +     * |FileNormalizedNameInformation| is specified to return an
  26. +     * absolute pathname where each short name component (e.g. 8.3
  27. +     * file name) has been replaced with the corresponding long
  28. +     * name component, and each name component uses the exact
  29. +     * letter casing stored on disk.
  30. +     *
  31. +     * So if we do not support 8.3 names (i.e.
  32. +     * |NFS41_DRIVER_DISABLE_8DOT3_SHORTNAME_GENERATION| being
  33. +     * defined) and the exported NFS filesystem is case-sensitive,
  34. +     * then just handle |FileNormalizedNameInformation| like
  35. +     * |FileNameInformation|.
  36. +     */
  37. +    case FileNormalizedNameInformation:
  38. +    {
  39. +        ULONG fsattrs = pVNetRootContext->FsAttrs.FileSystemAttributes;
  40. +
  41. +        /*
  42. +         * FIXME: If the underlying filesystem is case-insensitive we
  43. +         * would have to make an upcall to fetch the exact casing
  44. +         * from our namecache or the NFS server.
  45. +         */
  46. +        if ((fsattrs & FILE_CASE_SENSITIVE_SEARCH) == 0) {
  47. +            print_error("nfs41_QueryFileInformation: "
  48. +                "FileNormalizedNameInformation not supported for "
  49. +                "case-insensitive filesystems\n");
  50. +            status = STATUS_NOT_SUPPORTED;
  51. +            goto out;
  52. +        }
  53. +
  54. +        if (RxContext->Info.LengthRemaining <
  55. +            FIELD_OFFSET(FILE_NAME_INFORMATION, FileName)) {
  56. +            RxContext->Info.Length = 0;
  57. +            status = STATUS_BUFFER_OVERFLOW;
  58. +            goto out;
  59. +        }
  60. +
  61. +        PFILE_NAME_INFORMATION nameinfo =
  62. +            (PFILE_NAME_INFORMATION)RxContext->Info.Buffer;
  63. +        RxContext->Info.LengthRemaining -=
  64. +            FIELD_OFFSET(FILE_NAME_INFORMATION, FileName);
  65. +
  66. +        RxConjureOriginalName((PFCB)RxContext->pFcb,
  67. +            (PFOBX)RxContext->pFobx,
  68. +            &nameinfo->FileNameLength,
  69. +            &nameinfo->FileName[0],
  70. +            &RxContext->Info.Length,
  71. +            VNetRoot_As_UNC_Name);
  72. +
  73. +        if (RxContext->Info.LengthRemaining < 0) {
  74. +            RxContext->Info.Length = 0;
  75. +            status = STATUS_BUFFER_OVERFLOW;
  76. +            goto out;
  77. +        }
  78. +
  79. +        status = STATUS_SUCCESS;
  80. +        goto out;
  81. +    }
  82. +#endif /* NFS41_DRIVER_DISABLE_8DOT3_SHORTNAME_GENERATION */
  83.      case FileEaInformation:
  84.      {
  85.          if (RxContext->Info.LengthRemaining <
  86. --
  87. 2.45.1
  88.  
  89. From a8c2d216b63d80e03c76d5f957716cb4f40ae385 Mon Sep 17 00:00:00 2001
  90. From: Roland Mainz <roland.mainz@nrubsig.org>
  91. Date: Thu, 27 Feb 2025 14:28:39 +0100
  92. Subject: [PATCH 2/2] cygwin: Add msnfs41client subcmd "watch_nfs_traffic" to
  93.  watch NFS traffic
  94.  
  95. Add msnfs41client.bash subcmd "watch_nfs_traffic" to watch NFS network
  96. traffic.
  97. Requires "tshark" utility from WireShark.
  98.  
  99. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  100. ---
  101. cygwin/README.bintarball.txt    | 11 ++++++----
  102.  cygwin/devel/msnfs41client.bash | 39 +++++++++++++++++++++++++++++++++
  103.  2 files changed, 46 insertions(+), 4 deletions(-)
  104.  
  105. diff --git a/cygwin/README.bintarball.txt b/cygwin/README.bintarball.txt
  106. index 76ec183..407576a 100644
  107. --- a/cygwin/README.bintarball.txt
  108. +++ b/cygwin/README.bintarball.txt
  109. @@ -680,10 +680,13 @@ $ mount -t drvfs '\0.49.202.230@2049\nfs4\bigdisk' /mnt/bigdisk
  110.    to be installed.
  111.  
  112.  - Watching network traffic:
  113. -  WireShark has a command line tool called "tshark", which can be used
  114. -  to see NFSv4 traffic. As NFSv4 uses RPC you have to filter for RPC,
  115. -  and the RPC filter automatically identifies NFSv4 traffic on it's RPC
  116. -  id.
  117. +  - Use $ /sbin/msnfs41client watch_nfs_traffic # to watch the
  118. +  NFS network traffic
  119. +
  120. +  - WireShark has a command line tool called "tshark", which can be
  121. +  used to see NFSv4 traffic. As NFSv4 uses RPC you have to filter for
  122. +  RPC, and the RPC filter automatically identifies NFSv4 traffic on
  123. +  it's RPC id.
  124.    Example for Windows:
  125.    (for NFSv4 default TCP port "2049", replace "2049" with the
  126.    desired port if you use a custom port ; use "ipconfig" to find the
  127. diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
  128. index b12eb1e..42b4a86 100755
  129. --- a/cygwin/devel/msnfs41client.bash
  130. +++ b/cygwin/devel/msnfs41client.bash
  131. @@ -726,6 +726,35 @@ function watch_kernel_debuglog
  132.         return 0
  133.  }
  134.  
  135. +function watch_nfs_traffic
  136. +{
  137. +       typeset -i nfsv4port=2049
  138. +       typeset s
  139. +       typeset -a eth_interface_list=()
  140. +
  141. +       printf '# %s: Reading ethernet interface list\n' "$0"
  142. +       while read s ; do
  143. +               eth_interface_list+=( "${s/$'\r'/}" )
  144. +       done < <(powershell -Command 'Get-NetAdapter -Physical | Where-Object { $_.Status -eq "Up"} | ForEach-Object {$_.Name}')
  145. +
  146. +       printf '# Found interface %q\n' "${eth_interface_list[@]}"
  147. +
  148. +       # args to watch NFSv4.x RFC traffic
  149. +       typeset -a tshark_args=(
  150. +               '-f' "port $nfsv4port"
  151. +               '-d' "tcp.port==${nfsv4port},rpc"
  152. +       )
  153. +
  154. +       # add ethernet interface names
  155. +       for s in "${eth_interface_list[@]}" ; do
  156. +               tshark_args+=( '-i' "$s" )
  157. +       done
  158. +
  159. +       '/cygdrive/c/Program Files/Wireshark/tshark' "${tshark_args[@]}"
  160. +
  161. +       return 0
  162. +}
  163. +
  164.  function nfsclient_system_mount_globaldirs
  165.  {
  166.         set -o xtrace
  167. @@ -1024,6 +1053,16 @@ function main
  168.                         watch_kernel_debuglog
  169.                         return $?
  170.                         ;;
  171. +               'watch_nfs_traffic')
  172. +                       check_machine_arch || (( numerr++ ))
  173. +                       require_cmd 'powershell' || (( numerr++ ))
  174. +                       require_cmd '/cygdrive/c/Program Files/Wireshark/tshark' || (( numerr++ ))
  175. +
  176. +                       (( numerr > 0 )) && return 1
  177. +
  178. +                       watch_nfs_traffic
  179. +                       return $?
  180. +                       ;;
  181.                 'sys_terminal')
  182.                         check_machine_arch || (( numerr++ ))
  183.                         require_cmd 'mintty.exe' || (( numerr++ ))
  184. --
  185. 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