- From 308081b6da4ce62385ae678d2250f4a0ee4ef3f2 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 23 Sep 2025 14:28:33 +0200
- Subject: [PATCH 1/6] cygwin: Refactor cygwin/Makefile*+msnfs41client.bash for
- multiple architectures
- Refactor cygwin/Makefile*+msnfs41client.bash for multiple architectures.
- Goals:
- - Support any platform { ARM64, x86-32bit, x86-64bit } from
- { cygwin x86/32bit, cygwin/x86-64 64bit on x86-64, cygwin/x86-64 64bit
- on ARM64 }
- - Move hardlink generation to $ /sbin/msnfs41client install # time
- - Support 32bit-only, 64bit-only and 32bit+64bit binary tarball generation
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/Makefile | 55 +++++-----
- cygwin/Makefile.install | 177 +++++++++++++++-----------------
- cygwin/devel/msnfs41client.bash | 98 ++++++++++++++++--
- 3 files changed, 203 insertions(+), 127 deletions(-)
- diff --git a/cygwin/Makefile b/cygwin/Makefile
- index de3ad27..febbbb2 100644
- --- a/cygwin/Makefile
- +++ b/cygwin/Makefile
- @@ -13,10 +13,13 @@ PROJECT_BASEDIR_DIR := $(shell dirname $(realpath $(CYGWIN_MAKEFILE_DIR)/))
- DESTDIR:=$(PROJECT_BASEDIR_DIR)/destdir
- -VS_BUILD_DIR32:=$(PROJECT_BASEDIR_DIR)/build.vc19/Debug/
- -VS_BUILD_DIR64:=$(PROJECT_BASEDIR_DIR)/build.vc19/x64/Debug/
- -#VS_BUILD_DIR32:=$(PROJECT_BASEDIR_DIR)/build.vc19/Release/
- -#VS_BUILD_DIR64:=$(PROJECT_BASEDIR_DIR)/build.vc19/x64/Release/
- +VS_BUILD_DIR_I686:=$(PROJECT_BASEDIR_DIR)/build.vc19/Debug/
- +VS_BUILD_DIR_X64:=$(PROJECT_BASEDIR_DIR)/build.vc19/x64/Debug/
- +VS_BUILD_DIR_ARM64:=$(PROJECT_BASEDIR_DIR)/build.vc19/ARM64/Debug/
- +#VS_BUILD_DIR_I686:=$(PROJECT_BASEDIR_DIR)/build.vc19/Release/
- +#VS_BUILD_DIR_X64:=$(PROJECT_BASEDIR_DIR)/build.vc19/x64/Release/
- +#VS_BUILD_DIR_ARM64:=$(PROJECT_BASEDIR_DIR)/build.vc19/ARM64/Release/
- +
- # trigger "build_testutils" target when these binaries are needed
- $(PROJECT_BASEDIR_DIR)/tests/ea/nfs_ea.exe \
- @@ -136,36 +139,42 @@ installdest_util: \
- $(CYGWIN_MAKEFILE_DIR)/devel/msnfs41client.bash
- installdest32: \
- - $(VS_BUILD_DIR32)/nfsd.exe \
- - $(VS_BUILD_DIR32)/nfs_mount.exe \
- - $(VS_BUILD_DIR32)/nfs_install.exe \
- - $(VS_BUILD_DIR32)/nfs41_driver.sys \
- - $(VS_BUILD_DIR32)/libtirpc.dll \
- - $(VS_BUILD_DIR32)/nfs41_np.dll \
- + $(VS_BUILD_DIR_I686)/nfsd.exe \
- + $(VS_BUILD_DIR_I686)/nfs_mount.exe \
- + $(VS_BUILD_DIR_I686)/nfs_install.exe \
- + $(VS_BUILD_DIR_I686)/nfs41_driver.sys \
- + $(VS_BUILD_DIR_I686)/libtirpc.dll \
- + $(VS_BUILD_DIR_I686)/nfs41_np.dll \
- # installdest 32bit Windows
- make -f $(CYGWIN_MAKEFILE_DIR)/Makefile.install \
- installdest \
- - VS_BUILD_DIR="$(VS_BUILD_DIR32)" \
- - VS_BUILD_DIR32="$(VS_BUILD_DIR32)" \
- - VS_BUILD_DIR64="$(VS_BUILD_DIR64)" \
- + VS_BUILD_DIR_I686="$(VS_BUILD_DIR_I686)" \
- + VS_BUILD_DIR_X64="" \
- + VS_BUILD_DIR_ARM64="" \
- CYGWIN_BASEPATH=/cygdrive/c/cygwin/
- # installdest64: 32bit nfs41_np.dll is required to support 32bit
- # apps on 64bit Windows
- installdest64: \
- - $(VS_BUILD_DIR64)/nfsd.exe \
- - $(VS_BUILD_DIR64)/nfs_mount.exe \
- - $(VS_BUILD_DIR64)/nfs_install.exe \
- - $(VS_BUILD_DIR64)/nfs41_driver.sys \
- - $(VS_BUILD_DIR64)/libtirpc.dll \
- - $(VS_BUILD_DIR32)/nfs41_np.dll \
- - $(VS_BUILD_DIR64)/nfs41_np.dll \
- + $(VS_BUILD_DIR_X64)/nfsd.exe \
- + $(VS_BUILD_DIR_X64)/nfs_mount.exe \
- + $(VS_BUILD_DIR_X64)/nfs_install.exe \
- + $(VS_BUILD_DIR_X64)/nfs41_driver.sys \
- + $(VS_BUILD_DIR_X64)/libtirpc.dll \
- + $(VS_BUILD_DIR_X64)/nfs41_np.dll \
- + $(VS_BUILD_DIR_ARM64)/nfsd.exe \
- + $(VS_BUILD_DIR_ARM64)/nfs_mount.exe \
- + $(VS_BUILD_DIR_ARM64)/nfs_install.exe \
- + $(VS_BUILD_DIR_ARM64)/nfs41_driver.sys \
- + $(VS_BUILD_DIR_ARM64)/libtirpc.dll \
- + $(VS_BUILD_DIR_ARM64)/nfs41_np.dll \
- + $(VS_BUILD_DIR_I686)/nfs41_np.dll \
- # installdest 64bit Windows
- make -f $(CYGWIN_MAKEFILE_DIR)/Makefile.install \
- installdest \
- - VS_BUILD_DIR="$(VS_BUILD_DIR64)" \
- - VS_BUILD_DIR32="$(VS_BUILD_DIR32)" \
- - VS_BUILD_DIR64="$(VS_BUILD_DIR64)" \
- + VS_BUILD_DIR_I686="$(VS_BUILD_DIR_I686)" \
- + VS_BUILD_DIR_X64="$(VS_BUILD_DIR_X64)" \
- + VS_BUILD_DIR_ARM64="$(VS_BUILD_DIR_ARM64)" \
- CYGWIN_BASEPATH=/cygdrive/c/cygwin64/
- # installdest: we need a .WAIT here becase Makefile.install uses git commands
- diff --git a/cygwin/Makefile.install b/cygwin/Makefile.install
- index 337014e..a6029a6 100644
- --- a/cygwin/Makefile.install
- +++ b/cygwin/Makefile.install
- @@ -13,13 +13,6 @@ PROJECT_BASEDIR_DIR := $(shell dirname $(realpath $(CYGWIN_MAKEFILE_DIR)/))
- DESTDIR := $(PROJECT_BASEDIR_DIR)/destdir
- -# link *.exe
- -# We have to use hardlinks here, because cygwin defaults to use <JUNCTION>s,
- -# which neither cmd.exe nor powershell can follow. <SYMLINK>s are not an option,
- -# because it woulld required the "SeCreateSymbolicLinkPrivilege", which by default
- -# not even the Adminstrator has
- -LINKEXE = ln -f
- -
- # install in DESTDIR
- installdest:
- #
- @@ -36,6 +29,9 @@ installdest:
- # /usr/lib is a bind mount to C:/cygwin64/lib, so copy library data to /$(CYGWIN_BASEPATH)/lib
- mkdir -p $(DESTDIR)/$(CYGWIN_BASEPATH)/lib
- mkdir -p $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client
- + mkdir -p $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686
- + if [[ "$(VS_BUILD_DIR_X64)" != '' ]] ; then mkdir -p $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/x64 ; fi
- + if [[ "$(VS_BUILD_DIR_ARM64)" != '' ]] ; then mkdir -p $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/ARM64 ; fi
- mkdir -p $(DESTDIR)/$(CYGWIN_BASEPATH)/etc
- mkdir -p $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/src/msnfs41client
- mkdir -p $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/man/man1
- @@ -44,48 +40,71 @@ installdest:
- mkdir -p $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/misc
- mkdir -p $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/sparsefiles
- mkdir -p $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/filemmaptests
- - cp $(VS_BUILD_DIR)/nfsd.exe $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/nfsd_debug.exe
- - cp $(VS_BUILD_DIR)/nfsd.pdb $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/nfsd_debug.pdb
- - cp $(VS_BUILD_DIR)/nfs_mount.* $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/.
- - # we need a hardlink for nfs_umount.exe, softlinks do not work
- - ln -f $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/nfs_mount.exe $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/nfs_umount.exe
- + #
- + # copy x86 binaries
- + #
- + if [[ -f "$(VS_BUILD_DIR_I686)/nfs41_driver.sys" ]] ; then \
- + # workaround for coreutils 9.5-1 /bin/cp bug stuck in an endless loop with compressed files \
- + chattr -V -c $(VS_BUILD_DIR_I686)/nfs41_driver.* ; \
- + cp $(VS_BUILD_DIR_I686)/nfs41_driver.* $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/. ; \
- + cp $(VS_BUILD_DIR_I686)/nfsd.* $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/. ; \
- + cp $(VS_BUILD_DIR_I686)/libtirpc.* $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/. ; \
- + cp $(VS_BUILD_DIR_I686)/nfs_install.* $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/. ; \
- + fi
- + cp $(VS_BUILD_DIR_I686)/nfs_mount.* $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/.
- # install 32bit nfs_mount.exe on 64bit Windows to assist with debugging 32bit issues
- # we use the "Release" version on 64bit to avoid issues with missing debug libraries
- # on 32bit we just create a hardlink from nfs_mount.exe to nfs_mount.i686.exe
- - if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
- - cp $(VS_BUILD_DIR32)/../Release/nfs_mount.exe $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/nfs_mount.i686.exe ; \
- - else \
- - ln -f $(VS_BUILD_DIR32)/../Debug/nfs_mount.exe $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/nfs_mount.i686.exe ; \
- + cp $(VS_BUILD_DIR_I686)/../Release/nfs_mount.exe $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/nfs_mount.release.i686.exe
- + cp $(VS_BUILD_DIR_I686)/../Release/nfs41_np.dll $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/nfs41_np.release.dll
- + cp $(VS_BUILD_DIR_I686)/nfs41_np.* $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/. ; \
- + #
- + # copy x64 binaries
- + #
- + if [[ "$(VS_BUILD_DIR_X64)" != '' ]] ; then \
- + if [[ -f "$(VS_BUILD_DIR_X64)/nfs41_driver.sys" ]] ; then \
- + # workaround for coreutils 9.5-1 /bin/cp bug stuck in an endless loop with compressed files \
- + chattr -V -c $(VS_BUILD_DIR_X64)/nfs41_driver.* ; \
- + cp $(VS_BUILD_DIR_X64)/nfs41_driver.* $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/x64/. ; \
- + cp $(VS_BUILD_DIR_X64)/nfsd.* $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/x64/. ; \
- + cp $(VS_BUILD_DIR_X64)/libtirpc.* $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/x64/. ; \
- + cp $(VS_BUILD_DIR_X64)/nfs_install.* $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/x64/. ; \
- + fi ; \
- + cp $(VS_BUILD_DIR_X64)/nfs_mount.* $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/x64/. ; \
- + cp $(VS_BUILD_DIR_X64)/nfs41_np.* $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/x64/. ; \
- fi
- - ln -f $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/nfs_mount.i686.exe $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/nfs_umount.i686.exe
- - cp $(VS_BUILD_DIR)/nfsd.* $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/.
- - cp $(VS_BUILD_DIR)/nfs_install.* $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/.
- - cp $(VS_BUILD_DIR)/libtirpc.* $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/.
- - cp $(VS_BUILD_DIR)/nfs41_np.* $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/.
- - if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
- - mkdir -p -- $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686 ; \
- - cp $(VS_BUILD_DIR32)/../Release/nfs41_np.dll $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/nfs41_np.dll ; \
- - cp $(VS_BUILD_DIR32)/../Release/nfs41_np.exp $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/nfs41_np.exp ; \
- - cp $(VS_BUILD_DIR32)/../Release/nfs41_np.lib $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/nfs41_np.lib ; \
- - cp $(VS_BUILD_DIR32)/../Release/nfs41_np.pdb $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/nfs41_np.pdb ; \
- + #
- + # copy ARM64 binaries
- + #
- + if [[ "$(VS_BUILD_DIR_ARM64)" != '' ]] ; then \
- + if [[ -f "$(VS_BUILD_DIR_ARM64)/nfs41_driver.sys" ]] ; then \
- + # workaround for coreutils 9.5-1 /bin/cp bug stuck in an endless loop with compressed files \
- + chattr -V -c $(VS_BUILD_DIR_ARM64)/nfs41_driver.* ; \
- + cp $(VS_BUILD_DIR_ARM64)/nfs41_driver.* $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/ARM64/. ; \
- + cp $(VS_BUILD_DIR_ARM64)/nfsd.* $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/ARM64/. ; \
- + cp $(VS_BUILD_DIR_ARM64)/libtirpc.* $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/ARM64/. ; \
- + cp $(VS_BUILD_DIR_ARM64)/nfs_install.* $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/ARM64/. ; \
- + fi ; \
- + cp $(VS_BUILD_DIR_ARM64)/nfs_mount.* $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/ARM64/. ; \
- + cp $(VS_BUILD_DIR_ARM64)/nfs41_np.* $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/ARM64/. ; \
- fi
- - # workaround for coreutils 9.5-1 /bin/cp bug stuck in an endless loop with compressed files
- - chattr -V -c $(VS_BUILD_DIR)/nfs41_driver.*
- - cp $(VS_BUILD_DIR)/nfs41_driver.* $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/.
- - # Copy kernel driver INF file
- - cp $(PROJECT_BASEDIR_DIR)/nfs41rdr.inf $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/.
- - # generate signature catalog
- + # Copy kernel driver INF file and generate signature catalog
- # (inf2cat.exe cannot handle case-sensitive filesystems like NFS for temporary files, so we reset TMP&co)
- - ( \
- - inf2catbin="$$(find '/cygdrive/c/Program Files (x86)/Windows Kits/10/bin' -iname inf2cat.exe | head -n 1)" && \
- - cd "$(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/" && \
- - if [[ "$$(/usr/lib/csih/getVolInfo . | awk '/FILE_CASE_SENSITIVE_SEARCH/ { print $$3 }')" == "TRUE" ]] ; then \
- - printf "# case-sensitive filesystem, resetting TMP TMPDIR TEMP to /tmp\n" ; \
- - export TMP=/tmp TMPDIR=/tmp TEMP=/tmp ; \
- - fi && \
- - set -o xtrace ; \
- - "$$inf2catbin" /driver:. /os:10_X86,10_X64,10_VB_ARM64 \
- - )
- + for infdir in "i686" "x64" "ARM64" ; do \
- + [[ -f "$(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/$${infdir}/nfs41_driver.sys" ]] || continue ; \
- + ( \
- + cp "$(PROJECT_BASEDIR_DIR)/nfs41rdr.inf" "$(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/$${infdir}/." && \
- + inf2catbin="$$(find '/cygdrive/c/Program Files (x86)/Windows Kits/10/bin' -iname inf2cat.exe | head -n 1)" && \
- + cd "$(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/$${infdir}/." && \
- + if [[ "$$(/usr/lib/csih/getVolInfo . | awk '/FILE_CASE_SENSITIVE_SEARCH/ { print $$3 }')" == "TRUE" ]] ; then \
- + printf "# case-sensitive filesystem, resetting TMP TMPDIR TEMP to /tmp\n" ; \
- + export TMP=/tmp TMPDIR=/tmp TEMP=/tmp ; \
- + fi && \
- + set -o xtrace ; \
- + "$$inf2catbin" /driver:. /os:10_X86,10_X64,10_VB_ARM64 \
- + ) ; \
- + done
- + # Platform-independent files
- cp $(PROJECT_BASEDIR_DIR)/etc_netconfig $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/.
- cp $(PROJECT_BASEDIR_DIR)/ms-nfs41-idmap.conf $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/.
- cp $(CYGWIN_MAKEFILE_DIR)/devel/msnfs41client.bash $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/msnfs41client
- @@ -120,64 +139,21 @@ installdest:
- cp "$(PROJECT_BASEDIR_DIR)/tests/manual_testing.txt" $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/manual_testing.txt
- cp "$(PROJECT_BASEDIR_DIR)/tests/winfsinfo1/winfsinfo.x86_64.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/winfsinfo.x86_64.exe
- cp "$(PROJECT_BASEDIR_DIR)/tests/winfsinfo1/winfsinfo.i686.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/winfsinfo.i686.exe
- - if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
- - (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && $(LINKEXE) winfsinfo.x86_64.exe winfsinfo.exe) \
- - else \
- - (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && $(LINKEXE) winfsinfo.i686.exe winfsinfo.exe) \
- - fi
- cp "$(PROJECT_BASEDIR_DIR)/tests/winclonefile/winclonefile.x86_64.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/winclonefile.x86_64.exe
- cp "$(PROJECT_BASEDIR_DIR)/tests/winclonefile/winclonefile.i686.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/winclonefile.i686.exe
- - if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
- - (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && $(LINKEXE) winclonefile.x86_64.exe winclonefile.exe) \
- - else \
- - (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && $(LINKEXE) winclonefile.i686.exe winclonefile.exe) \
- - fi
- cp "$(PROJECT_BASEDIR_DIR)/tests/winoffloadcopyfile/winoffloadcopyfile.x86_64.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/winoffloadcopyfile.x86_64.exe
- cp "$(PROJECT_BASEDIR_DIR)/tests/winoffloadcopyfile/winoffloadcopyfile.i686.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/winoffloadcopyfile.i686.exe
- - if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
- - (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && $(LINKEXE) winoffloadcopyfile.x86_64.exe winoffloadcopyfile.exe) \
- - else \
- - (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && $(LINKEXE) winoffloadcopyfile.i686.exe winoffloadcopyfile.exe) \
- - fi
- cp "$(PROJECT_BASEDIR_DIR)/tests/winrunassystem/winrunassystem.x86_64.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/winrunassystem.x86_64.exe
- cp "$(PROJECT_BASEDIR_DIR)/tests/winrunassystem/winrunassystem.i686.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/winrunassystem.i686.exe
- - if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
- - (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/ && $(LINKEXE) winrunassystem.x86_64.exe winrunassystem.exe) \
- - else \
- - (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/ && $(LINKEXE) winrunassystem.i686.exe winrunassystem.exe) \
- - fi
- cp "$(PROJECT_BASEDIR_DIR)/tests/winrunassystem/nfs_globalmount.x86_64.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/nfs_globalmount.x86_64.exe
- cp "$(PROJECT_BASEDIR_DIR)/tests/winrunassystem/nfs_globalmount.i686.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/nfs_globalmount.i686.exe
- - if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
- - (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/ && $(LINKEXE) nfs_globalmount.x86_64.exe nfs_globalmount.exe) \
- - else \
- - (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/ && $(LINKEXE) nfs_globalmount.i686.exe nfs_globalmount.exe) \
- - fi
- cp "$(PROJECT_BASEDIR_DIR)/tests/lssparse/lssparse.x86_64.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/lssparse.x86_64.exe
- - if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
- - (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && $(LINKEXE) lssparse.x86_64.exe lssparse.exe) \
- - fi
- cp "$(PROJECT_BASEDIR_DIR)/tests/winsg/winsg.x86_64.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/winsg.x86_64.exe
- cp "$(PROJECT_BASEDIR_DIR)/tests/winsg/winsg.i686.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/winsg.i686.exe
- - if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
- - (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && $(LINKEXE) winsg.x86_64.exe winsg.exe) \
- - else \
- - (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && $(LINKEXE) winsg.i686.exe winsg.exe) \
- - fi
- cp "$(PROJECT_BASEDIR_DIR)/tests/ea/nfs_ea.x86_64.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/nfs_ea.x86_64.exe
- cp "$(PROJECT_BASEDIR_DIR)/tests/ea/nfs_ea.i686.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/nfs_ea.i686.exe
- - if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
- - (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && $(LINKEXE) nfs_ea.x86_64.exe nfs_ea.exe) \
- - else \
- - (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && $(LINKEXE) nfs_ea.i686.exe nfs_ea.exe) \
- - fi
- cp "$(PROJECT_BASEDIR_DIR)/tests/filemmaptests/qsortonmmapedfile1.x86_64.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/filemmaptests/qsortonmmapedfile1.x86_64.exe
- cp "$(PROJECT_BASEDIR_DIR)/tests/filemmaptests/qsortonmmapedfile1.i686.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/filemmaptests/qsortonmmapedfile1.i686.exe
- - if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
- - (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/filemmaptests/ && $(LINKEXE) qsortonmmapedfile1.x86_64.exe qsortonmmapedfile1.exe) \
- - else \
- - (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/filemmaptests/ && $(LINKEXE) qsortonmmapedfile1.i686.exe qsortonmmapedfile1.exe) \
- - fi
- cp $(PROJECT_BASEDIR_DIR)/tests/filemmaptests/testqsortonmmapedfile1.ksh93 $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/filemmaptests/testqsortonmmapedfile1.ksh93
- cp $(PROJECT_BASEDIR_DIR)/tests/nfsbuildtest/nfsbuildtest.ksh93 $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/misc/nfsbuildtest.ksh93
- cp $(PROJECT_BASEDIR_DIR)/tests/sparsefiles/testsparsefile1.ksh $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/sparsefiles/testsparsefile1.ksh
- @@ -195,21 +171,32 @@ installdest:
- typeset msbuildpath="$$(which MSBuild.exe)" ; \
- typeset vsbasepath="$${msbuildpath%*/Community/*}" ; \
- test -d "$${vsbasepath}" || { printf "vsbasepath not found\n" 1>&2 ; exit 1 ; }; \
- - if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
- + cp \
- + "$$(find "$${vsbasepath}/Community" -ipath '*/x86/*/VCRUNTIME140D.dll' | sort -n -r | head -n 1)" \
- + "$(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/." ; \
- + cp '/cygdrive/c/Program Files (x86)/Windows Kits/10/bin/x86/ucrt/ucrtbased.dll' "$(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686/." ; \
- + if [[ "$(VS_BUILD_DIR_X64)" != '' ]] ; then \
- cp \
- "$$(find "$${vsbasepath}/Community" -ipath '*/x64/*/VCRUNTIME140D.dll' | sort -n -r | head -n 1)" \
- - $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/. ; \
- - cp '/cygdrive/c/Program Files (x86)/Windows Kits/10/bin/x64/ucrt/ucrtbased.dll' $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/. ; \
- - else \
- + "$(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/x64/." ; \
- + cp '/cygdrive/c/Program Files (x86)/Windows Kits/10/bin/x64/ucrt/ucrtbased.dll' "$(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/x64/." ; \
- + fi ; \
- + if [[ "$(VS_BUILD_DIR_ARM64)" != '' ]] ; then \
- cp \
- - "$$(find "$${vsbasepath}/Community" -ipath '*/x86/*/VCRUNTIME140D.dll' | sort -n -r | head -n 1)" \
- - $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/. ; \
- - cp '/cygdrive/c/Program Files (x86)/Windows Kits/10/bin/x86/ucrt/ucrtbased.dll' $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/. ; \
- + "$$(find "$${vsbasepath}/Community" -ipath '*/arm64/*/VCRUNTIME140D.dll' | sort -n -r | head -n 1)" \
- + "$(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/ARM64/." ; \
- + cp '/cygdrive/c/Program Files (x86)/Windows Kits/10/bin/arm64/ucrt/ucrtbased.dll' "$(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/ARM64/." ; \
- fi
- @ printf "# Set file flags\n"
- (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && chmod a+rx *.exe)
- - (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/ && chmod a+rx *.exe *.dll)
- - (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/ && chmod a+rx *.dll)
- + (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/ && chmod a+rx *.exe)
- + (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/i686 && chmod a+rx *.exe *.dll)
- + if [[ "$(VS_BUILD_DIR_X64)" != '' ]] ; then \
- + (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/x64 && chmod a+rx *.exe *.dll) ; \
- + fi
- + if [[ "$(VS_BUILD_DIR_ARM64)" != '' ]] ; then \
- + (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/ARM64 && chmod a+rx *.exe *.dll) ; \
- + fi
- @printf "\n#\n# TEST sbin dir is %s\n#\n" "$(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/"
- @printf '\n'
- @printf "\n#\n# Now use\n# $$ cd '%s' && ./msnfs41client install #\n# to install the kernel driver as Admin\n#\n" \
- diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
- index 0dfc94a..975e089 100755
- --- a/cygwin/devel/msnfs41client.bash
- +++ b/cygwin/devel/msnfs41client.bash
- @@ -184,10 +184,96 @@ function nfsclient_install
- # make sure all binaries are executable, Windows cmd does
- # not care, but Cygwin&bash do.
- # If *.ddl are not executable nfs*.exe fail with 0xc0000022
- + typeset uname_m="$(uname -m)"
- + typeset uname_s="$(uname -s)"
- + typeset kernel_platform
- + case "${uname_m}" in
- + 'x86_64')
- + if [[ "${uname_s}" == *-ARM64 ]] ; then
- + kernel_platform='ARM64'
- + else
- + kernel_platform='x64'
- + fi
- + ;;
- + 'i686')
- + kernel_platform='i686'
- + ;;
- + *)
- + printf $"%s: Unsupported platform %q\n" "$0" "${uname_m}"
- + return 1
- + ;;
- + esac
- +
- + platform_dir="$PWD/${kernel_platform}"
- +
- + #
- + # We have to use hardlinks here, because cygwin defaults to use <JUNCTION>s,
- + # which neither cmd.exe nor powershell can follow. <SYMLINK>s are not an option,
- + # because it woulld required the "SeCreateSymbolicLinkPrivilege", which by default
- + # not even the Adminstrator has
- + #
- +
- + ln -f "${platform_dir}"/nfs41_driver.* .
- + ln -f "${platform_dir}"/nfsd.* .
- + ln -f "${platform_dir}"/nfs_install.* .
- + ln -f "${platform_dir}"/nfs_mount.* .
- + ln -f "${platform_dir}"/libtirpc.* .
- + ln -f "${platform_dir}"/nfs41_np.* .
- + ln -f "${platform_dir}"/nfs41rdr.inf .
- + ln -f "${platform_dir}/VCRUNTIME140D.dll" .
- + ln -f "${platform_dir}/ucrtbased.dll" .
- +
- + # add hardlinks in /sbin
- + ln -f "nfsd".* "../../sbin/."
- + ln -f "nfs_install".* "../../sbin/."
- + ln -f "nfs_mount".* "../../sbin/."
- + ln -f "libtirpc".* "../../sbin/."
- + ln -f "VCRUNTIME140D.dll" "../../sbin/."
- + ln -f "ucrtbased.dll" "../../sbin/."
- + ln -f "../../sbin/nfs_mount.exe" "../../sbin/nfs_umount.exe"
- + if [[ "${kernel_platform}" != 'i686' ]] ; then
- + ln -f 'i686/nfs_mount.release.i686.exe' "../../sbin/nfs_mount.i686.exe"
- + fi
- +
- + typeset -a platformspecificexe=(
- + 'bin/winfsinfo'
- + 'bin/winclonefile'
- + 'bin/winoffloadcopyfile'
- + 'bin/winsg'
- + 'bin/nfs_ea'
- + 'sbin/winrunassystem'
- + 'sbin/nfs_globalmount'
- + 'usr/share/msnfs41client/tests/filemmaptests/qsortonmmapedfile1'
- + )
- +
- + if [[ "${kernel_platform}" != 'i686' ]] ; then
- + # lssparse needs Cygwin >= 3.5 (|lseek(..., SEEK_HOLE, ...)| support), which is not available
- + # for Windows 32bit
- + platformspecificexe+=( 'bin/lssparse' )
- + fi
- +
- + for i in "${platformspecificexe[@]}"; do
- + case "${kernel_platform}" in
- + 'x64')
- + ln -f "../../${i}.x86_64.exe" "../../${i}.exe"
- + ;;
- + 'ARM64')
- + if [[ -f "../../${i}.arm64.exe" ]] ; then
- + ln -f "../../${i}.arm64.exe" "../../${i}.exe"
- + else
- + ln -f "../../${i}.x86_64.exe" "../../${i}.exe"
- + fi
- + ;;
- + 'i686')
- + ln -f "../../${i}.i686.exe" "../../${i}.exe"
- + ;;
- + esac
- + done
- +
- chmod a+x *.dll
- chmod a+x ../../sbin/nfs*.exe ../../sbin/libtirpc*.dll
- - # (re-)install driver
- + # (re-)install driver and network provider DLL(s) (nfs41_np.dll)
- nfsclient_adddriver
- mkdir -p /cygdrive/c/etc
- @@ -207,8 +293,6 @@ function nfsclient_install
- od -t x4 <'/proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/FileSystem/LongPathsEnabled'
- # use the Win10 "SegmentHeap" (see https://www.blackhat.com/docs/us-16/materials/us-16-Yason-Windows-10-Segment-Heap-Internals.pdf)
- - regtool add '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfsd_debug.exe'
- - regtool -i set '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfsd_debug.exe/FrontEndHeapDebugOptions' 0x08
- regtool add '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfsd.exe'
- regtool -i set '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfsd.exe/FrontEndHeapDebugOptions' 0x08
- regtool add '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfs_mount.exe'
- @@ -232,7 +316,7 @@ function nfsclient_install
- win_domainname="$( strings '/proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Tcpip/Parameters/Domain' )"
- fi
- if [[ "${win_domainname}" == '' ]] ; then
- - regtool -s set '/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Tcpip/Parameters/Domain' 'GLOBAL.LOC'
- + regtool -s set '/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Tcpip/Parameters/Domain' 'GLOBAL.LOC'
- fi
- # disable DFS
- @@ -448,7 +532,7 @@ function nfsclient_adddriver
- if is_windows_64bit ; then
- # copy from the 32bit install dir
- rm -f '/cygdrive/c/Windows/SysWOW64/nfs41_np.dll'
- - cp './i686/nfs41_np.dll' '/cygdrive/c/Windows/SysWOW64/nfs41_np.dll'
- + cp './i686/nfs41_np.release.dll' '/cygdrive/c/Windows/SysWOW64/nfs41_np.dll'
- fi
- return 0
- @@ -1070,8 +1154,6 @@ function main
- check_machine_arch || (( numerr++ ))
- require_cmd 'regtool.exe' || (( numerr++ ))
- require_cmd 'cygrunsrv.exe' || (( numerr++ ))
- - require_cmd 'nfsd.exe' || (( numerr++ ))
- - require_cmd 'nfs_install.exe' || (( numerr++ ))
- require_cmd 'rundll32.exe' || (( numerr++ ))
- require_cmd 'bcdedit.exe' || (( numerr++ ))
- require_cmd 'fsutil.exe' || (( numerr++ ))
- @@ -1130,7 +1212,6 @@ function main
- check_machine_arch || (( numerr++ ))
- #require_cmd 'cdb.exe' || (( numerr++ ))
- require_cmd 'nfsd.exe' || (( numerr++ ))
- - require_cmd 'nfsd_debug.exe' || (( numerr++ ))
- require_cmd 'nfs_mount.exe' || (( numerr++ ))
- require_cmd 'ksh93.exe' || (( numerr++ ))
- require_file '/lib/msnfs41client/cygwin_idmapper.ksh' || (( numerr++ ))
- @@ -1144,7 +1225,6 @@ function main
- #require_cmd 'cdb.exe' || (( numerr++ ))
- require_cmd 'PsExec.exe' || (( numerr++ ))
- require_cmd 'nfsd.exe' || (( numerr++ ))
- - require_cmd 'nfsd_debug.exe' || (( numerr++ ))
- require_cmd 'nfs_mount.exe' || (( numerr++ ))
- require_cmd 'ksh93.exe' || (( numerr++ ))
- require_file '/lib/msnfs41client/cygwin_idmapper.ksh' || (( numerr++ ))
- --
- 2.51.0
- From f0b43078cc68a0031c544c5bcd57f8ca107e31cf Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 24 Sep 2025 19:18:10 +0200
- Subject: [PATCH 2/6] libtirpc: Codepath for |CRITICAL_SECTION|-as-mutex should
- use |spincount=0| on the lock
- Codepath for |CRITICAL_SECTION|-as-mutex should use |spincount=0| on
- the lock, as all users wait for a long time on the mutex anyway.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- libtirpc/tirpc/reentrant.h | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
- diff --git a/libtirpc/tirpc/reentrant.h b/libtirpc/tirpc/reentrant.h
- index 9e6b102..ee25946 100644
- --- a/libtirpc/tirpc/reentrant.h
- +++ b/libtirpc/tirpc/reentrant.h
- @@ -152,7 +152,7 @@
- #define mutex_unlock(m) ReleaseSRWLockExclusive(m)
- #define mutex_trylock(m) TryAcquireSRWLockExclusive(m)
- #else
- -#define mutex_init(m, a) InitializeCriticalSection(m)
- +#define mutex_init(m, a) InitializeCriticalSectionAndSpinCount((m), 0)
- #define mutex_lock(m) EnterCriticalSection(m)
- #define mutex_unlock(m) LeaveCriticalSection(m)
- #define mutex_trylock(m) TryEnterCriticalSection(m)
- --
- 2.51.0
- From 276863a46ae9b256a96f02047c06be420925cc68 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 24 Sep 2025 19:29:00 +0200
- Subject: [PATCH 3/6] cygwin: Use "manual driver install" codepath instead of
- nfs41rdr.inf for Win11/ARM64 support
- Use "manual driver install" codepath instead of nfs41rdr.inf for
- Windows 11/ARM64 support, because our current nfs41rdr.inf fails
- to work on Windows 11/ARM64.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/devel/msnfs41client.bash | 8 ++++++--
- 1 file changed, 6 insertions(+), 2 deletions(-)
- diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
- index 975e089..8d5cfd0 100755
- --- a/cygwin/devel/msnfs41client.bash
- +++ b/cygwin/devel/msnfs41client.bash
- @@ -465,8 +465,6 @@ function nfsclient_disable_autostartservices
- sc config 'ms-nfs41-client-globalmountall-service' start=disabled
- }
- -typeset -r use_nfs41rdrinf=true
- -
- function nfsclient_adddriver
- {
- typeset -i res
- @@ -1349,6 +1347,12 @@ function main
- #
- # main
- #
- +
- +# Our current nfs41rdr.inf file does not work on Windows 11/ARM64,
- +# therefore use the "manual driver install" codepath for now
- +# until we fixed the nfs41rdr.inf
- +typeset -r use_nfs41rdrinf=false
- +
- if [[ -v KSH_VERSION ]] ; then
- #
- # use ksh93 builtins
- --
- 2.51.0
- From 72b7575ad72191efa1d87f32f7bcebf43f0ae320 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 24 Sep 2025 20:55:33 +0200
- Subject: [PATCH 4/6] daemon,sys: Add asserts that all data from kernel are
- read+fix kernel
- Add asserts that all data from kernel are read, and fix related issues
- in the kernel module.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/acl.c | 10 +++++++++-
- daemon/ea.c | 14 ++++++++++++--
- daemon/fsctl.c | 6 ++++++
- daemon/getattr.c | 2 ++
- daemon/lock.c | 4 ++++
- daemon/mount.c | 5 +++++
- daemon/open.c | 6 ++++++
- daemon/readdir.c | 3 +++
- daemon/readwrite.c | 2 ++
- daemon/setattr.c | 3 ++-
- daemon/symlink.c | 4 ++++
- daemon/util.c | 17 +++++++++++++++++
- daemon/util.h | 2 ++
- daemon/volume.c | 2 ++
- sys/nfs41sys_fileinfo.c | 7 ++-----
- sys/nfs41sys_fsctl.c | 2 +-
- 16 files changed, 79 insertions(+), 10 deletions(-)
- diff --git a/daemon/acl.c b/daemon/acl.c
- index 56d297a..7b68f7c 100644
- --- a/daemon/acl.c
- +++ b/daemon/acl.c
- @@ -64,6 +64,8 @@ static int parse_getacl(unsigned char *buffer, uint32_t length,
- status = safe_read(&buffer, &length, &args->query, sizeof(args->query));
- if (status) goto out;
- + EASSERT(length == 0);
- +
- DPRINTF(1, ("parsing NFS41_SYSOP_ACL_QUERY: info_class=%d\n", args->query));
- out:
- return status;
- @@ -521,13 +523,19 @@ static int parse_setacl(unsigned char *buffer, uint32_t length,
- {
- int status;
- setacl_upcall_args *args = &upcall->args.setacl;
- + void *sec_desc_ptr = NULL;
- ULONG sec_desc_len;
- status = safe_read(&buffer, &length, &args->query, sizeof(args->query));
- if (status) goto out;
- status = safe_read(&buffer, &length, &sec_desc_len, sizeof(ULONG));
- if (status) goto out;
- - args->sec_desc = (PSECURITY_DESCRIPTOR)buffer;
- + status = get_safe_read_bufferpos(&buffer, &length, sec_desc_len, &sec_desc_ptr);
- + if (status) goto out;
- +
- + args->sec_desc = (PSECURITY_DESCRIPTOR)sec_desc_ptr;
- +
- + EASSERT(length == 0);
- DPRINTF(1, ("parsing NFS41_SYSOP_ACL_SET: info_class=%d sec_desc_len=%d\n",
- args->query, sec_desc_len));
- diff --git a/daemon/ea.c b/daemon/ea.c
- index a1fb42f..14a2fee 100644
- --- a/daemon/ea.c
- +++ b/daemon/ea.c
- @@ -198,7 +198,9 @@ static int parse_setexattr(unsigned char *buffer, uint32_t length, nfs41_upcall
- if (status) goto out;
- status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len));
- if (status) goto out;
- - args->buf = buffer;
- + status = get_safe_read_bufferpos(&buffer, &length, args->buf_len, &args->buf);
- +
- + EASSERT(length == 0);
- DPRINTF(1, ("parsing NFS41_SYSOP_EA_SET: mode=0%o\n", args->mode));
- out:
- @@ -271,7 +273,15 @@ static int parse_getexattr(unsigned char *buffer, uint32_t length, nfs41_upcall
- if (status) goto out;
- status = safe_read(&buffer, &length, &args->ealist_len, sizeof(args->ealist_len));
- if (status) goto out;
- - args->ealist = args->ealist_len ? buffer : NULL;
- + if (args->ealist_len) {
- + status = get_safe_read_bufferpos(&buffer, &length, args->ealist_len, &args->ealist);
- + if (status) goto out;
- + }
- + else {
- + args->ealist = NULL;
- + }
- +
- + EASSERT(length == 0);
- DPRINTF(1, ("parsing NFS41_SYSOP_EA_GET: buf_len=%d Index %d Restart %d "
- "Single %d\n", args->buf_len,args->eaindex, args->restart, args->single));
- diff --git a/daemon/fsctl.c b/daemon/fsctl.c
- index c730ab2..dbc76f6 100644
- --- a/daemon/fsctl.c
- +++ b/daemon/fsctl.c
- @@ -44,6 +44,8 @@ static int parse_queryallocatedranges(unsigned char *buffer,
- status = safe_read(&buffer, &length, &args->outbuffer, sizeof(args->outbuffer));
- if (status) goto out;
- + EASSERT(length == 0);
- +
- DPRINTF(QARLVL, ("parse_queryallocatedranges: "
- "parsing '%s' inrange=(FileOffset=%lld Length=%lld) "
- "outbuffersize=%lu outbuffer=0x%p\n",
- @@ -327,6 +329,8 @@ static int parse_setzerodata(unsigned char *buffer,
- sizeof(args->setzerodata));
- if (status) goto out;
- + EASSERT(length == 0);
- +
- DPRINTF(SZDLVL, ("parse_setzerodata: "
- "parsing '%s' setzerodata=(FileOffset=%lld BeyondFinalZero=%lld)\n",
- opcode2string(upcall->opcode),
- @@ -453,6 +457,8 @@ static int parse_duplicatedata(unsigned char *buffer,
- sizeof(args->bytecount));
- if (status) goto out;
- + EASSERT(length == 0);
- +
- DPRINTF(DDLVL, ("parse_duplicatedata: "
- "parsing '%s' "
- "duplicatedata=(src_state=0x%p srcfileoffset=%lld "
- diff --git a/daemon/getattr.c b/daemon/getattr.c
- index f057eab..f5622d2 100644
- --- a/daemon/getattr.c
- +++ b/daemon/getattr.c
- @@ -93,6 +93,8 @@ static int parse_getattr(unsigned char *buffer, uint32_t length, nfs41_upcall *u
- status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len));
- if (status) goto out;
- + EASSERT(length == 0);
- +
- DPRINTF(1, ("parsing '%s': "
- "info_class=%d buf_len=%d file='%.*s'\n",
- opcode2string(upcall->opcode),
- diff --git a/daemon/lock.c b/daemon/lock.c
- index efaf40a..0c9a85b 100644
- --- a/daemon/lock.c
- +++ b/daemon/lock.c
- @@ -181,6 +181,8 @@ static int parse_lock(unsigned char *buffer, uint32_t length, nfs41_upcall *upca
- status = safe_read(&buffer, &length, &args->blocking, sizeof(BOOLEAN));
- if (status) goto out;
- + EASSERT(length == 0);
- +
- DPRINTF(1, ("parsing NFS41_SYSOP_LOCK: offset=0x%llx length=0x%llx exclusive=%u "
- "blocking=%u\n", args->offset, args->length, args->exclusive,
- args->blocking));
- @@ -311,6 +313,8 @@ static int parse_unlock(unsigned char *buffer, uint32_t length, nfs41_upcall *up
- status = safe_read(&buffer, &length, &args->count, sizeof(ULONG));
- if (status) goto out;
- + EASSERT(length == 0);
- +
- args->buf = buffer;
- args->buf_len = length;
- diff --git a/daemon/mount.c b/daemon/mount.c
- index 3864b4a..2105375 100644
- --- a/daemon/mount.c
- +++ b/daemon/mount.c
- @@ -64,6 +64,8 @@ static int parse_mount(unsigned char *buffer, uint32_t length, nfs41_upcall *upc
- if (status) goto out;
- #endif /* NFS41_DRIVER_HACK_FORCE_FILENAME_CASE_MOUNTOPTIONS */
- + EASSERT(length == 0);
- +
- #ifdef NFS41_DRIVER_HACK_FORCE_FILENAME_CASE_MOUNTOPTIONS
- DPRINTF(1, ("parsing NFS41_SYSOP_MOUNT: hostport='%s' root='%s' "
- "sec_flavor='%s' rsize=%d wsize=%d use_nfspubfh=%d "
- @@ -347,6 +349,9 @@ const nfs41_upcall_op nfs41_op_mount = {
- static int parse_unmount(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
- {
- DPRINTF(1, ("parsing NFS41_SYSOP_UNMOUNT: root=0x%p\n", upcall->root_ref));
- +
- + EASSERT(length == 0);
- +
- return ERROR_SUCCESS;
- }
- diff --git a/daemon/open.c b/daemon/open.c
- index 593452c..75740ef 100644
- --- a/daemon/open.c
- +++ b/daemon/open.c
- @@ -344,6 +344,10 @@ static int parse_open(unsigned char *buffer, uint32_t length, nfs41_upcall *upca
- status = safe_read(&buffer, &length, &args->ea, sizeof(HANDLE));
- if (status) goto out;
- + EASSERT_MSG((length == 0),
- + ("parse_open: filename='%s' leftover length=%ld\n",
- + args->path, (long)length));
- +
- DPRINTF(1, ("parsing NFS41_SYSOP_OPEN: filename='%s' "
- "isvolumemntpt=%d access mask=%d "
- "access mode=%d\n\tfile attrs=0x%x create attrs=0x%x "
- @@ -1351,6 +1355,8 @@ static int parse_close(unsigned char *buffer, uint32_t length, nfs41_upcall *upc
- if (status) goto out;
- }
- + EASSERT(length == 0);
- +
- DPRINTF(1,
- ("parsing NFS41_SYSOP_CLOSE: "
- "remove=%d srv_open=0x%p renamed=%d "
- diff --git a/daemon/readdir.c b/daemon/readdir.c
- index e7ba90c..83d848e 100644
- --- a/daemon/readdir.c
- +++ b/daemon/readdir.c
- @@ -282,6 +282,9 @@ static int parse_readdir(unsigned char *buffer, uint32_t length, nfs41_upcall *u
- if (status) goto out;
- status = safe_read(&buffer, &length, &args->kbuf, sizeof(args->kbuf));
- if (status) goto out;
- +
- + EASSERT(length == 0);
- +
- args->root = upcall->root_ref;
- args->state = upcall->state_ref;
- diff --git a/daemon/readwrite.c b/daemon/readwrite.c
- index 3c52049..2be92b6 100644
- --- a/daemon/readwrite.c
- +++ b/daemon/readwrite.c
- @@ -50,6 +50,8 @@ static int parse_rw(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall
- status = safe_read(&buffer, &length, &args->buffer, sizeof(args->buffer));
- if (status) goto out;
- + EASSERT(length == 0);
- +
- DPRINTF(1, ("parsing '%s' len=%lu offset=%llu buf=0x%p\n",
- opcode2string(upcall->opcode), args->len, args->offset, args->buffer));
- out:
- diff --git a/daemon/setattr.c b/daemon/setattr.c
- index db45478..9f379f1 100644
- --- a/daemon/setattr.c
- +++ b/daemon/setattr.c
- @@ -53,8 +53,9 @@ static int parse_setattr(unsigned char *buffer, uint32_t length, nfs41_upcall *u
- if (status) goto out;
- status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len));
- if (status) goto out;
- + status = get_safe_read_bufferpos(&buffer, &length, args->buf_len, &args->buf);
- + if (status) goto out;
- - args->buf = buffer;
- args->root = upcall->root_ref;
- args->state = upcall->state_ref;
- diff --git a/daemon/symlink.c b/daemon/symlink.c
- index 0537380..ee12c16 100644
- --- a/daemon/symlink.c
- +++ b/daemon/symlink.c
- @@ -246,6 +246,8 @@ static int parse_symlink_get(unsigned char *buffer, uint32_t length,
- if (status)
- goto out;
- + EASSERT(length == 0);
- +
- args->target_set = NULL;
- DPRINTF(SYMLLVL1,
- @@ -345,6 +347,8 @@ static int parse_symlink_set(unsigned char *buffer, uint32_t length,
- status = get_name(&buffer, &length,
- (const char **)(&args->target_set));
- + EASSERT(length == 0);
- +
- DPRINTF(SYMLLVL1,
- ("parse_symlink_set: parsing NFS41_SYSOP_SYMLINK_SET: "
- "path='%s' target='%s'\n",
- diff --git a/daemon/util.c b/daemon/util.c
- index 37660d2..31cdb4d 100644
- --- a/daemon/util.c
- +++ b/daemon/util.c
- @@ -50,6 +50,23 @@ int safe_read(unsigned char **pos, uint32_t *remaining, void *dest, uint32_t des
- return 0;
- }
- +/*
- + * |get_safe_read_bufferpos()| - like |safe_read()| but tests whether we
- + * have enough buffer space left, and in that case return current buffer
- + * position in |destbuffer|
- + */
- +int get_safe_read_bufferpos(unsigned char **pos, uint32_t *remaining, uint32_t src_len, void **destbuffer)
- +{
- + if (*remaining < src_len)
- + return ERROR_BUFFER_OVERFLOW;
- +
- + *destbuffer = *pos;
- + *pos += src_len;
- + *remaining -= src_len;
- + return ERROR_SUCCESS;
- +}
- +
- +
- int safe_write(unsigned char **pos, uint32_t *remaining, void *src, uint32_t src_len)
- {
- if (*remaining < src_len)
- diff --git a/daemon/util.h b/daemon/util.h
- index 6a7f458..83b925d 100644
- --- a/daemon/util.h
- +++ b/daemon/util.h
- @@ -94,6 +94,8 @@ void *memrchr(const void * restrict s, int c, size_t n)
- }
- int safe_read(unsigned char **pos, uint32_t *remaining, void *dest, uint32_t dest_len);
- +int get_safe_read_bufferpos(unsigned char **pos, uint32_t *remaining,
- + uint32_t src_len, void **destbuffer);
- int safe_write(unsigned char **pos, uint32_t *remaining, void *dest, uint32_t dest_len);
- int get_safe_write_bufferpos(unsigned char **pos, uint32_t *remaining,
- uint32_t src_len, void **destbuffer);
- diff --git a/daemon/volume.c b/daemon/volume.c
- index 3501c6e..2eb29bc 100644
- --- a/daemon/volume.c
- +++ b/daemon/volume.c
- @@ -53,6 +53,8 @@ static int parse_volume(unsigned char *buffer, uint32_t length, nfs41_upcall *up
- status = safe_read(&buffer, &length, &args->query, sizeof(FS_INFORMATION_CLASS));
- if (status) goto out;
- + EASSERT(length == 0);
- +
- DPRINTF(1, ("parsing NFS41_SYSOP_VOLUME_QUERY: query=%d\n", args->query));
- out:
- return status;
- diff --git a/sys/nfs41sys_fileinfo.c b/sys/nfs41sys_fileinfo.c
- index 0b148f8..b4cd89f 100644
- --- a/sys/nfs41sys_fileinfo.c
- +++ b/sys/nfs41sys_fileinfo.c
- @@ -83,7 +83,7 @@ NTSTATUS marshal_nfs41_filequery(
- if (status) goto out;
- else tmp += *len;
- - header_len = *len + 2 * sizeof(ULONG) + 2*sizeof(HANDLE);
- + header_len = *len + 2 * sizeof(ULONG);
- if (header_len > buf_len) {
- status = STATUS_INSUFFICIENT_RESOURCES;
- goto out;
- @@ -91,10 +91,7 @@ NTSTATUS marshal_nfs41_filequery(
- RtlCopyMemory(tmp, &entry->u.QueryFile.InfoClass, sizeof(ULONG));
- tmp += sizeof(ULONG);
- RtlCopyMemory(tmp, &entry->buf_len, sizeof(ULONG));
- - tmp += sizeof(ULONG);
- - RtlCopyMemory(tmp, &entry->session, sizeof(HANDLE));
- - tmp += sizeof(HANDLE);
- - RtlCopyMemory(tmp, &entry->open_state, sizeof(HANDLE));
- + /* tmp += sizeof(ULONG); */
- *len = header_len;
- #ifdef DEBUG_MARSHAL_DETAIL
- diff --git a/sys/nfs41sys_fsctl.c b/sys/nfs41sys_fsctl.c
- index b65d35b..8f25517 100644
- --- a/sys/nfs41sys_fsctl.c
- +++ b/sys/nfs41sys_fsctl.c
- @@ -256,7 +256,7 @@ NTSTATUS marshal_nfs41_queryallocatedranges(
- else tmp += *len;
- header_len = *len + sizeof(FILE_ALLOCATED_RANGE_BUFFER) +
- - sizeof(LONGLONG) +
- + sizeof(ULONG) +
- sizeof(HANDLE);
- if (header_len > buf_len) {
- status = STATUS_INSUFFICIENT_RESOURCES;
- --
- 2.51.0
- From 28b1ca4505a257f32fd7ec249f0de2c5cc2363a8 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 24 Sep 2025 21:25:37 +0200
- Subject: [PATCH 5/6] daemon:
- |get_safe_read_bufferpos()|+|get_write_read_bufferpos()| should return |NULL|
- ptr if |len==0|
- |get_safe_read_bufferpos()|+|get_write_read_bufferpos()| should return
- |NULL| pointer if |len==0|.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/acl.c | 8 +++++++-
- daemon/ea.c | 15 ++++++++-------
- daemon/setattr.c | 6 ++++++
- daemon/util.c | 4 ++--
- 4 files changed, 23 insertions(+), 10 deletions(-)
- diff --git a/daemon/acl.c b/daemon/acl.c
- index 7b68f7c..b56266c 100644
- --- a/daemon/acl.c
- +++ b/daemon/acl.c
- @@ -523,7 +523,7 @@ static int parse_setacl(unsigned char *buffer, uint32_t length,
- {
- int status;
- setacl_upcall_args *args = &upcall->args.setacl;
- - void *sec_desc_ptr = NULL;
- + void *sec_desc_ptr;
- ULONG sec_desc_len;
- status = safe_read(&buffer, &length, &args->query, sizeof(args->query));
- @@ -1437,6 +1437,12 @@ static int handle_setacl(void *daemon_context, nfs41_upcall *upcall)
- DPRINTF(ACLLVL1, ("--> handle_setacl(state->path.path='%s')\n",
- state->path.path));
- + if (args->sec_desc == NULL) {
- + eprintf("handle_setacl: args->sec_desc==NULL\n");
- + status = ERROR_INVALID_PARAMETER;
- + goto out;
- + }
- +
- if (args->query & OWNER_SECURITY_INFORMATION) {
- DPRINTF(ACLLVL2, ("handle_setacl: OWNER_SECURITY_INFORMATION\n"));
- status = GetSecurityDescriptorOwner(args->sec_desc, &sid, &sid_default);
- diff --git a/daemon/ea.c b/daemon/ea.c
- index 14a2fee..0915790 100644
- --- a/daemon/ea.c
- +++ b/daemon/ea.c
- @@ -215,6 +215,12 @@ static int handle_setexattr(void *daemon_context, nfs41_upcall *upcall)
- PFILE_FULL_EA_INFORMATION ea =
- (PFILE_FULL_EA_INFORMATION)args->buf;
- + if (ea == NULL) {
- + eprintf("handle_setexattr: ea==NULL\n");
- + status = ERROR_INVALID_PARAMETER;
- + goto out;
- + }
- +
- /* break read delegations before SETATTR */
- nfs41_delegation_return(state->session, &state->file,
- OPEN_DELEGATE_READ, FALSE);
- @@ -273,13 +279,8 @@ static int parse_getexattr(unsigned char *buffer, uint32_t length, nfs41_upcall
- if (status) goto out;
- status = safe_read(&buffer, &length, &args->ealist_len, sizeof(args->ealist_len));
- if (status) goto out;
- - if (args->ealist_len) {
- - status = get_safe_read_bufferpos(&buffer, &length, args->ealist_len, &args->ealist);
- - if (status) goto out;
- - }
- - else {
- - args->ealist = NULL;
- - }
- + status = get_safe_read_bufferpos(&buffer, &length, args->ealist_len, &args->ealist);
- + if (status) goto out;
- EASSERT(length == 0);
- diff --git a/daemon/setattr.c b/daemon/setattr.c
- index 9f379f1..c6933d4 100644
- --- a/daemon/setattr.c
- +++ b/daemon/setattr.c
- @@ -78,6 +78,12 @@ static int handle_nfs41_setattr_basicinfo(void *daemon_context, setattr_upcall_a
- (void)memset(&info, 0, sizeof(info));
- (void)memset(&old_info, 0, sizeof(old_info));
- + if (basic_info == NULL) {
- + eprintf("handle_nfs41_setattr_basicinfo: basic_info==NULL\n");
- + status = ERROR_INVALID_PARAMETER;
- + goto out;
- + }
- +
- getattr_status = nfs41_cached_getattr(state->session,
- &state->file, NULL, &old_info);
- if (getattr_status) {
- diff --git a/daemon/util.c b/daemon/util.c
- index 31cdb4d..6e26e83 100644
- --- a/daemon/util.c
- +++ b/daemon/util.c
- @@ -60,7 +60,7 @@ int get_safe_read_bufferpos(unsigned char **pos, uint32_t *remaining, uint32_t s
- if (*remaining < src_len)
- return ERROR_BUFFER_OVERFLOW;
- - *destbuffer = *pos;
- + *destbuffer = (src_len == 0)?NULL:*pos;
- *pos += src_len;
- *remaining -= src_len;
- return ERROR_SUCCESS;
- @@ -88,7 +88,7 @@ int get_safe_write_bufferpos(unsigned char **pos, uint32_t *remaining, uint32_t
- if (*remaining < src_len)
- return ERROR_BUFFER_OVERFLOW;
- - *destbuffer = *pos;
- + *destbuffer = (src_len == 0)?NULL:*pos;
- *pos += src_len;
- *remaining -= src_len;
- return ERROR_SUCCESS;
- --
- 2.51.0
- From 20780dfa45f7c808ad1696a8cf2f7c20ba6a8820 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 24 Sep 2025 21:34:30 +0200
- Subject: [PATCH 6/6] daemon: Fix
- |get_safe_read_bufferpos()|+|get_safe_write_bufferpos()| caller error
- handling
- Fix |get_safe_read_bufferpos()|+|get_safe_write_bufferpos()| caller error
- handling.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/ea.c | 1 +
- daemon/open.c | 1 +
- daemon/symlink.c | 2 ++
- 3 files changed, 4 insertions(+)
- diff --git a/daemon/ea.c b/daemon/ea.c
- index 0915790..795e242 100644
- --- a/daemon/ea.c
- +++ b/daemon/ea.c
- @@ -199,6 +199,7 @@ static int parse_setexattr(unsigned char *buffer, uint32_t length, nfs41_upcall
- status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len));
- if (status) goto out;
- status = get_safe_read_bufferpos(&buffer, &length, args->buf_len, &args->buf);
- + if (status) goto out;
- EASSERT(length == 0);
- diff --git a/daemon/open.c b/daemon/open.c
- index 75740ef..953fa49 100644
- --- a/daemon/open.c
- +++ b/daemon/open.c
- @@ -1263,6 +1263,7 @@ static int marshall_open(unsigned char *buffer, uint32_t *length, nfs41_upcall *
- status = get_safe_write_bufferpos(&buffer, length,
- sizeof(unsigned short), &wc_len_out);
- if (status) goto out;
- + EASSERT(wc_len_out != NULL);
- if (*length <= len) {
- status = ERROR_BUFFER_OVERFLOW;
- diff --git a/daemon/symlink.c b/daemon/symlink.c
- index ee12c16..5722b72 100644
- --- a/daemon/symlink.c
- +++ b/daemon/symlink.c
- @@ -296,6 +296,8 @@ static int marshall_symlink_get(unsigned char *buffer, uint32_t *length,
- unsigned short *wc_len_out;
- status = get_safe_write_bufferpos(&buffer, length,
- sizeof(unsigned short), &wc_len_out);
- + if (status) goto out;
- + EASSERT(wc_len_out != NULL);
- if (*length <= len) {
- status = ERROR_BUFFER_OVERFLOW;
- --
- 2.51.0
msnfs41client: Patches for install refactoring to support any platform, ARM64 platform fixes, kernel2userland buffer fixes, cleanup+misc, 2025-09-24
Posted by Anonymous on Wed 24th Sep 2025 20:43
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.