- From 60bb8f7497b7b17695a91364ef43c93463bc5a87 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Fri, 1 Dec 2023 16:06:15 +0100
- Subject: [PATCH 1/4] daemon: Enable FileSystemAttributes FILE_UNICODE_ON_DISK
- Enable FileSystemAttributes |FILE_UNICODE_ON_DISK|, as the NFSv4
- protocol supports Unicode by default (assuming that the underlying
- storage filesystem used by the NFSv4 server supports that too),
- so that |GetVolumeInformationByHandleW()| will return it.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/Makefile | 8 ++-
- daemon/nfs41_superblock.c | 28 ++++++--
- tests/winfsinfo1/Makefile | 15 ++++
- tests/winfsinfo1/winfsinfo.c | 131 +++++++++++++++++++++++++++++++++++
- 4 files changed, 175 insertions(+), 7 deletions(-)
- create mode 100644 tests/winfsinfo1/Makefile
- create mode 100644 tests/winfsinfo1/winfsinfo.c
- diff --git a/cygwin/Makefile b/cygwin/Makefile
- index 301ea56..b7a3b1e 100644
- --- a/cygwin/Makefile
- +++ b/cygwin/Makefile
- @@ -31,13 +31,14 @@ build:
- which MSBuild.exe
- MSBuild.exe '$(shell cygpath -w "$(PROJECT_BASEDIR_DIR)/build.vc19/nfs41-client.sln")' -t:Build -p:Configuration=Debug -p:Platform=x64
- #MSBuild.exe $(PROJECT_BASEDIR_DIR)/build.vc19/nfs41-client.sln -t:Build -p:Configuration=Debug -p:Platform=x64
- -
- + (cd tests/winfsinfo1 && make all)
- #
- # clean target
- #
- clean:
- rm -vRf $$(find "$(PROJECT_BASEDIR_DIR)/build.vc19" -name Debug -o -name Release)
- + (cd tests/winfsinfo1 && make clean)
- # install in DESTDIR
- installdest: $(VS_BUILD_DIR)/nfsd.exe \
- @@ -73,10 +74,13 @@ installdest: $(VS_BUILD_DIR)/nfsd.exe \
- chmod a+x $(DESTDIR)/cygdrive/c/cygwin64/sbin/mount_sshnfs
- cp $(CYGWIN_MAKEFILE_DIR)/utils/sshnfs/sshnfs.ksh $(DESTDIR)/cygdrive/c/cygwin64/sbin/sshnfs
- chmod a+x $(DESTDIR)/cygdrive/c/cygwin64/sbin/sshnfs
- - (cd $(DESTDIR)/cygdrive/c/cygwin64/sbin/ ; chmod a+x *.exe *.dll *.sys *.bash)
- + @ printf "# Package tests\n"
- + cp tests/winfsinfo1/winfsinfo.exe $(DESTDIR)/cygdrive/c/cygwin64/usr/bin/winfsinfo.exe
- @ printf "# Package ksh93&co (if available) since Cygwin does not ship with it yet\n"
- [[ -x /usr/bin/ksh93.exe ]] && cp /usr/bin/ksh93.exe $(DESTDIR)/cygdrive/c/cygwin64/usr/bin/ksh93.exe
- [[ -x /usr/bin/shcomp.exe ]] && cp /usr/bin/shcomp.exe $(DESTDIR)/cygdrive/c/cygwin64/usr/bin/shcomp.exe
- + @ printf "# Set file flags\n"
- + (cd $(DESTDIR)/cygdrive/c/cygwin64/sbin/ ; chmod a+x *.exe *.dll *.sys *.bash)
- @printf "\n#\n# TEST sbin dir is %s\n#\n" "$(DESTDIR)/cygdrive/c/cygwin64/sbin/"
- @printf '\n'
- @printf "\n#\n# Now use\n# $$ cd '%s' && bash ./msnfs41client.bash install #\n# to install the kernel driver as Admin\n#\n" \
- diff --git a/daemon/nfs41_superblock.c b/daemon/nfs41_superblock.c
- index effd02a..b2f77fd 100644
- --- a/daemon/nfs41_superblock.c
- +++ b/daemon/nfs41_superblock.c
- @@ -165,7 +165,11 @@ void nfs41_superblock_fs_attributes(
- IN const nfs41_superblock *superblock,
- OUT PFILE_FS_ATTRIBUTE_INFORMATION FsAttrs)
- {
- - FsAttrs->FileSystemAttributes = FILE_SUPPORTS_REMOTE_STORAGE;
- + FsAttrs->FileSystemAttributes = 0;
- + FsAttrs->FileSystemAttributes |= FILE_SUPPORTS_REMOTE_STORAGE;
- + /* NFSv4 protocol uses Unicode by default */
- + FsAttrs->FileSystemAttributes |= FILE_UNICODE_ON_DISK;
- +
- if (superblock->link_support)
- FsAttrs->FileSystemAttributes |= FILE_SUPPORTS_HARD_LINKS;
- if (superblock->symlink_support)
- @@ -179,15 +183,29 @@ void nfs41_superblock_fs_attributes(
- if (superblock->aclsupport)
- FsAttrs->FileSystemAttributes |= FILE_PERSISTENT_ACLS;
- + /* gisburn: Fixme: We should someone query this (NFSv4.2 ?) */
- FsAttrs->MaximumComponentNameLength = NFS41_MAX_COMPONENT_LEN;
- /* let the driver fill in FileSystemName */
- FsAttrs->FileSystemNameLength = 0;
- - dprintf(SBLVL, "FileFsAttributeInformation: case_preserving %u, "
- - "case_insensitive %u, max component %u\n",
- - superblock->case_preserving, superblock->case_insensitive,
- - FsAttrs->MaximumComponentNameLength);
- + dprintf(SBLVL, "FileFsAttributeInformation: "
- + "link_support=%u, "
- + "symlink_support=%u, "
- + "ea_support=%u, "
- + "case_preserving=%u, "
- + "case_insensitive=%u, "
- + "aclsupport=%u, "
- + "MaximumComponentNameLength=%u, "
- + "FileSystemAttributes=%lx\n",
- + superblock->link_support,
- + superblock->symlink_support,
- + superblock->ea_support,
- + superblock->case_preserving,
- + superblock->case_insensitive,
- + superblock->aclsupport,
- + (unsigned int)FsAttrs->MaximumComponentNameLength,
- + (unsigned long)FsAttrs->FileSystemAttributes);
- }
- diff --git a/tests/winfsinfo1/Makefile b/tests/winfsinfo1/Makefile
- new file mode 100644
- index 0000000..8e7d10a
- --- /dev/null
- +++ b/tests/winfsinfo1/Makefile
- @@ -0,0 +1,15 @@
- +#
- +# Makefile for winfsinfo
- +#
- +
- +# POSIX Makefile
- +
- +winfsinfo: winfsinfo.c
- + gcc -Wall -g winfsinfo.c -o winfsinfo
- +
- +all: winfsinfo
- +
- +clean:
- + rm -fv \
- + winfsinfo.exe
- +# EOF.
- diff --git a/tests/winfsinfo1/winfsinfo.c b/tests/winfsinfo1/winfsinfo.c
- new file mode 100644
- index 0000000..361e2d2
- --- /dev/null
- +++ b/tests/winfsinfo1/winfsinfo.c
- @@ -0,0 +1,131 @@
- +/*
- + * MIT License
- + *
- + * Copyright (c) 2023 Roland Mainz <roland.mainz@nrubsig.org>
- + *
- + * Permission is hereby granted, free of charge, to any person obtaining a copy
- + * of this software and associated documentation files (the "Software"), to deal
- + * in the Software without restriction, including without limitation the rights
- + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- + * copies of the Software, and to permit persons to whom the Software is
- + * furnished to do so, subject to the following conditions:
- + *
- + * The above copyright notice and this permission notice shall be included in all
- + * copies or substantial portions of the Software.
- + *
- + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- + * SOFTWARE.
- + */
- +
- +/*
- + * winfsinfo1.c - print Windows filesystem info
- + *
- + * Written by Roland Mainz <roland.mainz@nrubsig.org>
- + */
- +
- +#define UNICODE 1
- +#define _UNICODE 1
- +
- +#include <stdio.h>
- +#include <windows.h>
- +#include <stdlib.h>
- +#include <stdbool.h>
- +
- +static
- +bool print_volume_info(const char *progname, const char *filename)
- +{
- + bool ok = false;
- +
- + 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,
- + GetLastError());
- + return false;
- + }
- +
- + (void)printf("filename='%s'\n", filename);
- +
- + DWORD volumeFlags = 0;
- + ok = GetVolumeInformationByHandleW(fileHandle, NULL, 0,
- + NULL, NULL, &volumeFlags, NULL, 0);
- +
- + if (!ok) {
- + (void)fprintf(stderr, "%s: GetVolumeInformationByHandleW() "
- + "error. GetLastError()==%d.\n",
- + progname,
- + GetLastError());
- + ok = false;
- + goto done;
- + }
- +
- +#define TESTFSATTR(s) \
- + if (volumeFlags & (s)) { \
- + (void)puts("volumeflag="#s); \
- + volumeFlags &= ~(s); \
- + }
- +
- + TESTFSATTR(FILE_SUPPORTS_USN_JOURNAL);
- + TESTFSATTR(FILE_SUPPORTS_OPEN_BY_FILE_ID);
- + TESTFSATTR(FILE_SUPPORTS_EXTENDED_ATTRIBUTES);
- + TESTFSATTR(FILE_SUPPORTS_HARD_LINKS);
- + TESTFSATTR(FILE_SUPPORTS_TRANSACTIONS);
- + TESTFSATTR(FILE_SEQUENTIAL_WRITE_ONCE);
- + TESTFSATTR(FILE_READ_ONLY_VOLUME);
- + TESTFSATTR(FILE_NAMED_STREAMS);
- + TESTFSATTR(FILE_SUPPORTS_ENCRYPTION);
- + TESTFSATTR(FILE_SUPPORTS_OBJECT_IDS);
- + TESTFSATTR(FILE_VOLUME_IS_COMPRESSED);
- + TESTFSATTR(FILE_SUPPORTS_REMOTE_STORAGE);
- + TESTFSATTR(FILE_RETURNS_CLEANUP_RESULT_INFO);
- + TESTFSATTR(FILE_SUPPORTS_POSIX_UNLINK_RENAME);
- + TESTFSATTR(FILE_SUPPORTS_REPARSE_POINTS);
- + TESTFSATTR(FILE_SUPPORTS_SPARSE_FILES);
- + TESTFSATTR(FILE_VOLUME_QUOTAS);
- + TESTFSATTR(FILE_FILE_COMPRESSION);
- + TESTFSATTR(FILE_PERSISTENT_ACLS);
- + TESTFSATTR(FILE_UNICODE_ON_DISK);
- + TESTFSATTR(FILE_CASE_PRESERVED_NAMES);
- + TESTFSATTR(FILE_CASE_SENSITIVE_SEARCH);
- + TESTFSATTR(FILE_SUPPORTS_INTEGRITY_STREAMS);
- +#ifdef FILE_SUPPORTS_BLOCK_REFCOUNTING
- + TESTFSATTR(FILE_SUPPORTS_BLOCK_REFCOUNTING);
- +#endif
- +#ifdef FILE_SUPPORTS_SPARSE_VDL
- + TESTFSATTR(FILE_SUPPORTS_SPARSE_VDL);
- +#endif
- +#ifdef FILE_DAX_VOLUME
- + TESTFSATTR(FILE_DAX_VOLUME);
- +#endif
- +#ifdef FILE_SUPPORTS_GHOSTING
- + TESTFSATTR(FILE_SUPPORTS_GHOSTING);
- +#endif
- +
- + /*
- + * print any leftover flags not covered by |TESTFSATTR(FILE_*)|
- + * above
- + */
- + if (volumeFlags) {
- + (void)printf("attr=0x%lx\n", (long)volumeFlags);
- + }
- + ok = true;
- +
- +done:
- + CloseHandle(fileHandle);
- + return ok;
- +}
- +
- +int main(int ac, char *av[])
- +{
- + print_volume_info(av[0], av[1]);
- + return EXIT_SUCCESS;
- +}
- --
- 2.42.1
- From 358221a9713dd2ae0c58b289e2027593be0af5b1 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 5 Dec 2023 14:36:58 +0100
- Subject: [PATCH 2/4] daemon: Do not spend CPU time with filling buffers with
- debug markers
- daemon: Set |_CrtSetDebugFillThreshold(0)| so debug builds do
- not spend lots of CPU time time filling buffer copies etc with
- debug markers (i.e. 0xFE).
- We have DrMemory to find such bugs.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/nfs41_daemon.c | 7 +++++++
- 1 file changed, 7 insertions(+)
- diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
- index cdbad18..fe0683e 100644
- --- a/daemon/nfs41_daemon.c
- +++ b/daemon/nfs41_daemon.c
- @@ -417,6 +417,13 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv)
- /* available only when built in debug mode under visual studio -cbodley */
- _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
- _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
- +
- + /*
- + * Do not fill memory with 0xFE for functions like |strcpy_s()|
- + * etc, as it causes bad performance. We have drmemory to find
- + * issues like that instead
- + */
- + (void)_CrtSetDebugFillThreshold(0);
- #pragma warning (push)
- #pragma warning (disable : 4306) /* conversion from 'int' to '_HFILE' of greater size */
- _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
- --
- 2.42.1
- From 2d788f4fe089378a0deed2a104c4edaacb1ae6b7 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 5 Dec 2023 14:45:17 +0100
- Subject: [PATCH 3/4] nfs41_driver,daemon,mount,np: Allow long paths (beyond
- 260 characters)
- Starting in Windows 10, version 1607, MAX_PATH limitations have been
- removed from common Win32 file and directory functions
- (see https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation)
- So avoid using MAX_PATH in our code, and use 4096 (to match Cygwin
- $ getconf PATH_MAX /cygdrive/c/Users #) as limit where
- static limits are required right now now.
- Tested with CYGWIN_NT-10.0-19045 3.5.0-0.494.gcb21f8bc56c2.x86_64,
- /HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/FileSystem/LongPathsEnabled==1
- and paths up to 512 characters.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/devel/msnfs41client.bash | 5 +++++
- daemon/nfs41_const.h | 16 ++++++++++++++--
- dll/nfs41_np.c | 25 +++++++++++++------------
- dll/nfs41_np.h | 8 ++++----
- dll/options.h | 3 ++-
- mount/mount.c | 18 +++++++++---------
- mount/options.h | 2 +-
- sys/nfs41_driver.c | 4 ++--
- sys/nfs41_driver.h | 11 +++++++++++
- tests/manual_testing.txt | 19 +++++++++++++++++--
- 10 files changed, 78 insertions(+), 33 deletions(-)
- diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
- index cafd82e..a9782bb 100644
- --- a/cygwin/devel/msnfs41client.bash
- +++ b/cygwin/devel/msnfs41client.bash
- @@ -83,6 +83,10 @@ function nfsclient_install
- fsutil behavior set SymlinkEvaluation L2L:1 R2R:1 L2R:1 R2L:1
- fsutil behavior query SymlinkEvaluation
- + # enable Win32 long paths
- + # (see https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation)
- + regtool -i set '/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/FileSystem/LongPathsEnabled' 1
- +
- # make sure we can load the kernel driver
- # (does not work with SecureBoot)
- bcdedit /set testsigning on
- @@ -93,6 +97,7 @@ function nfsclient_install
- # set domain name
- regtool -s set '/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Tcpip/Parameters/Domain' 'GLOBAL.LOC'
- + od -t x4 <'/proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/FileSystem/LongPathsEnabled'
- # disable DFS
- sc query Dfsc
- diff --git a/daemon/nfs41_const.h b/daemon/nfs41_const.h
- index a3c2dd5..252dfbb 100644
- --- a/daemon/nfs41_const.h
- +++ b/daemon/nfs41_const.h
- @@ -41,9 +41,21 @@
- #define UPCALL_BUF_SIZE 2048
- -/* MaximumComponentNameLength reported for FileFsAttributeInformation */
- +/*
- + * NFS41_MAX_COMPONENT_LEN - MaximumComponentNameLength
- + * reported for FileFsAttributeInformation
- + */
- #define NFS41_MAX_COMPONENT_LEN 256
- -#define NFS41_MAX_PATH_LEN 1280
- +/*
- + * NFS41_MAX_PATH_LEN - Maximum path length
- + * Notes:
- + * - Starting in Windows 10, version 1607, MAX_PATH limitations have
- + * been removed from common Win32 file and directory functions
- + * (see https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation)
- + * - We limit this to 4096 for now, to match Cygwin
- + * $ getconf PATH_MAX /cygdrive/c/Users #
- + */
- +#define NFS41_MAX_PATH_LEN 4096
- #define NFS41_HOSTNAME_LEN 64
- #define NFS41_ADDRS_PER_SERVER 4
- diff --git a/dll/nfs41_np.c b/dll/nfs41_np.c
- index 8b259bb..6432124 100644
- --- a/dll/nfs41_np.c
- +++ b/dll/nfs41_np.c
- @@ -28,6 +28,8 @@
- #include "nfs41_np.h"
- #include "options.h"
- +#define DBG 1
- +
- #ifdef DBG
- #define DbgP(_x_) NFS41DbgPrint _x_
- #else
- @@ -40,15 +42,14 @@
- ULONG _cdecl NFS41DbgPrint( __in LPTSTR Format, ... )
- {
- ULONG rc = 0;
- - TCHAR szbuffer[256];
- +#define szbuffer_SIZE 256
- + TCHAR szbuffer[szbuffer_SIZE];
- va_list marker;
- va_start( marker, Format );
- {
- -
- - //StringCchVPrintfW( szbuffer, 127, Format, marker );
- - StringCchVPrintfW( szbuffer, 256, Format, marker );
- - szbuffer[255] = (TCHAR)0;
- + StringCchVPrintfW( szbuffer, szbuffer_SIZE, Format, marker );
- + szbuffer[szbuffer_SIZE-1] = (TCHAR)0;
- OutputDebugString( TRACE_TAG );
- OutputDebugString( szbuffer );
- }
- @@ -416,7 +417,7 @@ NPAddConnection3(
- DWORD CopyBytes = 0;
- CONNECTION_INFO Connection;
- LPWSTR ConnectionName;
- - WCHAR ServerName[MAX_PATH];
- + WCHAR ServerName[NFS41_SYS_MAX_PATH_LEN];
- PWCHAR p;
- DWORD i;
- @@ -444,9 +445,9 @@ NPAddConnection3(
- LocalName[0] = (WCHAR) toupper(lpNetResource->lpLocalName[0]);
- LocalName[1] = L':';
- LocalName[2] = L'\0';
- - StringCchCopyW( ConnectionName, MAX_PATH, NFS41_DEVICE_NAME );
- - StringCchCatW( ConnectionName, MAX_PATH, L"\\;" );
- - StringCchCatW( ConnectionName, MAX_PATH, LocalName );
- + StringCchCopyW( ConnectionName, NFS41_SYS_MAX_PATH_LEN, NFS41_DEVICE_NAME );
- + StringCchCatW( ConnectionName, NFS41_SYS_MAX_PATH_LEN, L"\\;" );
- + StringCchCatW( ConnectionName, NFS41_SYS_MAX_PATH_LEN, LocalName );
- // remote name, must start with "\\"
- if (lpNetResource->lpRemoteName[0] == L'\0' ||
- @@ -472,10 +473,10 @@ NPAddConnection3(
- i++;
- }
- ServerName[i] = L'\0';
- - StringCchCatW( ConnectionName, MAX_PATH, ServerName);
- + StringCchCatW( ConnectionName, NFS41_SYS_MAX_PATH_LEN, ServerName);
- /* insert the "nfs4" in between the server name and the path,
- * just to make sure all calls to our driver come thru this */
- - StringCchCatW( ConnectionName, MAX_PATH, L"\\nfs4" );
- + StringCchCatW( ConnectionName, NFS41_SYS_MAX_PATH_LEN, L"\\nfs4" );
- #ifdef CONVERT_2_UNIX_SLASHES
- /* convert all windows slashes to unix slashes */
- @@ -500,7 +501,7 @@ NPAddConnection3(
- }
- }
- #endif
- - StringCchCatW( ConnectionName, MAX_PATH, &p[i]);
- + StringCchCatW( ConnectionName, NFS41_SYS_MAX_PATH_LEN, &p[i]);
- DbgP(( L"[aglo] Full Connect Name: %s\n", ConnectionName ));
- DbgP(( L"[aglo] Full Connect Name Length: %d %d\n",
- (wcslen(ConnectionName) + 1) * sizeof(WCHAR),
- diff --git a/dll/nfs41_np.h b/dll/nfs41_np.h
- index aed9c35..738a61b 100644
- --- a/dll/nfs41_np.h
- +++ b/dll/nfs41_np.h
- @@ -35,10 +35,10 @@ typedef struct __NFS41NP_NETRESOURCE {
- DWORD dwType;
- DWORD dwDisplayType;
- DWORD dwUsage;
- - WCHAR LocalName[MAX_PATH];
- - WCHAR RemoteName[MAX_PATH];
- - WCHAR ConnectionName[MAX_PATH];
- - WCHAR Options[MAX_PATH];
- + WCHAR LocalName[NFS41_SYS_MAX_PATH_LEN];
- + WCHAR RemoteName[NFS41_SYS_MAX_PATH_LEN];
- + WCHAR ConnectionName[NFS41_SYS_MAX_PATH_LEN];
- + WCHAR Options[NFS41_SYS_MAX_PATH_LEN];
- } NFS41NP_NETRESOURCE, *PNFS41NP_NETRESOURCE;
- typedef struct __NFS41NP_SHARED_MEMORY {
- diff --git a/dll/options.h b/dll/options.h
- index e6f16ff..f05acc7 100644
- --- a/dll/options.h
- +++ b/dll/options.h
- @@ -22,6 +22,7 @@
- #ifndef __NFS41_NP_OPTIONS_H__
- #define __NFS41_NP_OPTIONS_H__
- +#include "nfs41_driver.h"
- #define MOUNT_OPTION_BUFFER_SECRET ('n4')
- @@ -59,7 +60,7 @@ typedef struct _CONNECTION_INFO {
- } CONNECTION_INFO, *PCONNECTION_INFO;
- #define MAX_CONNECTION_BUFFER_SIZE(EaSize) ( \
- - sizeof(CONNECTION_BUFFER) + MAX_PATH + (EaSize) )
- + sizeof(CONNECTION_BUFFER) + NFS41_SYS_MAX_PATH_LEN + (EaSize) )
- /* options.c */
- diff --git a/mount/mount.c b/mount/mount.c
- index da0c712..68fc445 100644
- --- a/mount/mount.c
- +++ b/mount/mount.c
- @@ -264,11 +264,11 @@ static DWORD ParseRemoteName(
- LPTSTR pEnd;
- int port = 0;
- PFILE_FULL_EA_INFORMATION port_option_val;
- - wchar_t remotename[MAX_PATH];
- + wchar_t remotename[NFS41_SYS_MAX_PATH_LEN];
- wchar_t *premotename = remotename;
- - wchar_t srvname[MAX_PATH+1+32]; /* sizeof(hostname+'@'+integer) */
- + wchar_t srvname[NFS41_SYS_MAX_PATH_LEN+1+32]; /* sizeof(hostname+'@'+integer) */
- - result = StringCchCopy(premotename, MAX_PATH, pRemoteName);
- + result = StringCchCopy(premotename, NFS41_SYS_MAX_PATH_LEN, pRemoteName);
- /*
- * gisburn: Fixme: Implement nfs://-URLS per RFC 2224 ("NFS URL
- @@ -442,13 +442,13 @@ static DWORD DoMount(
- IN PMOUNT_OPTION_LIST pOptions)
- {
- DWORD result = NO_ERROR;
- - TCHAR szExisting[MAX_PATH];
- - TCHAR szParsedRemoteName[MAX_PATH];
- - TCHAR szRemoteName[MAX_PATH];
- + TCHAR szExisting[NFS41_SYS_MAX_PATH_LEN];
- + TCHAR szParsedRemoteName[NFS41_SYS_MAX_PATH_LEN];
- + TCHAR szRemoteName[NFS41_SYS_MAX_PATH_LEN];
- DWORD dwLength;
- *szRemoteName = TEXT('\0');
- - result = ParseRemoteName(pRemoteName, pOptions, szParsedRemoteName, szRemoteName, MAX_PATH);
- + result = ParseRemoteName(pRemoteName, pOptions, szParsedRemoteName, szRemoteName, NFS41_SYS_MAX_PATH_LEN);
- if (result)
- goto out;
- @@ -464,8 +464,8 @@ static DWORD DoMount(
- else
- {
- NETRESOURCE NetResource;
- - TCHAR szConnection[MAX_PATH];
- - DWORD ConnectSize = MAX_PATH, ConnectResult, Flags = 0;
- + TCHAR szConnection[NFS41_SYS_MAX_PATH_LEN];
- + DWORD ConnectSize = NFS41_SYS_MAX_PATH_LEN, ConnectResult, Flags = 0;
- ZeroMemory(&NetResource, sizeof(NETRESOURCE));
- NetResource.dwType = RESOURCETYPE_DISK;
- diff --git a/mount/options.h b/mount/options.h
- index e23e986..0acfb61 100644
- --- a/mount/options.h
- +++ b/mount/options.h
- @@ -61,7 +61,7 @@ typedef struct _MOUNT_OPTION_LIST {
- /* allocate space for 8 full attributes, but limit options by
- * space rather than count. */
- #define MAX_OPTION_EA_SIZE ( 8 * \
- - (sizeof(FILE_FULL_EA_INFORMATION) + MAX_PATH) )
- + (sizeof(FILE_FULL_EA_INFORMATION) + NFS41_SYS_MAX_PATH_LEN) )
- #define MAX_OPTION_BUFFER_SIZE ( sizeof(MOUNT_OPTION_BUFFER) + \
- MAX_OPTION_EA_SIZE - 1 )
- diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
- index dcec443..26bfffa 100644
- --- a/sys/nfs41_driver.c
- +++ b/sys/nfs41_driver.c
- @@ -287,7 +287,7 @@ typedef struct _NFS41_MOUNT_CONFIG {
- BOOLEAN nocache;
- WCHAR srv_buffer[SERVER_NAME_BUFFER_SIZE];
- UNICODE_STRING SrvName; /* hostname, or hostname@port */
- - WCHAR mntpt_buffer[MAX_PATH];
- + WCHAR mntpt_buffer[NFS41_SYS_MAX_PATH_LEN];
- UNICODE_STRING MntPt;
- WCHAR sec_flavor[MAX_SEC_FLAVOR_LEN];
- UNICODE_STRING SecFlavor;
- @@ -2688,7 +2688,7 @@ void nfs41_MountConfig_InitDefaults(
- Config->SrvName.MaximumLength = SERVER_NAME_BUFFER_SIZE;
- Config->SrvName.Buffer = Config->srv_buffer;
- Config->MntPt.Length = 0;
- - Config->MntPt.MaximumLength = MAX_PATH;
- + Config->MntPt.MaximumLength = NFS41_SYS_MAX_PATH_LEN;
- Config->MntPt.Buffer = Config->mntpt_buffer;
- Config->SecFlavor.Length = 0;
- Config->SecFlavor.MaximumLength = MAX_SEC_FLAVOR_LEN;
- diff --git a/sys/nfs41_driver.h b/sys/nfs41_driver.h
- index f11eda8..be4faf6 100644
- --- a/sys/nfs41_driver.h
- +++ b/sys/nfs41_driver.h
- @@ -49,6 +49,17 @@
- #define IOCTL_NFS41_WRITE _RDR_CTL_CODE(7, METHOD_BUFFERED)
- #define IOCTL_NFS41_INVALCACHE _RDR_CTL_CODE(8, METHOD_BUFFERED)
- +/*
- + * NFS41_SYS_MAX_PATH_LEN - Maximum path length
- + * Notes:
- + * - Starting in Windows 10, version 1607, MAX_PATH limitations have
- + * been removed from common Win32 file and directory functions
- + * (see https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation)
- + * - We limit this to 4096 for now, to match Cygwin
- + * $ getconf PATH_MAX /cygdrive/c/Users #
- + */
- +#define NFS41_SYS_MAX_PATH_LEN 4096
- +
- typedef enum _nfs41_opcodes {
- NFS41_MOUNT,
- NFS41_UNMOUNT,
- diff --git a/tests/manual_testing.txt b/tests/manual_testing.txt
- index 3058c0b..e6a8173 100644
- --- a/tests/manual_testing.txt
- +++ b/tests/manual_testing.txt
- @@ -36,6 +36,11 @@ time ksh93 -c 'export SHELL=/bin/bash HOSTTYPE="cygwin.i386-64"; /bin/bash ./bin
- #
- # bash
- #
- +mkdir longpath__________________________________________________________________________________________________________________________________________________________________________________________________________________________1
- +cd longpath__________________________________________________________________________________________________________________________________________________________________________________________________________________________1
- +mkdir longpath__________________________________________________________________________________________________________________________________________________________________________________________________________________________2
- +cd longpath__________________________________________________________________________________________________________________________________________________________________________________________________________________________2
- +echo ${#PWD} # (478 is know to work)
- git clone https://git.savannah.gnu.org/git/bash.git
- cd bash/
- ./configure --with-curses
- @@ -60,8 +65,18 @@ MSBuild.exe build.vc19/nfs41-client.sln -t:Build -p:Configuration=Release -p:Pl
- #
- # gcc
- #
- -
- -
- +# * Notes:
- +# - The build requires that there are at least 131 characters left in
- +# the path, e.g. $ echo $((260-${#PWD} > 131)) # should be "1",
- +# otherwise the buildcan "randomly" fail with internal gcc errors.
- +# Note that PWD might be the UNC path.
- +# ---- snip ----
- +# $ cd gcc
- +# $ ksh93 -c 'integer pnl pnl_max ; find . | while read pn ; do pnl=${#pn} ; (( pnl_max=fmax(pnl, pnl_max) )) ; done ; printf "max_path_length=%d\n" pnl_max'
- +# max_path_length=131
- +# ---- snip ----
- +# - Full build can easily take ~~16 hours minutes
- +#
- git clone -b 'releases/gcc-13.2.0' git://gcc.gnu.org/git/gcc.git
- cd gcc/
- # Cygwin: workaround for configure using cp -p where ln -s should be used
- --
- 2.42.1
- From 8370dd0851c64eb13b4edc25c66d70d54fc92061 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 5 Dec 2023 15:00:53 +0100
- Subject: [PATCH 4/4] daemon: Demote "trying to open file/dir as dir/file"
- errors to debug msg
- daemon: Demote "trying to open directory '%s' as a file" and
- "trying to open file '%s' as a directory" errors to debug messages.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/open.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
- diff --git a/daemon/open.c b/daemon/open.c
- index 4b2a335..8c01ac1 100644
- --- a/daemon/open.c
- +++ b/daemon/open.c
- @@ -556,7 +556,7 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
- if (info.type == NF4DIR) {
- dprintf(2, "handle_nfs41_open: DIRECTORY\n");
- if (args->create_opts & FILE_NON_DIRECTORY_FILE) {
- - eprintf("trying to open directory %s as a file\n",
- + dprintf(1, "trying to open directory '%s' as a file\n",
- state->path.path);
- status = ERROR_DIRECTORY;
- goto out_free_state;
- @@ -564,7 +564,7 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
- } else if (info.type == NF4REG) {
- dprintf(2, "handle nfs41_open: FILE\n");
- if (args->create_opts & FILE_DIRECTORY_FILE) {
- - eprintf("trying to open file %s as a directory\n",
- + dprintf(1, "trying to open file '%s' as a directory\n",
- state->path.path);
- status = ERROR_BAD_FILE_TYPE;
- goto out_free_state;
- --
- 2.42.1
msnfs41client: Long path support and misc stuff, 2023-12-05
Posted by Anonymous on Tue 5th Dec 2023 14:59
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.