- From 485e55beda6227b87e4dfb14705f2c5970f7ff80 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Thu, 26 Sep 2024 14:22:32 +0200
- Subject: [PATCH 1/2] cygwin: Make msnfs41client(.bash) compatible with ksh93
- Make msnfs41client(.bash) compatible with ksh93.
- So far we've avoided using ksh93 for "msnfs41client" so
- $ msnfs41client install # can be used without ksh93, but
- as the rest of the scripts and infrastructure (e.g. idmapper)
- require /usr/bin/ksh93 this might not be feasible.
- Reported-by: Mark Liam Brown <brownmarkliam@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/devel/msnfs41client.bash | 55 ++++++++++++++++++++++++++++++---
- 1 file changed, 50 insertions(+), 5 deletions(-)
- diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
- index 426ba8d..415a2e9 100755
- --- a/cygwin/devel/msnfs41client.bash
- +++ b/cygwin/devel/msnfs41client.bash
- @@ -53,7 +53,11 @@ function check_machine_arch
- # because on Cygwin the script will be installed
- # in /cygdrive/c/cygwin/lib/msnfs41client/ (32bit) or
- # in /cygdrive/c/cygwin64/lib/msnfs41client/ (64bit).
- - winpwd="$(cygpath -w "$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")")"
- + if [[ -v KSH_VERSION ]] ; then
- + winpwd="$(cygpath -w "$(dirname -- "$(realpath "${.sh.file}")")")"
- + else
- + winpwd="$(cygpath -w "$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")")"
- + fi
- uname_m="$(uname -m)"
- @@ -90,7 +94,11 @@ function nfsclient_install
- # because on Cygwin the script will be installed
- # in /cygdrive/c/cygwin/lib/msnfs41client/ (32bit) or
- # in /cygdrive/c/cygwin64/lib/msnfs41client/ (64bit).
- - cd -P "$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")"
- + if [[ -v KSH_VERSION ]] ; then
- + cd -P "$(dirname -- "$(realpath "${.sh.file}")")"
- + else
- + cd -P "$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")"
- + fi
- # make sure all binaries are executable, Windows cmd does
- # not care, but Cygwin&bash do.
- @@ -275,7 +283,11 @@ function nfsclient_adddriver
- # because on Cygwin the script will be installed
- # in /cygdrive/c/cygwin/lib/msnfs41client/ (32bit) or
- # in /cygdrive/c/cygwin64/lib/msnfs41client/ (64bit).
- - cd -P "$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")"
- + if [[ -v KSH_VERSION ]] ; then
- + cd -P "$(dirname -- "$(realpath "${.sh.file}")")"
- + else
- + cd -P "$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")"
- + fi
- # devel: set default in case "nfs_install" ruined it:
- #regtool -s set '/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/NetworkProvider/Order/ProviderOrder' 'RDPNP,LanmanWorkstation,webclient'
- @@ -309,7 +321,11 @@ function nfsclient_removedriver
- # because on Cygwin the script will be installed
- # in /cygdrive/c/cygwin/lib/msnfs41client/ (32bit) or
- # in /cygdrive/c/cygwin64/lib/msnfs41client/ (64bit).
- - cd -P "$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")"
- + if [[ -v KSH_VERSION ]] ; then
- + cd -P "$(dirname -- "$(realpath "${.sh.file}")")"
- + else
- + cd -P "$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")"
- + fi
- nfs_install.exe 0
- rundll32.exe setupapi.dll,InstallHinfSection DefaultUninstall 132 ./nfs41rdr.inf
- @@ -743,7 +759,11 @@ function main
- typeset -i numerr=0
- # path where this script is installed
- - typeset scriptpath="$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")"
- + if [[ -v KSH_VERSION ]] ; then
- + typeset scriptpath="$(dirname -- "$(realpath "${.sh.file}")")"
- + else
- + typeset scriptpath="$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")"
- + fi
- # "$PATH:/usr/bin:/bin" is used for PsExec where $PATH might be empty
- PATH="$PWD:$PATH:${scriptpath}../../usr/bin:${scriptpath}/../../bin:${scriptpath}/../../sbin:${scriptpath}/../../usr/sbin"
- @@ -926,6 +946,31 @@ function main
- #
- # main
- #
- +if [[ -v KSH_VERSION ]] ; then
- + #
- + # use ksh93 builtins
- + # (and make it fatal if they are missing)
- + #
- + set -o errexit
- + builtin cat
- + builtin chmod
- + builtin chown
- + builtin cp
- + builtin dirname
- + builtin id
- + builtin ln
- + builtin md5sum
- + builtin mkdir
- + builtin mv
- + builtin rm
- + builtin rmdir
- + builtin sync
- + builtin tail
- + builtin uname
- + PATH="/usr/ast/bin:/opt/ast/bin:$PATH"
- + set +o errexit
- +fi
- +
- main "$@"
- exit $?
- --
- 2.45.1
- From 8e74071b918786f60a281eb10c8fc860a6aaab32 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Thu, 26 Sep 2024 16:28:54 +0200
- Subject: [PATCH 2/2] sys,tests: Implement
- |FileCaseSensitiveInformation|+testcase in winfsinfo
- Implement |FileCaseSensitiveInformation| and add testcase in winfsinfo.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41_driver.c | 33 ++++++++++++++++++
- tests/winfsinfo1/winfsinfo.c | 67 ++++++++++++++++++++++++++++++++++++
- 2 files changed, 100 insertions(+)
- diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
- index ee44975..8143840 100644
- --- a/sys/nfs41_driver.c
- +++ b/sys/nfs41_driver.c
- @@ -6083,6 +6083,39 @@ static NTSTATUS nfs41_QueryFileInformation(
- status = STATUS_SUCCESS;
- goto out;
- }
- + case FileCaseSensitiveInformation:
- + {
- + if (RxContext->Info.LengthRemaining <
- + sizeof(FILE_CASE_SENSITIVE_INFORMATION)) {
- + print_error("nfs41_QueryFileInformation: "
- + "FILE_CASE_SENSITIVE_INFORMATION buffer too small\n");
- + status = STATUS_BUFFER_TOO_SMALL;
- + goto out;
- + }
- +
- + PFILE_CASE_SENSITIVE_INFORMATION info =
- + (PFILE_CASE_SENSITIVE_INFORMATION)RxContext->Info.Buffer;
- +
- + ULONG fsattrs = pVNetRootContext->FsAttrs.FileSystemAttributes;
- +
- + /*
- + * For NFSv4.1 |FATTR4_WORD0_CASE_INSENSITIVE| used
- + * to fill |FsAttrs.FileSystemAttributes| is per
- + * filesystem.
- + * FIXME: Future NFSv4.x standards should make this a
- + * per-filesystem, per-directory and
- + * per-extended-attribute-dir attribute to support
- + * Win32
- + */
- + if (fsattrs & FILE_CASE_SENSITIVE_SEARCH) {
- + info->Flags = FILE_CS_FLAG_CASE_SENSITIVE_DIR;
- + }
- +
- + RxContext->Info.LengthRemaining -=
- + sizeof(FILE_CASE_SENSITIVE_INFORMATION);
- + status = STATUS_SUCCESS;
- + goto out;
- + }
- case FileBasicInformation:
- case FileStandardInformation:
- case FileInternalInformation:
- diff --git a/tests/winfsinfo1/winfsinfo.c b/tests/winfsinfo1/winfsinfo.c
- index 702761a..4832ea9 100644
- --- a/tests/winfsinfo1/winfsinfo.c
- +++ b/tests/winfsinfo1/winfsinfo.c
- @@ -447,6 +447,69 @@ done:
- }
- +static
- +bool get_filecasesensitiveinfo(const char *progname, const char *filename)
- +{
- + int res = EXIT_FAILURE;
- + bool ok;
- + FILE_CASE_SENSITIVE_INFO finfo;
- + (void)memset(&finfo, 0, sizeof(finfo));
- +
- + HANDLE fileHandle = CreateFileA(filename,
- + GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
- + FILE_FLAG_BACKUP_SEMANTICS, NULL);
- + if (fileHandle == INVALID_HANDLE_VALUE) {
- + (void)fprintf(stderr,
- + "%s: Error opening file '%s'. Last error was %d.\n",
- + progname,
- + filename,
- + (int)GetLastError());
- + return EXIT_FAILURE;
- + }
- +
- + ok = GetFileInformationByHandleEx(fileHandle,
- + 23/*FileCaseSensitiveInfo*/,
- + &finfo, sizeof(finfo));
- +
- + if (!ok) {
- + (void)fprintf(stderr, "%s: GetFileInformationByHandleEx() "
- + "error. GetLastError()==%d.\n",
- + progname,
- + (int)GetLastError());
- + res = EXIT_FAILURE;
- + goto done;
- + }
- +
- + (void)printf("(\n");
- + (void)printf("\tfilename='%s'\n", filename);
- +
- + (void)printf("\ttypeset -a Flags=(\n");
- +
- + ULONG fcsi_flags = finfo.Flags;
- +#define TESTFCSI(s) \
- + if (fcsi_flags & (s)) { \
- + (void)puts("\t\t"#s); \
- + fcsi_flags &= ~(s); \
- + }
- + TESTFCSI(FILE_CS_FLAG_CASE_SENSITIVE_DIR);
- +
- + (void)printf("\t)\n");
- +
- + /*
- + * print any leftover flags not covered by |TESTFCSI(FILE_*)|
- + * above
- + */
- + if (fcsi_flags) {
- + (void)printf("\ffcsi_flags=0x%lx\n", (long)fcsi_flags);
- + }
- + (void)printf(")\n");
- + res = EXIT_SUCCESS;
- +
- +done:
- + (void)CloseHandle(fileHandle);
- + return res;
- +}
- +
- static
- bool get_getfiletime(const char *progname, const char *filename)
- {
- @@ -516,6 +579,7 @@ void usage(void)
- "fileexinfostandard|"
- "filestandardinfo|"
- "filenormalizednameinfo|"
- + "filecasesensitiveinfo|"
- "getfiletime"
- "> path\n");
- }
- @@ -549,6 +613,9 @@ int main(int ac, char *av[])
- else if (!strcmp(subcmd, "getfiletime")) {
- return get_getfiletime(av[0], av[2]);
- }
- + else if (!strcmp(subcmd, "filecasesensitiveinfo")) {
- + return get_filecasesensitiveinfo(av[0], av[2]);
- + }
- else {
- (void)fprintf(stderr, "%s: Unknown subcmd '%s'\n", av[0], subcmd);
- return EXIT_FAILURE;
- --
- 2.45.1
msnfs41client: Implement FileCaseSensitiveInformation syscall+tests+misc, 2024-09-26
Posted by Anonymous on Thu 26th Sep 2024 15:41
raw | new post
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.