pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Implement FileCaseSensitiveInformation syscall+tests+misc, 2024-09-26
Posted by Anonymous on Thu 26th Sep 2024 15:41
raw | new post

  1. From 485e55beda6227b87e4dfb14705f2c5970f7ff80 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Thu, 26 Sep 2024 14:22:32 +0200
  4. Subject: [PATCH 1/2] cygwin: Make msnfs41client(.bash) compatible with ksh93
  5.  
  6. Make msnfs41client(.bash) compatible with ksh93.
  7. So far we've avoided using ksh93 for "msnfs41client" so
  8. $ msnfs41client install # can be used without ksh93, but
  9. as the rest of the scripts and infrastructure (e.g. idmapper)
  10. require /usr/bin/ksh93 this might not be feasible.
  11.  
  12. Reported-by: Mark Liam Brown <brownmarkliam@gmail.com>
  13. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  14. ---
  15.  cygwin/devel/msnfs41client.bash | 55 ++++++++++++++++++++++++++++++---
  16.  1 file changed, 50 insertions(+), 5 deletions(-)
  17.  
  18. diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
  19. index 426ba8d..415a2e9 100755
  20. --- a/cygwin/devel/msnfs41client.bash
  21. +++ b/cygwin/devel/msnfs41client.bash
  22. @@ -53,7 +53,11 @@ function check_machine_arch
  23.         # because on Cygwin the script will be installed
  24.         # in /cygdrive/c/cygwin/lib/msnfs41client/ (32bit) or
  25.         # in /cygdrive/c/cygwin64/lib/msnfs41client/ (64bit).
  26. -       winpwd="$(cygpath -w "$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")")"
  27. +       if [[ -v KSH_VERSION ]] ; then
  28. +               winpwd="$(cygpath -w "$(dirname -- "$(realpath "${.sh.file}")")")"
  29. +       else
  30. +               winpwd="$(cygpath -w "$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")")"
  31. +       fi
  32.  
  33.         uname_m="$(uname -m)"
  34.  
  35. @@ -90,7 +94,11 @@ function nfsclient_install
  36.         # because on Cygwin the script will be installed
  37.         # in /cygdrive/c/cygwin/lib/msnfs41client/ (32bit) or
  38.         # in /cygdrive/c/cygwin64/lib/msnfs41client/ (64bit).
  39. -       cd -P "$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")"
  40. +       if [[ -v KSH_VERSION ]] ; then
  41. +               cd -P "$(dirname -- "$(realpath "${.sh.file}")")"
  42. +       else
  43. +               cd -P "$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")"
  44. +       fi
  45.  
  46.         # make sure all binaries are executable, Windows cmd does
  47.         # not care, but Cygwin&bash do.
  48. @@ -275,7 +283,11 @@ function nfsclient_adddriver
  49.         # because on Cygwin the script will be installed
  50.         # in /cygdrive/c/cygwin/lib/msnfs41client/ (32bit) or
  51.         # in /cygdrive/c/cygwin64/lib/msnfs41client/ (64bit).
  52. -       cd -P "$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")"
  53. +       if [[ -v KSH_VERSION ]] ; then
  54. +               cd -P "$(dirname -- "$(realpath "${.sh.file}")")"
  55. +       else
  56. +               cd -P "$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")"
  57. +       fi
  58.  
  59.         # devel: set default in case "nfs_install" ruined it:
  60.         #regtool -s set '/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/NetworkProvider/Order/ProviderOrder' 'RDPNP,LanmanWorkstation,webclient'
  61. @@ -309,7 +321,11 @@ function nfsclient_removedriver
  62.         # because on Cygwin the script will be installed
  63.         # in /cygdrive/c/cygwin/lib/msnfs41client/ (32bit) or
  64.         # in /cygdrive/c/cygwin64/lib/msnfs41client/ (64bit).
  65. -       cd -P "$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")"
  66. +       if [[ -v KSH_VERSION ]] ; then
  67. +               cd -P "$(dirname -- "$(realpath "${.sh.file}")")"
  68. +       else
  69. +               cd -P "$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")"
  70. +       fi
  71.  
  72.         nfs_install.exe 0
  73.         rundll32.exe setupapi.dll,InstallHinfSection DefaultUninstall 132 ./nfs41rdr.inf
  74. @@ -743,7 +759,11 @@ function main
  75.         typeset -i numerr=0
  76.  
  77.         # path where this script is installed
  78. -       typeset scriptpath="$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")"
  79. +       if [[ -v KSH_VERSION ]] ; then
  80. +               typeset scriptpath="$(dirname -- "$(realpath "${.sh.file}")")"
  81. +       else
  82. +               typeset scriptpath="$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")"
  83. +       fi
  84.  
  85.         # "$PATH:/usr/bin:/bin" is used for PsExec where $PATH might be empty
  86.         PATH="$PWD:$PATH:${scriptpath}../../usr/bin:${scriptpath}/../../bin:${scriptpath}/../../sbin:${scriptpath}/../../usr/sbin"
  87. @@ -926,6 +946,31 @@ function main
  88.  #
  89.  # main
  90.  #
  91. +if [[ -v KSH_VERSION ]] ; then
  92. +       #
  93. +       # use ksh93 builtins
  94. +       # (and make it fatal if they are missing)
  95. +       #
  96. +       set -o errexit
  97. +       builtin cat
  98. +       builtin chmod
  99. +       builtin chown
  100. +       builtin cp
  101. +       builtin dirname
  102. +       builtin id
  103. +       builtin ln
  104. +       builtin md5sum
  105. +       builtin mkdir
  106. +       builtin mv
  107. +       builtin rm
  108. +       builtin rmdir
  109. +       builtin sync
  110. +       builtin tail
  111. +       builtin uname
  112. +       PATH="/usr/ast/bin:/opt/ast/bin:$PATH"
  113. +       set +o errexit
  114. +fi
  115. +
  116.  main "$@"
  117.  exit $?
  118.  
  119. --
  120. 2.45.1
  121.  
  122. From 8e74071b918786f60a281eb10c8fc860a6aaab32 Mon Sep 17 00:00:00 2001
  123. From: Roland Mainz <roland.mainz@nrubsig.org>
  124. Date: Thu, 26 Sep 2024 16:28:54 +0200
  125. Subject: [PATCH 2/2] sys,tests: Implement
  126.  |FileCaseSensitiveInformation|+testcase in winfsinfo
  127.  
  128. Implement |FileCaseSensitiveInformation| and add testcase in winfsinfo.
  129.  
  130. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  131. ---
  132.  sys/nfs41_driver.c           | 33 ++++++++++++++++++
  133.  tests/winfsinfo1/winfsinfo.c | 67 ++++++++++++++++++++++++++++++++++++
  134.  2 files changed, 100 insertions(+)
  135.  
  136. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  137. index ee44975..8143840 100644
  138. --- a/sys/nfs41_driver.c
  139. +++ b/sys/nfs41_driver.c
  140. @@ -6083,6 +6083,39 @@ static NTSTATUS nfs41_QueryFileInformation(
  141.          status = STATUS_SUCCESS;
  142.          goto out;
  143.      }
  144. +    case FileCaseSensitiveInformation:
  145. +    {
  146. +        if (RxContext->Info.LengthRemaining <
  147. +            sizeof(FILE_CASE_SENSITIVE_INFORMATION)) {
  148. +            print_error("nfs41_QueryFileInformation: "
  149. +                "FILE_CASE_SENSITIVE_INFORMATION buffer too small\n");
  150. +            status = STATUS_BUFFER_TOO_SMALL;
  151. +            goto out;
  152. +        }
  153. +
  154. +        PFILE_CASE_SENSITIVE_INFORMATION info =
  155. +            (PFILE_CASE_SENSITIVE_INFORMATION)RxContext->Info.Buffer;
  156. +
  157. +        ULONG fsattrs = pVNetRootContext->FsAttrs.FileSystemAttributes;
  158. +
  159. +        /*
  160. +         * For NFSv4.1 |FATTR4_WORD0_CASE_INSENSITIVE| used
  161. +         * to fill |FsAttrs.FileSystemAttributes| is per
  162. +         * filesystem.
  163. +         * FIXME: Future NFSv4.x standards should make this a
  164. +         * per-filesystem, per-directory and
  165. +         * per-extended-attribute-dir attribute to support
  166. +         * Win32
  167. +         */
  168. +        if (fsattrs & FILE_CASE_SENSITIVE_SEARCH) {
  169. +            info->Flags = FILE_CS_FLAG_CASE_SENSITIVE_DIR;
  170. +        }
  171. +
  172. +        RxContext->Info.LengthRemaining -=
  173. +            sizeof(FILE_CASE_SENSITIVE_INFORMATION);
  174. +        status = STATUS_SUCCESS;
  175. +        goto out;
  176. +    }
  177.      case FileBasicInformation:
  178.      case FileStandardInformation:
  179.      case FileInternalInformation:
  180. diff --git a/tests/winfsinfo1/winfsinfo.c b/tests/winfsinfo1/winfsinfo.c
  181. index 702761a..4832ea9 100644
  182. --- a/tests/winfsinfo1/winfsinfo.c
  183. +++ b/tests/winfsinfo1/winfsinfo.c
  184. @@ -447,6 +447,69 @@ done:
  185.  }
  186.  
  187.  
  188. +static
  189. +bool get_filecasesensitiveinfo(const char *progname, const char *filename)
  190. +{
  191. +    int res = EXIT_FAILURE;
  192. +    bool ok;
  193. +    FILE_CASE_SENSITIVE_INFO finfo;
  194. +    (void)memset(&finfo, 0, sizeof(finfo));
  195. +
  196. +    HANDLE fileHandle = CreateFileA(filename,
  197. +        GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
  198. +        FILE_FLAG_BACKUP_SEMANTICS, NULL);
  199. +    if (fileHandle == INVALID_HANDLE_VALUE) {
  200. +        (void)fprintf(stderr,
  201. +            "%s: Error opening file '%s'. Last error was %d.\n",
  202. +            progname,
  203. +            filename,
  204. +            (int)GetLastError());
  205. +        return EXIT_FAILURE;
  206. +    }
  207. +
  208. +    ok = GetFileInformationByHandleEx(fileHandle,
  209. +        23/*FileCaseSensitiveInfo*/,
  210. +        &finfo, sizeof(finfo));
  211. +
  212. +    if (!ok) {
  213. +        (void)fprintf(stderr, "%s: GetFileInformationByHandleEx() "
  214. +            "error. GetLastError()==%d.\n",
  215. +            progname,
  216. +            (int)GetLastError());
  217. +        res = EXIT_FAILURE;
  218. +        goto done;
  219. +    }
  220. +
  221. +    (void)printf("(\n");
  222. +    (void)printf("\tfilename='%s'\n", filename);
  223. +
  224. +    (void)printf("\ttypeset -a Flags=(\n");
  225. +
  226. +    ULONG fcsi_flags = finfo.Flags;
  227. +#define TESTFCSI(s) \
  228. +    if (fcsi_flags & (s)) { \
  229. +        (void)puts("\t\t"#s); \
  230. +        fcsi_flags &= ~(s); \
  231. +    }
  232. +    TESTFCSI(FILE_CS_FLAG_CASE_SENSITIVE_DIR);
  233. +
  234. +    (void)printf("\t)\n");
  235. +
  236. +    /*
  237. +     * print any leftover flags not covered by |TESTFCSI(FILE_*)|
  238. +     * above
  239. +     */
  240. +    if (fcsi_flags) {
  241. +        (void)printf("\ffcsi_flags=0x%lx\n", (long)fcsi_flags);
  242. +    }
  243. +    (void)printf(")\n");
  244. +    res = EXIT_SUCCESS;
  245. +
  246. +done:
  247. +    (void)CloseHandle(fileHandle);
  248. +    return res;
  249. +}
  250. +
  251.  static
  252.  bool get_getfiletime(const char *progname, const char *filename)
  253.  {
  254. @@ -516,6 +579,7 @@ void usage(void)
  255.          "fileexinfostandard|"
  256.          "filestandardinfo|"
  257.          "filenormalizednameinfo|"
  258. +        "filecasesensitiveinfo|"
  259.          "getfiletime"
  260.          "> path\n");
  261.  }
  262. @@ -549,6 +613,9 @@ int main(int ac, char *av[])
  263.      else if (!strcmp(subcmd, "getfiletime")) {
  264.          return get_getfiletime(av[0], av[2]);
  265.      }
  266. +    else if (!strcmp(subcmd, "filecasesensitiveinfo")) {
  267. +        return get_filecasesensitiveinfo(av[0], av[2]);
  268. +    }
  269.      else {
  270.          (void)fprintf(stderr, "%s: Unknown subcmd '%s'\n", av[0], subcmd);
  271.          return EXIT_FAILURE;
  272. --
  273. 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