- From ce00adbaf85ebd004584ccb5ed423a102b0cad6c Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 4 Feb 2025 14:10:46 +0100
- Subject: [PATCH 1/6] build.vc19: Sync debug+release compiler options between
- platforms
- Sync debug+release compiler options between platforms, so all
- platforms uniformly use the same compiler flags.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- build.vc19/libtirpc/libtirpc.vcxproj | 26 +++++++++++++++++---
- build.vc19/nfs41_driver/nfs41_driver.vcxproj | 15 +++++++++++
- build.vc19/nfs41_np/nfs41_np.vcxproj | 13 ++++++++++
- build.vc19/nfsd/nfsd.vcxproj | 22 +++++++++++++++--
- 4 files changed, 71 insertions(+), 5 deletions(-)
- diff --git a/build.vc19/libtirpc/libtirpc.vcxproj b/build.vc19/libtirpc/libtirpc.vcxproj
- index c6ba375..e9234ff 100644
- --- a/build.vc19/libtirpc/libtirpc.vcxproj
- +++ b/build.vc19/libtirpc/libtirpc.vcxproj
- @@ -129,6 +129,9 @@
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- <AdditionalOptions>/wd4100 /wd4131 /wd4389</AdditionalOptions>
- <SupportJustMyCode>false</SupportJustMyCode>
- + <OmitFramePointers>false</OmitFramePointers>
- + <IntrinsicFunctions>true</IntrinsicFunctions>
- + <WholeProgramOptimization>false</WholeProgramOptimization>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- @@ -153,6 +156,8 @@
- <AdditionalOptions>/wd4100 /wd4131 /wd4389</AdditionalOptions>
- <SupportJustMyCode>false</SupportJustMyCode>
- <OmitFramePointers>false</OmitFramePointers>
- + <IntrinsicFunctions>true</IntrinsicFunctions>
- + <WholeProgramOptimization>false</WholeProgramOptimization>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- @@ -176,6 +181,8 @@
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- <AdditionalOptions>/wd4100 /wd4131 /wd4389</AdditionalOptions>
- <SupportJustMyCode>false</SupportJustMyCode>
- + <IntrinsicFunctions>true</IntrinsicFunctions>
- + <WholeProgramOptimization>false</WholeProgramOptimization>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- @@ -191,7 +198,6 @@
- </PrecompiledHeader>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- - <IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;NDEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\libtirpc\tirpc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- @@ -199,6 +205,11 @@
- <BufferSecurityCheck>false</BufferSecurityCheck>
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
- <AdditionalOptions>/wd4100 /wd4131 /wd4389</AdditionalOptions>
- + <OmitFramePointers>false</OmitFramePointers>
- + <IntrinsicFunctions>true</IntrinsicFunctions>
- + <WholeProgramOptimization>true</WholeProgramOptimization>
- + <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
- + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- @@ -207,6 +218,7 @@
- <OptimizeReferences>true</OptimizeReferences>
- <AdditionalDependencies>ws2_32.lib;secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>..\..\libtirpc\libtirpc\libtirpc.def</ModuleDefinitionFile>
- + <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- @@ -216,7 +228,6 @@
- </PrecompiledHeader>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- - <IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;NDEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\libtirpc\tirpc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- @@ -225,6 +236,10 @@
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
- <AdditionalOptions>/wd4100 /wd4131 /wd4389</AdditionalOptions>
- <OmitFramePointers>false</OmitFramePointers>
- + <IntrinsicFunctions>true</IntrinsicFunctions>
- + <WholeProgramOptimization>true</WholeProgramOptimization>
- + <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
- + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- @@ -233,6 +248,7 @@
- <OptimizeReferences>true</OptimizeReferences>
- <AdditionalDependencies>ws2_32.lib;secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>..\..\libtirpc\libtirpc\libtirpc.def</ModuleDefinitionFile>
- + <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
- @@ -241,7 +257,6 @@
- <PrecompiledHeader>
- </PrecompiledHeader>
- <Optimization>MaxSpeed</Optimization>
- - <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;NDEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\libtirpc\tirpc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- @@ -250,6 +265,10 @@
- <BufferSecurityCheck>false</BufferSecurityCheck>
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
- <AdditionalOptions>/wd4100 /wd4131 /wd4389</AdditionalOptions>
- + <IntrinsicFunctions>true</IntrinsicFunctions>
- + <WholeProgramOptimization>true</WholeProgramOptimization>
- + <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
- + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- @@ -258,6 +277,7 @@
- <OptimizeReferences>true</OptimizeReferences>
- <AdditionalDependencies>ws2_32.lib;secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>..\..\libtirpc\libtirpc\libtirpc.def</ModuleDefinitionFile>
- + <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- diff --git a/build.vc19/nfs41_driver/nfs41_driver.vcxproj b/build.vc19/nfs41_driver/nfs41_driver.vcxproj
- index bd97fb1..afd079e 100644
- --- a/build.vc19/nfs41_driver/nfs41_driver.vcxproj
- +++ b/build.vc19/nfs41_driver/nfs41_driver.vcxproj
- @@ -114,6 +114,8 @@
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <StringPooling>true</StringPooling>
- <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
- + <IntrinsicFunctions>true</IntrinsicFunctions>
- + <WholeProgramOptimization>false</WholeProgramOptimization>
- </ClCompile>
- <Link>
- <AdditionalDependencies>$(DDK_LIB_PATH)\ntoskrnl.lib;$(DDK_LIB_PATH)\hal.lib;$(DDK_LIB_PATH)\BufferOverflowfastfailK.lib;$(DDK_LIB_PATH)\ksecdd.lib;$(DDK_LIB_PATH)\rxce.lib;$(DDK_LIB_PATH)\rdbsslib.lib</AdditionalDependencies>
- @@ -128,9 +130,12 @@
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <StringPooling>true</StringPooling>
- <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
- + <IntrinsicFunctions>true</IntrinsicFunctions>
- + <WholeProgramOptimization>true</WholeProgramOptimization>
- </ClCompile>
- <Link>
- <AdditionalDependencies>$(DDK_LIB_PATH)\ntoskrnl.lib;$(DDK_LIB_PATH)\hal.lib;$(DDK_LIB_PATH)\BufferOverflowfastfailK.lib;$(DDK_LIB_PATH)\ksecdd.lib;$(DDK_LIB_PATH)\rxce.lib;$(DDK_LIB_PATH)\rdbsslib.lib</AdditionalDependencies>
- + <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- @@ -142,6 +147,8 @@
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <StringPooling>true</StringPooling>
- <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
- + <IntrinsicFunctions>true</IntrinsicFunctions>
- + <WholeProgramOptimization>false</WholeProgramOptimization>
- </ClCompile>
- <Link>
- <AdditionalDependencies>$(DDK_LIB_PATH)\ntoskrnl.lib;$(DDK_LIB_PATH)\hal.lib;$(DDK_LIB_PATH)\BufferOverflowfastfailK.lib;$(DDK_LIB_PATH)\ksecdd.lib;$(DDK_LIB_PATH)\rxce.lib;$(DDK_LIB_PATH)\rdbsslib.lib</AdditionalDependencies>
- @@ -159,9 +166,12 @@
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <StringPooling>true</StringPooling>
- <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
- + <IntrinsicFunctions>true</IntrinsicFunctions>
- + <WholeProgramOptimization>true</WholeProgramOptimization>
- </ClCompile>
- <Link>
- <AdditionalDependencies>$(DDK_LIB_PATH)\ntoskrnl.lib;$(DDK_LIB_PATH)\hal.lib;$(DDK_LIB_PATH)\BufferOverflowfastfailK.lib;$(DDK_LIB_PATH)\ksecdd.lib;$(DDK_LIB_PATH)\rxce.lib;$(DDK_LIB_PATH)\rdbsslib.lib</AdditionalDependencies>
- + <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
- </Link>
- <DriverSign>
- <FileDigestAlgorithm>sha256</FileDigestAlgorithm>
- @@ -176,6 +186,8 @@
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <StringPooling>true</StringPooling>
- <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
- + <IntrinsicFunctions>true</IntrinsicFunctions>
- + <WholeProgramOptimization>false</WholeProgramOptimization>
- </ClCompile>
- <Link>
- <AdditionalDependencies>$(DDK_LIB_PATH)\ntoskrnl.lib;$(DDK_LIB_PATH)\hal.lib;$(DDK_LIB_PATH)\BufferOverflowfastfailK.lib;$(DDK_LIB_PATH)\ksecdd.lib;$(DDK_LIB_PATH)\rxce.lib;$(DDK_LIB_PATH)\rdbsslib.lib</AdditionalDependencies>
- @@ -193,9 +205,12 @@
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <StringPooling>true</StringPooling>
- <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
- + <IntrinsicFunctions>true</IntrinsicFunctions>
- + <WholeProgramOptimization>true</WholeProgramOptimization>
- </ClCompile>
- <Link>
- <AdditionalDependencies>$(DDK_LIB_PATH)\ntoskrnl.lib;$(DDK_LIB_PATH)\hal.lib;$(DDK_LIB_PATH)\BufferOverflowfastfailK.lib;$(DDK_LIB_PATH)\ksecdd.lib;$(DDK_LIB_PATH)\rxce.lib;$(DDK_LIB_PATH)\rdbsslib.lib</AdditionalDependencies>
- + <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
- </Link>
- <DriverSign>
- <FileDigestAlgorithm>sha256</FileDigestAlgorithm>
- diff --git a/build.vc19/nfs41_np/nfs41_np.vcxproj b/build.vc19/nfs41_np/nfs41_np.vcxproj
- index c61e65a..89cb2e3 100644
- --- a/build.vc19/nfs41_np/nfs41_np.vcxproj
- +++ b/build.vc19/nfs41_np/nfs41_np.vcxproj
- @@ -37,6 +37,7 @@
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v142</PlatformToolset>
- + <WholeProgramOptimization>false</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- @@ -50,6 +51,7 @@
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v142</PlatformToolset>
- + <WholeProgramOptimization>false</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- @@ -63,6 +65,7 @@
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v142</PlatformToolset>
- + <WholeProgramOptimization>false</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
- @@ -126,6 +129,8 @@
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- <AdditionalOptions>/wd4100</AdditionalOptions>
- <SupportJustMyCode>false</SupportJustMyCode>
- + <IntrinsicFunctions>true</IntrinsicFunctions>
- + <OmitFramePointers>false</OmitFramePointers>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- @@ -145,6 +150,8 @@
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- <AdditionalOptions>/wd4100</AdditionalOptions>
- <SupportJustMyCode>false</SupportJustMyCode>
- + <IntrinsicFunctions>true</IntrinsicFunctions>
- + <OmitFramePointers>false</OmitFramePointers>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- @@ -164,6 +171,7 @@
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- <AdditionalOptions>/wd4100</AdditionalOptions>
- <SupportJustMyCode>false</SupportJustMyCode>
- + <IntrinsicFunctions>true</IntrinsicFunctions>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- @@ -184,6 +192,7 @@
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
- <AdditionalOptions>/wd4100</AdditionalOptions>
- + <OmitFramePointers>false</OmitFramePointers>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- @@ -191,6 +200,7 @@
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <ModuleDefinitionFile>..\..\dll\nfs41_np.def</ModuleDefinitionFile>
- + <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- @@ -206,6 +216,7 @@
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
- <AdditionalOptions>/wd4100</AdditionalOptions>
- + <OmitFramePointers>false</OmitFramePointers>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- @@ -213,6 +224,7 @@
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <ModuleDefinitionFile>..\..\dll\nfs41_np.def</ModuleDefinitionFile>
- + <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
- @@ -235,6 +247,7 @@
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <ModuleDefinitionFile>..\..\dll\nfs41_np.def</ModuleDefinitionFile>
- + <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- diff --git a/build.vc19/nfsd/nfsd.vcxproj b/build.vc19/nfsd/nfsd.vcxproj
- index c871777..3005f90 100644
- --- a/build.vc19/nfsd/nfsd.vcxproj
- +++ b/build.vc19/nfsd/nfsd.vcxproj
- @@ -135,6 +135,9 @@
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- <AdditionalOptions>/wd4100</AdditionalOptions>
- <SupportJustMyCode>false</SupportJustMyCode>
- + <IntrinsicFunctions>true</IntrinsicFunctions>
- + <WholeProgramOptimization>false</WholeProgramOptimization>
- + <FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- @@ -158,6 +161,9 @@
- <AdditionalOptions>/wd4100</AdditionalOptions>
- <SupportJustMyCode>false</SupportJustMyCode>
- <OmitFramePointers>false</OmitFramePointers>
- + <IntrinsicFunctions>true</IntrinsicFunctions>
- + <WholeProgramOptimization>false</WholeProgramOptimization>
- + <FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- @@ -170,7 +176,7 @@
- <PrecompiledHeader>
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- - <Optimization>MaxSpeed</Optimization>
- + <Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;STANDALONE_NFSD;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;_CRT_STDIO_ISO_WIDE_SPECIFIERS=1;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\include;..\..\libtirpc\tirpc;..\..\dll;..\..;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <LanguageStandard_C>stdc17</LanguageStandard_C>
- @@ -181,7 +187,8 @@
- <AdditionalOptions>/wd4100</AdditionalOptions>
- <SupportJustMyCode>false</SupportJustMyCode>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- - <WholeProgramOptimization>true</WholeProgramOptimization>
- + <WholeProgramOptimization>false</WholeProgramOptimization>
- + <FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- @@ -204,6 +211,9 @@
- <StringPooling>true</StringPooling>
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
- <AdditionalOptions>/wd4100</AdditionalOptions>
- + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
- + <WholeProgramOptimization>true</WholeProgramOptimization>
- + <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- @@ -211,6 +221,7 @@
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <AdditionalDependencies>iphlpapi.lib;ws2_32.lib;wldap32.lib;ntdll.lib;..\$(Configuration)\libtirpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
- + <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- @@ -229,6 +240,9 @@
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
- <AdditionalOptions>/wd4100</AdditionalOptions>
- <OmitFramePointers>false</OmitFramePointers>
- + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
- + <WholeProgramOptimization>true</WholeProgramOptimization>
- + <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- @@ -236,6 +250,7 @@
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <AdditionalDependencies>iphlpapi.lib;ws2_32.lib;wldap32.lib;ntdll.lib;..\$(Platform)\$(Configuration)\libtirpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
- + <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
- @@ -253,6 +268,8 @@
- <StringPooling>true</StringPooling>
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
- <AdditionalOptions>/wd4100</AdditionalOptions>
- + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
- + <WholeProgramOptimization>true</WholeProgramOptimization>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- @@ -260,6 +277,7 @@
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <AdditionalDependencies>iphlpapi.lib;ws2_32.lib;wldap32.lib;ntdll.lib;..\$(Platform)\$(Configuration)\libtirpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
- + <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- --
- 2.45.1
- From 74b9b0c58c75153a510577b1cc878762bf15dddc Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 4 Feb 2025 14:11:51 +0100
- Subject: [PATCH 2/6] sys: Implement |nfs41_AreFilesAliased()|
- Implement |nfs41_AreFilesAliased()|, now that we have the
- fileid+fsid information available in the kernel.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41sys_driver.c | 33 ++++++++++++++++++++++++++++++---
- 1 file changed, 30 insertions(+), 3 deletions(-)
- diff --git a/sys/nfs41sys_driver.c b/sys/nfs41sys_driver.c
- index dd7975c..9457ddb 100644
- --- a/sys/nfs41sys_driver.c
- +++ b/sys/nfs41sys_driver.c
- @@ -1009,9 +1009,36 @@ NTSTATUS nfs41_AreFilesAliased(
- PFCB a,
- PFCB b)
- {
- - DbgP("nfs41_AreFilesAliased: a=0x%p b=0x%p\n",
- - (void *)a, (void *)b);
- - return STATUS_NOT_IMPLEMENTED;
- + __notnull PNFS41_FCB nfs41_fcb_a = (PNFS41_FCB)a;
- + __notnull PNFS41_FCB nfs41_fcb_b = (PNFS41_FCB)b;
- +
- + if ((nfs41_fcb_a->fileid == nfs41_fcb_b->fileid) &&
- + (nfs41_fcb_a->fsid_major == nfs41_fcb_b->fsid_major) &&
- + (nfs41_fcb_a->fsid_minor == nfs41_fcb_b->fsid_minor)) {
- +
- + DbgP("nfs41_AreFilesAliased: "
- + "a=0x%p b=0x%p aliases, fileid=0x%llx "
- + "fsid_major=0x%llx fsid_minor=0x%llx\n",
- + (void *)a, (void *)b,
- + (long long)nfs41_fcb_a->fileid,
- + (long long)nfs41_fcb_a->fsid_major,
- + (long long)nfs41_fcb_a->fsid_minor);
- + return STATUS_MORE_PROCESSING_REQUIRED;
- + }
- + else {
- + DbgP("nfs41_AreFilesAliased: "
- + "a=0x%p b=0x%p NOT aliases, "
- + "a=(fileid=0x%llx fsid_major=0x%llx fsid_minor=0x%llx) "
- + "b=(fileid=0x%llx fsid_major=0x%llx fsid_minor=0x%llx)\n",
- + (void *)a, (void *)b,
- + (long long)nfs41_fcb_a->fileid,
- + (long long)nfs41_fcb_a->fsid_major,
- + (long long)nfs41_fcb_a->fsid_minor,
- + (long long)nfs41_fcb_b->fileid,
- + (long long)nfs41_fcb_b->fsid_major,
- + (long long)nfs41_fcb_b->fsid_minor);
- + return STATUS_SUCCESS;
- + }
- }
- static
- --
- 2.45.1
- From d30bdfc7a74b643485fdb77b2c6360fb6e540556 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 5 Feb 2025 11:22:15 +0100
- Subject: [PATCH 3/6] daemon,include,sys: Split |NFS41_SYSOP_SYMLINK| into
- |*GET|/|*SET|
- Split |NFS41_SYSOP_SYMLINK| into |NFS41_SYSOP_SYMLINK_GET| and
- |NFS41_SYSOP_SYMLINK_SET|
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/daemon_debug.c | 6 ++++--
- daemon/symlink.c | 45 +++++++++++++++++++++++++++++----------
- daemon/upcall.c | 9 +++++---
- daemon/upcall.h | 1 -
- include/nfs41_driver.h | 5 +++--
- sys/nfs41sys_debug.c | 6 ++++--
- sys/nfs41sys_driver.h | 1 -
- sys/nfs41sys_ea.c | 5 ++---
- sys/nfs41sys_symlink.c | 35 +++++++++++++++++-------------
- sys/nfs41sys_updowncall.c | 8 ++++---
- 10 files changed, 78 insertions(+), 43 deletions(-)
- diff --git a/daemon/daemon_debug.c b/daemon/daemon_debug.c
- index 74f26bc..0a027ac 100644
- --- a/daemon/daemon_debug.c
- +++ b/daemon/daemon_debug.c
- @@ -1,5 +1,6 @@
- /* NFSv4.1 client for Windows
- - * Copyright (C) 2012 The Regents of the University of Michigan
- + * Copyright (C) 2012 The Regents of the University of Michigan
- + * Copyright (C) 2023-2025 Roland Mainz <roland.mainz@nrubsig.org>
- *
- * Olga Kornievskaia <aglo@umich.edu>
- * Casey Bodley <cbodley@umich.edu>
- @@ -460,7 +461,8 @@ const char* opcode2string(nfs41_opcodes opcode)
- NFSOPCODE_TO_STRLITERAL(NFS41_SYSOP_FILE_SET)
- NFSOPCODE_TO_STRLITERAL(NFS41_SYSOP_EA_SET)
- NFSOPCODE_TO_STRLITERAL(NFS41_SYSOP_EA_GET)
- - NFSOPCODE_TO_STRLITERAL(NFS41_SYSOP_SYMLINK)
- + NFSOPCODE_TO_STRLITERAL(NFS41_SYSOP_SYMLINK_GET)
- + NFSOPCODE_TO_STRLITERAL(NFS41_SYSOP_SYMLINK_SET)
- NFSOPCODE_TO_STRLITERAL(NFS41_SYSOP_VOLUME_QUERY)
- NFSOPCODE_TO_STRLITERAL(NFS41_SYSOP_ACL_QUERY)
- NFSOPCODE_TO_STRLITERAL(NFS41_SYSOP_ACL_SET)
- diff --git a/daemon/symlink.c b/daemon/symlink.c
- index 87be302..b601f01 100644
- --- a/daemon/symlink.c
- +++ b/daemon/symlink.c
- @@ -1,8 +1,10 @@
- /* NFSv4.1 client for Windows
- - * Copyright (C) 2012 The Regents of the University of Michigan
- + * Copyright (C) 2012 The Regents of the University of Michigan
- + * Copyright (C) 2023-2025 Roland Mainz <roland.mainz@nrubsig.org>
- *
- * Olga Kornievskaia <aglo@umich.edu>
- * Casey Bodley <cbodley@umich.edu>
- + * Roland Mainz <roland.mainz@nrubsig.org>
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- @@ -22,6 +24,7 @@
- #include <Windows.h>
- #include <strsafe.h>
- +#include "nfs41_driver.h"
- #include "nfs41_ops.h"
- #include "upcall.h"
- #include "util.h"
- @@ -186,7 +189,7 @@ out:
- }
- -/* NFS41_SYSOP_SYMLINK */
- +/* NFS41_SYSOP_SYMLINK_GET, NFS41_SYSOP_SYMLINK_SET */
- static int parse_symlink(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
- {
- symlink_upcall_args *args = &upcall->args.symlink;
- @@ -194,21 +197,34 @@ static int parse_symlink(unsigned char *buffer, uint32_t length, nfs41_upcall *u
- status = get_name(&buffer, &length, &args->path);
- if (status) goto out;
- - status = safe_read(&buffer, &length, &args->set, sizeof(BOOLEAN));
- - if (status) goto out;
- - if (args->set)
- + if (upcall->opcode == NFS41_SYSOP_SYMLINK_SET) {
- /*
- * args->target_set is not const because handle_symlink() might
- * have to replace '\\' with '/'
- */
- status = get_name(&buffer, &length,
- (const char **)(&args->target_set));
- - else
- +
- + DPRINTF(1,
- + ("parsing NFS41_SYSOP_SYMLINK_SET: "
- + "path='%s' target='%s'\n",
- + args->path, args->target_set));
- + }
- + else if (upcall->opcode == NFS41_SYSOP_SYMLINK_GET) {
- args->target_set = NULL;
- - DPRINTF(1, ("parsing NFS41_SYSOP_SYMLINK: path='%s' set=%u target='%s'\n",
- - args->path, args->set, args->target_set));
- + DPRINTF(1,
- + ("parsing NFS41_SYSOP_SYMLINK_GET: "
- + "path='%s' target='%s'\n",
- + args->path, args->target_set));
- + }
- + else {
- + status = ERROR_INVALID_PARAMETER;
- + eprintf("parse_symlink: Unknown upcall->opcode=%d\n",
- + (int)upcall->opcode);
- + }
- +
- out:
- return status;
- }
- @@ -219,7 +235,7 @@ static int handle_symlink(void *daemon_context, nfs41_upcall *upcall)
- nfs41_open_state *state = upcall->state_ref;
- int status = NO_ERROR;
- - if (args->set) {
- + if (upcall->opcode == NFS41_SYSOP_SYMLINK_SET) {
- nfs41_file_info info, createattrs;
- /* don't send windows slashes to the server */
- @@ -280,7 +296,7 @@ static int marshall_symlink(unsigned char *buffer, uint32_t *length, nfs41_upcal
- unsigned short len = (args->target_get.len + 1) * sizeof(WCHAR);
- int status = NO_ERROR;
- - if (args->set)
- + if (upcall->opcode == NFS41_SYSOP_SYMLINK_SET)
- goto out;
- status = safe_write(&buffer, length, &len, sizeof(len));
- @@ -306,7 +322,14 @@ out:
- }
- -const nfs41_upcall_op nfs41_op_symlink = {
- +const nfs41_upcall_op nfs41_op_symlink_get = {
- + .parse = parse_symlink,
- + .handle = handle_symlink,
- + .marshall = marshall_symlink,
- + .arg_size = sizeof(symlink_upcall_args)
- +};
- +
- +const nfs41_upcall_op nfs41_op_symlink_set = {
- .parse = parse_symlink,
- .handle = handle_symlink,
- .marshall = marshall_symlink,
- diff --git a/daemon/upcall.c b/daemon/upcall.c
- index 67d6ef3..40cfdea 100644
- --- a/daemon/upcall.c
- +++ b/daemon/upcall.c
- @@ -1,5 +1,6 @@
- /* NFSv4.1 client for Windows
- - * Copyright (C) 2012 The Regents of the University of Michigan
- + * Copyright (C) 2012 The Regents of the University of Michigan
- + * Copyright (C) 2023-2025 Roland Mainz <roland.mainz@nrubsig.org>
- *
- * Olga Kornievskaia <aglo@umich.edu>
- * Casey Bodley <cbodley@umich.edu>
- @@ -43,7 +44,8 @@ extern const nfs41_upcall_op nfs41_op_getattr;
- extern const nfs41_upcall_op nfs41_op_setattr;
- extern const nfs41_upcall_op nfs41_op_getexattr;
- extern const nfs41_upcall_op nfs41_op_setexattr;
- -extern const nfs41_upcall_op nfs41_op_symlink;
- +extern const nfs41_upcall_op nfs41_op_symlink_get;
- +extern const nfs41_upcall_op nfs41_op_symlink_set;
- extern const nfs41_upcall_op nfs41_op_volume;
- extern const nfs41_upcall_op nfs41_op_getacl;
- extern const nfs41_upcall_op nfs41_op_setacl;
- @@ -65,7 +67,8 @@ static const nfs41_upcall_op *g_upcall_op_table[] = {
- &nfs41_op_setattr,
- &nfs41_op_getexattr,
- &nfs41_op_setexattr,
- - &nfs41_op_symlink,
- + &nfs41_op_symlink_get,
- + &nfs41_op_symlink_set,
- &nfs41_op_volume,
- &nfs41_op_getacl,
- &nfs41_op_setacl,
- diff --git a/daemon/upcall.h b/daemon/upcall.h
- index e601e3b..982471e 100644
- --- a/daemon/upcall.h
- +++ b/daemon/upcall.h
- @@ -161,7 +161,6 @@ typedef struct __symlink_upcall_args {
- nfs41_abs_path target_get;
- char *target_set;
- const char *path;
- - BOOLEAN set;
- } symlink_upcall_args;
- typedef struct __volume_upcall_args {
- diff --git a/include/nfs41_driver.h b/include/nfs41_driver.h
- index 8b569d0..bddf5cc 100644
- --- a/include/nfs41_driver.h
- +++ b/include/nfs41_driver.h
- @@ -1,6 +1,6 @@
- /* NFSv4.1 client for Windows
- * Copyright (C) 2012 The Regents of the University of Michigan
- - * Copyright (C) 2023-2024 Roland Mainz <roland.mainz@nrubsig.org>
- + * Copyright (C) 2023-2025 Roland Mainz <roland.mainz@nrubsig.org>
- *
- * Olga Kornievskaia <aglo@umich.edu>
- * Casey Bodley <cbodley@umich.edu>
- @@ -77,7 +77,8 @@ typedef enum _nfs41_opcodes {
- NFS41_SYSOP_FILE_SET,
- NFS41_SYSOP_EA_GET,
- NFS41_SYSOP_EA_SET,
- - NFS41_SYSOP_SYMLINK,
- + NFS41_SYSOP_SYMLINK_GET,
- + NFS41_SYSOP_SYMLINK_SET,
- NFS41_SYSOP_VOLUME_QUERY,
- NFS41_SYSOP_ACL_QUERY,
- NFS41_SYSOP_ACL_SET,
- diff --git a/sys/nfs41sys_debug.c b/sys/nfs41sys_debug.c
- index 8706565..33b801c 100644
- --- a/sys/nfs41sys_debug.c
- +++ b/sys/nfs41sys_debug.c
- @@ -1,5 +1,6 @@
- /* NFSv4.1 client for Windows
- - * Copyright (C) 2012 The Regents of the University of Michigan
- + * Copyright (C) 2012 The Regents of the University of Michigan
- + * Copyright (C) 2023-2025 Roland Mainz <roland.mainz@nrubsig.org>
- *
- * Olga Kornievskaia <aglo@umich.edu>
- * Casey Bodley <cbodley@umich.edu>
- @@ -671,7 +672,8 @@ const char *opcode2string(int opcode)
- case NFS41_SYSOP_FILE_SET: return "NFS41_SYSOP_FILE_SET";
- case NFS41_SYSOP_EA_SET: return "NFS41_SYSOP_EA_SET";
- case NFS41_SYSOP_EA_GET: return "NFS41_SYSOP_EA_GET";
- - case NFS41_SYSOP_SYMLINK: return "NFS41_SYSOP_SYMLINK";
- + case NFS41_SYSOP_SYMLINK_GET: return "NFS41_SYSOP_SYMLINK_GET";
- + case NFS41_SYSOP_SYMLINK_SET: return "NFS41_SYSOP_SYMLINK_SET";
- case NFS41_SYSOP_VOLUME_QUERY: return "NFS41_SYSOP_VOLUME_QUERY";
- case NFS41_SYSOP_ACL_QUERY: return "NFS41_SYSOP_ACL_QUERY";
- case NFS41_SYSOP_ACL_SET: return "NFS41_SYSOP_ACL_SET";
- diff --git a/sys/nfs41sys_driver.h b/sys/nfs41sys_driver.h
- index f14beb5..f4d3130 100644
- --- a/sys/nfs41sys_driver.h
- +++ b/sys/nfs41sys_driver.h
- @@ -261,7 +261,6 @@ typedef struct _updowncall_entry {
- } QueryEa;
- struct {
- PUNICODE_STRING target;
- - BOOLEAN set;
- } Symlink;
- struct {
- FS_INFORMATION_CLASS query;
- diff --git a/sys/nfs41sys_ea.c b/sys/nfs41sys_ea.c
- index 629f3d8..0803f1b 100644
- --- a/sys/nfs41sys_ea.c
- +++ b/sys/nfs41sys_ea.c
- @@ -1,6 +1,6 @@
- /* NFSv4.1 client for Windows
- * Copyright (C) 2012 The Regents of the University of Michigan
- - * Copyright (C) 2023-2024 Roland Mainz <roland.mainz@nrubsig.org>
- + * Copyright (C) 2023-2025 Roland Mainz <roland.mainz@nrubsig.org>
- *
- * Olga Kornievskaia <aglo@umich.edu>
- * Casey Bodley <cbodley@umich.edu>
- @@ -473,13 +473,12 @@ NTSTATUS QueryCygwinSymlink(
- TargetName.MaximumLength = (USHORT)min(RxContext->Info.LengthRemaining -
- HeaderLen, 0xFFFF);
- - status = nfs41_UpcallCreate(NFS41_SYSOP_SYMLINK, &Fobx->sec_ctx,
- + status = nfs41_UpcallCreate(NFS41_SYSOP_SYMLINK_GET, &Fobx->sec_ctx,
- VNetRootContext->session, Fobx->nfs41_open_state,
- NetRootContext->nfs41d_version, SrvOpen->pAlreadyPrefixedName, &entry);
- if (status) goto out;
- entry->u.Symlink.target = &TargetName;
- - entry->u.Symlink.set = FALSE;
- status = nfs41_UpcallWaitForReply(entry, VNetRootContext->timeout);
- if (status) goto out;
- diff --git a/sys/nfs41sys_symlink.c b/sys/nfs41sys_symlink.c
- index 6e04074..6fb15e4 100644
- --- a/sys/nfs41sys_symlink.c
- +++ b/sys/nfs41sys_symlink.c
- @@ -1,6 +1,6 @@
- /* NFSv4.1 client for Windows
- * Copyright (C) 2012 The Regents of the University of Michigan
- - * Copyright (C) 2023-2024 Roland Mainz <roland.mainz@nrubsig.org>
- + * Copyright (C) 2023-2025 Roland Mainz <roland.mainz@nrubsig.org>
- *
- * Olga Kornievskaia <aglo@umich.edu>
- * Casey Bodley <cbodley@umich.edu>
- @@ -85,8 +85,8 @@ NTSTATUS marshal_nfs41_symlink(
- if (status) goto out;
- else tmp += *len;
- - header_len = *len + sizeof(BOOLEAN) + length_as_utf8(entry->filename);
- - if (entry->u.Symlink.set)
- + header_len = *len + length_as_utf8(entry->filename);
- + if (entry->opcode == NFS41_SYSOP_SYMLINK_SET)
- header_len += length_as_utf8(entry->u.Symlink.target);
- if (header_len > buf_len) {
- status = STATUS_INSUFFICIENT_RESOURCES;
- @@ -95,19 +95,25 @@ NTSTATUS marshal_nfs41_symlink(
- status = marshall_unicode_as_utf8(&tmp, entry->filename);
- if (status) goto out;
- - RtlCopyMemory(tmp, &entry->u.Symlink.set, sizeof(BOOLEAN));
- - tmp += sizeof(BOOLEAN);
- - if (entry->u.Symlink.set) {
- + if (entry->opcode == NFS41_SYSOP_SYMLINK_SET) {
- status = marshall_unicode_as_utf8(&tmp, entry->u.Symlink.target);
- if (status) goto out;
- }
- *len = header_len;
- #ifdef DEBUG_MARSHAL_DETAIL
- - DbgP("marshal_nfs41_symlink: name '%wZ' symlink target '%wZ'\n",
- - entry->filename,
- - entry->u.Symlink.set?entry->u.Symlink.target : NULL);
- -#endif
- + if (entry->opcode == NFS41_SYSOP_SYMLINK_SET) {
- + DbgP("marshal_nfs41_symlink: "
- + "SET: name '%wZ' symlink target '%wZ'\n",
- + entry->filename,
- + entry->u.Symlink.target);
- + }
- + else {
- + DbgP("marshal_nfs41_symlink: "
- + "GET: name '%wZ'\n",
- + entry->filename);
- + }
- +#endif /* DEBUG_MARSHAL_DETAIL */
- out:
- return status;
- }
- @@ -116,7 +122,8 @@ void unmarshal_nfs41_symlink(
- nfs41_updowncall_entry *cur,
- unsigned char **buf)
- {
- - if (cur->u.Symlink.set) return;
- + if (cur->opcode == NFS41_SYSOP_SYMLINK_SET)
- + return;
- RtlCopyMemory(&cur->u.Symlink.target->Length, *buf, sizeof(USHORT));
- *buf += sizeof(USHORT);
- @@ -296,13 +303,12 @@ NTSTATUS nfs41_SetSymlinkReparsePoint(
- TargetName.Buffer = &Reparse->SymbolicLinkReparseBuffer.PathBuffer[
- Reparse->SymbolicLinkReparseBuffer.PrintNameOffset/sizeof(WCHAR)];
- - status = nfs41_UpcallCreate(NFS41_SYSOP_SYMLINK, &Fobx->sec_ctx,
- + status = nfs41_UpcallCreate(NFS41_SYSOP_SYMLINK_SET, &Fobx->sec_ctx,
- VNetRootContext->session, Fobx->nfs41_open_state,
- pNetRootContext->nfs41d_version, SrvOpen->pAlreadyPrefixedName, &entry);
- if (status) goto out;
- entry->u.Symlink.target = &TargetName;
- - entry->u.Symlink.set = TRUE;
- status = nfs41_UpcallWaitForReply(entry, VNetRootContext->timeout);
- if (status) goto out;
- @@ -395,13 +401,12 @@ NTSTATUS nfs41_GetSymlinkReparsePoint(
- TargetName.MaximumLength = (USHORT)min(FsCtl->OutputBufferLength -
- HeaderLen, 0xFFFF);
- - status = nfs41_UpcallCreate(NFS41_SYSOP_SYMLINK, &Fobx->sec_ctx,
- + status = nfs41_UpcallCreate(NFS41_SYSOP_SYMLINK_GET, &Fobx->sec_ctx,
- VNetRootContext->session, Fobx->nfs41_open_state,
- pNetRootContext->nfs41d_version, SrvOpen->pAlreadyPrefixedName, &entry);
- if (status) goto out;
- entry->u.Symlink.target = &TargetName;
- - entry->u.Symlink.set = FALSE;
- status = nfs41_UpcallWaitForReply(entry, VNetRootContext->timeout);
- if (status) goto out;
- diff --git a/sys/nfs41sys_updowncall.c b/sys/nfs41sys_updowncall.c
- index b359d2a..0f2afa6 100644
- --- a/sys/nfs41sys_updowncall.c
- +++ b/sys/nfs41sys_updowncall.c
- @@ -1,6 +1,6 @@
- /* NFSv4.1 client for Windows
- * Copyright (C) 2012 The Regents of the University of Michigan
- - * Copyright (C) 2023-2024 Roland Mainz <roland.mainz@nrubsig.org>
- + * Copyright (C) 2023-2025 Roland Mainz <roland.mainz@nrubsig.org>
- *
- * Olga Kornievskaia <aglo@umich.edu>
- * Casey Bodley <cbodley@umich.edu>
- @@ -289,7 +289,8 @@ NTSTATUS handle_upcall(
- case NFS41_SYSOP_EA_GET:
- status = marshal_nfs41_eaget(entry, pbOut, cbOut, len);
- break;
- - case NFS41_SYSOP_SYMLINK:
- + case NFS41_SYSOP_SYMLINK_GET:
- + case NFS41_SYSOP_SYMLINK_SET:
- status = marshal_nfs41_symlink(entry, pbOut, cbOut, len);
- break;
- case NFS41_SYSOP_VOLUME_QUERY:
- @@ -631,7 +632,8 @@ NTSTATUS nfs41_downcall(
- case NFS41_SYSOP_EA_GET:
- unmarshal_nfs41_eaget(cur, &buf);
- break;
- - case NFS41_SYSOP_SYMLINK:
- + case NFS41_SYSOP_SYMLINK_GET:
- + case NFS41_SYSOP_SYMLINK_SET:
- unmarshal_nfs41_symlink(cur, &buf);
- break;
- case NFS41_SYSOP_VOLUME_QUERY:
- --
- 2.45.1
- From 77cd75950da001e4807c0feb4bee6283cca2a72e Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 5 Feb 2025 11:28:08 +0100
- Subject: [PATCH 4/6] sys: |map_symlink_errors()| should handle
- |ERROR_*_NOT_FOUND|
- |map_symlink_errors()| should handle |ERROR_FILE_NOT_FOUND| and
- |ERROR_PATH_NOT_FOUND|.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41sys_symlink.c | 2 ++
- 1 file changed, 2 insertions(+)
- diff --git a/sys/nfs41sys_symlink.c b/sys/nfs41sys_symlink.c
- index 6fb15e4..1480ace 100644
- --- a/sys/nfs41sys_symlink.c
- +++ b/sys/nfs41sys_symlink.c
- @@ -142,6 +142,8 @@ NTSTATUS map_symlink_errors(
- {
- switch (status) {
- case NO_ERROR: return STATUS_SUCCESS;
- + case ERROR_FILE_NOT_FOUND: return STATUS_OBJECT_NAME_NOT_FOUND;
- + case ERROR_PATH_NOT_FOUND: return STATUS_OBJECT_PATH_NOT_FOUND;
- case ERROR_INVALID_REPARSE_DATA: return STATUS_IO_REPARSE_DATA_INVALID;
- case ERROR_NOT_A_REPARSE_POINT: return STATUS_NOT_A_REPARSE_POINT;
- case ERROR_ACCESS_DENIED: return STATUS_ACCESS_DENIED;
- --
- 2.45.1
- From a71e2b790377bddc069bb2c32c161806bf0c5475 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 5 Feb 2025 11:53:28 +0100
- Subject: [PATCH 5/6] sys: Move(+cleanup) |print_reparse_buffer()| to
- nfs41sys_reparse.c
- Move(+cleanup) |print_reparse_buffer()| to nfs41sys_reparse.c
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41sys_driver.h | 2 ++
- sys/nfs41sys_reparse.c | 57 ++++++++++++++++++++++++++++++++++++++++++
- sys/nfs41sys_symlink.c | 31 -----------------------
- 3 files changed, 59 insertions(+), 31 deletions(-)
- diff --git a/sys/nfs41sys_driver.h b/sys/nfs41sys_driver.h
- index f4d3130..4b875ee 100644
- --- a/sys/nfs41sys_driver.h
- +++ b/sys/nfs41sys_driver.h
- @@ -777,6 +777,8 @@ NTSTATUS nfs41_SetSymlinkReparsePoint(
- IN OUT PRX_CONTEXT RxContext);
- NTSTATUS nfs41_GetSymlinkReparsePoint(
- IN OUT PRX_CONTEXT RxContext);
- +void print_reparse_buffer(
- + PREPARSE_DATA_BUFFER r);
- /* nfs41sys_reparse.c */
- NTSTATUS nfs41_SetReparsePoint(
- diff --git a/sys/nfs41sys_reparse.c b/sys/nfs41sys_reparse.c
- index 0b1e726..df4fa1f 100644
- --- a/sys/nfs41sys_reparse.c
- +++ b/sys/nfs41sys_reparse.c
- @@ -115,3 +115,60 @@ NTSTATUS nfs41_GetReparsePoint(
- DbgEx();
- return status;
- }
- +
- +void print_reparse_buffer(
- + PREPARSE_DATA_BUFFER r)
- +{
- + UNICODE_STRING name;
- + DbgP("ReparseTag: 0x%lx\n", (long)r->ReparseTag);
- + DbgP("ReparseDataLength: %u\n", (int)r->ReparseDataLength);
- + DbgP("Reserved: %u\n", (int)r->Reserved);
- + if (r->ReparseTag == IO_REPARSE_TAG_SYMLINK) {
- + DbgP("IO_REPARSE_TAG_SYMLINK:\n");
- + DbgP("SubstituteNameOffset: %u\n",
- + r->SymbolicLinkReparseBuffer.SubstituteNameOffset);
- + DbgP("SubstituteNameLength: %u\n",
- + r->SymbolicLinkReparseBuffer.SubstituteNameLength);
- + DbgP("PrintNameOffset: %u\n",
- + r->SymbolicLinkReparseBuffer.PrintNameOffset);
- + DbgP("PrintNameLength: %u\n",
- + r->SymbolicLinkReparseBuffer.PrintNameLength);
- + DbgP("Flags: 0x%lx\n",
- + (long)r->SymbolicLinkReparseBuffer.Flags);
- +
- + name.Buffer = &r->SymbolicLinkReparseBuffer.PathBuffer[
- + r->SymbolicLinkReparseBuffer.SubstituteNameOffset/sizeof(WCHAR)];
- + name.MaximumLength = name.Length =
- + r->SymbolicLinkReparseBuffer.SubstituteNameLength;
- + DbgP("SubstituteName: '%wZ'\n", &name);
- +
- + name.Buffer = &r->SymbolicLinkReparseBuffer.PathBuffer[
- + r->SymbolicLinkReparseBuffer.PrintNameOffset/sizeof(WCHAR)];
- + name.MaximumLength = name.Length =
- + r->SymbolicLinkReparseBuffer.PrintNameLength;
- + DbgP("PrintName: '%wZ'\n", &name);
- + }
- + else if (r->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) {
- + DbgP("IO_REPARSE_TAG_MOUNT_POINT:\n");
- + DbgP("SubstituteNameOffset: %u\n",
- + r->MountPointReparseBuffer.SubstituteNameOffset);
- + DbgP("SubstituteNameLength: %u\n",
- + r->MountPointReparseBuffer.SubstituteNameLength);
- + DbgP("PrintNameOffset: %u\n",
- + r->MountPointReparseBuffer.PrintNameOffset);
- + DbgP("PrintNameLength: %u\n",
- + r->MountPointReparseBuffer.PrintNameLength);
- +
- + name.Buffer = &r->MountPointReparseBuffer.PathBuffer[
- + r->MountPointReparseBuffer.SubstituteNameOffset/sizeof(WCHAR)];
- + name.MaximumLength = name.Length =
- + r->MountPointReparseBuffer.SubstituteNameLength;
- + DbgP("SubstituteName: '%wZ'\n", &name);
- +
- + name.Buffer = &r->MountPointReparseBuffer.PathBuffer[
- + r->MountPointReparseBuffer.PrintNameOffset/sizeof(WCHAR)];
- + name.MaximumLength = name.Length =
- + r->MountPointReparseBuffer.PrintNameLength;
- + DbgP("PrintName: '%wZ'\n", &name);
- + }
- +}
- diff --git a/sys/nfs41sys_symlink.c b/sys/nfs41sys_symlink.c
- index 1480ace..cb57082 100644
- --- a/sys/nfs41sys_symlink.c
- +++ b/sys/nfs41sys_symlink.c
- @@ -166,37 +166,6 @@ NTSTATUS map_symlink_errors(
- }
- }
- -static void print_reparse_buffer(
- - PREPARSE_DATA_BUFFER Reparse)
- -{
- - UNICODE_STRING name;
- - DbgP("ReparseTag: %08X\n", Reparse->ReparseTag);
- - DbgP("ReparseDataLength: %8u\n", Reparse->ReparseDataLength);
- - DbgP("Reserved: %8u\n", Reparse->Reserved);
- - DbgP("SubstituteNameOffset: %8u\n",
- - Reparse->SymbolicLinkReparseBuffer.SubstituteNameOffset);
- - DbgP("SubstituteNameLength: %8u\n",
- - Reparse->SymbolicLinkReparseBuffer.SubstituteNameLength);
- - DbgP("PrintNameOffset: %8u\n",
- - Reparse->SymbolicLinkReparseBuffer.PrintNameOffset);
- - DbgP("PrintNameLength: %8u\n",
- - Reparse->SymbolicLinkReparseBuffer.PrintNameLength);
- - DbgP("Flags: %08X\n",
- - Reparse->SymbolicLinkReparseBuffer.Flags);
- -
- - name.Buffer = &Reparse->SymbolicLinkReparseBuffer.PathBuffer[
- - Reparse->SymbolicLinkReparseBuffer.SubstituteNameOffset/sizeof(WCHAR)];
- - name.MaximumLength = name.Length =
- - Reparse->SymbolicLinkReparseBuffer.SubstituteNameLength;
- - DbgP("SubstituteName: '%wZ'\n", &name);
- -
- - name.Buffer = &Reparse->SymbolicLinkReparseBuffer.PathBuffer[
- - Reparse->SymbolicLinkReparseBuffer.PrintNameOffset/sizeof(WCHAR)];
- - name.MaximumLength = name.Length =
- - Reparse->SymbolicLinkReparseBuffer.PrintNameLength;
- - DbgP("PrintName: '%wZ'\n", &name);
- -}
- -
- static
- NTSTATUS check_nfs41_setsymlinkreparse_args(
- IN PRX_CONTEXT RxContext)
- --
- 2.45.1
- From 0d84cbd51ea9abc30f5c69558a8ce626335a9c90 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 5 Feb 2025 21:18:27 +0100
- Subject: [PATCH 6/6] sys: Convert Windows (deviceletter, UNC, relative)
- symlinks to/from POSIX symlinks
- Convert Windows (deviceletter, UNC, relative) symlinks into POSIX symlinks
- and POSIX symlinks into Windows (deviceletter, UNC, relative) symlinks,
- and reject malformed POSIX symlinks (e.g. POSIX "X:/foo" will be rejected).
- Reported-by: Lionel Cons <lionelcons1972@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41sys_symlink.c | 401 ++++++++++++++++++++++++++++++++++++++---
- 1 file changed, 375 insertions(+), 26 deletions(-)
- diff --git a/sys/nfs41sys_symlink.c b/sys/nfs41sys_symlink.c
- index cb57082..eea2db8 100644
- --- a/sys/nfs41sys_symlink.c
- +++ b/sys/nfs41sys_symlink.c
- @@ -58,6 +58,7 @@
- #include <winerror.h>
- #include <Ntstrsafe.h>
- +#include <stdbool.h>
- #include "nfs41sys_buildconfig.h"
- @@ -248,7 +249,8 @@ NTSTATUS nfs41_SetSymlinkReparsePoint(
- NFS41GetVNetRootExtension(SrvOpen->pVNetRoot);
- __notnull PNFS41_NETROOT_EXTENSION pNetRootContext =
- NFS41GetNetRootExtension(SrvOpen->pVNetRoot->pNetRoot);
- - nfs41_updowncall_entry *entry;
- + nfs41_updowncall_entry *entry = NULL;
- + PWSTR prefixed_targetname = NULL;
- #ifdef DEBUG_SYMLINK
- DbgEn();
- @@ -269,10 +271,110 @@ NTSTATUS nfs41_SetSymlinkReparsePoint(
- goto out;
- }
- + if (Reparse->ReparseTag != IO_REPARSE_TAG_SYMLINK) {
- + status = IO_REPARSE_TAG_SYMLINK;
- + DbgP("nfs41_SetSymlinkReparsePoint: "
- + "Reparse->ReparseTag != IO_REPARSE_TAG_SYMLINK\n");
- + goto out;
- + }
- +
- TargetName.MaximumLength = TargetName.Length =
- - Reparse->SymbolicLinkReparseBuffer.PrintNameLength;
- + Reparse->SymbolicLinkReparseBuffer.SubstituteNameLength;
- TargetName.Buffer = &Reparse->SymbolicLinkReparseBuffer.PathBuffer[
- - Reparse->SymbolicLinkReparseBuffer.PrintNameOffset/sizeof(WCHAR)];
- + Reparse->SymbolicLinkReparseBuffer.SubstituteNameOffset/sizeof(WCHAR)];
- +
- + if (TargetName.Buffer[0] == L'.') {
- + DbgP("nfs41_SetSymlinkReparsePoint: "
- + "relative path TargetName='%wZ'\n",
- + &TargetName);
- + }
- + else {
- + DbgP("nfs41_SetSymlinkReparsePoint: "
- + "absolute path TargetName='%wZ'\n",
- + &TargetName);
- +
- + /* Strip "\\??\\" prefix */
- + if (!memcmp(&TargetName.Buffer[0], L"\\??\\",
- + (4*sizeof(wchar_t)))) {
- + TargetName.Buffer += 4;
- + TargetName.MaximumLength = TargetName.Length =
- + TargetName.Length-(4*sizeof(wchar_t));
- + }
- +
- + /* UNC path ? */
- + if (!memcmp(&TargetName.Buffer[0], L"UNC\\",
- + (4*sizeof(wchar_t)))) {
- +
- + /*
- + * Turn "UNC\" into "\\"
- + * (userland daemon will convert the backslashes in UNC
- + * path to slashes)
- + */
- + TargetName.Buffer += 2;
- + TargetName.MaximumLength = TargetName.Length =
- + TargetName.Length-(2*sizeof(wchar_t));
- + TargetName.Buffer[0] = L'\\';
- +
- + DbgP("nfs41_SetSymlinkReparsePoint: "
- + "UNC TargetName='%wZ'\n",
- + &TargetName);
- + }
- + else {
- + wchar_t devletter;
- +
- + DbgP("nfs41_SetSymlinkReparsePoint: "
- + "DEVLETTER TargetName='%wZ'\n",
- + &TargetName);
- +
- + if ((TargetName.Buffer[1] != L':') ||
- + (TargetName.Buffer[2] != L'\\')) {
- + status = STATUS_INVALID_PARAMETER;
- + DbgP("nfs41_SetSymlinkReparsePoint: "
- + "DEVLETTER path '%wZ' should start with 'L:\\'\n",
- + &TargetName);
- + goto out;
- + }
- +
- + /* Get devletter and skip "L:\" "*/
- + devletter = towlower(TargetName.Buffer[0]);
- + TargetName.Buffer += 3;
- + TargetName.MaximumLength = TargetName.Length =
- + TargetName.Length-(3*sizeof(wchar_t));
- +
- + DbgP("nfs41_SetSymlinkReparsePoint: "
- + "deviceletter='%C' path='%wZ'\n",
- + devletter,
- + &TargetName);
- +
- + size_t prefixed_targetname_len = 4096*sizeof(wchar_t);
- +
- + prefixed_targetname = RxAllocatePoolWithTag(NonPagedPoolNx,
- + prefixed_targetname_len, NFS41_MM_POOLTAG);
- + if (prefixed_targetname == NULL) {
- + status = STATUS_INSUFFICIENT_RESOURCES;
- + goto out;
- + }
- +
- + /*
- + * Stuff Cygwin /cygdrive/<deviceletter>/ prefix in front
- + * of path, userland daemon will convert the backslashes
- + * to slashes
- + */
- + (void)_snwprintf(prefixed_targetname,
- + prefixed_targetname_len, L"\\cygdrive\\%C\\%wZ",
- + devletter,
- + &TargetName);
- +
- + /* Put new buffer into target name */
- + TargetName.MaximumLength = TargetName.Length =
- + (USHORT)(wcslen(prefixed_targetname)*sizeof(wchar_t));
- + TargetName.Buffer = prefixed_targetname;
- +
- + DbgP("nfs41_SetSymlinkReparsePoint: "
- + "new TargetName='%wZ'\n",
- + &TargetName);
- + }
- + }
- status = nfs41_UpcallCreate(NFS41_SYSOP_SYMLINK_SET, &Fobx->sec_ctx,
- VNetRootContext->session, Fobx->nfs41_open_state,
- @@ -285,8 +387,12 @@ NTSTATUS nfs41_SetSymlinkReparsePoint(
- if (status) goto out;
- status = map_symlink_errors(entry->status);
- - nfs41_UpcallDestroy(entry);
- out:
- + if (entry)
- + nfs41_UpcallDestroy(entry);
- + if (prefixed_targetname)
- + RxFreePool(prefixed_targetname);
- +
- #ifdef DEBUG_SYMLINK
- DbgEx();
- #endif
- @@ -340,6 +446,75 @@ out:
- return status;
- }
- +static
- +bool is_us_relative_path(UNICODE_STRING *restrict us)
- +{
- + /* Match exactly "." (single dot) */
- + if ((us->Length == (1*sizeof(wchar_t))) &&
- + (us->Buffer[0] == L'.'))
- + return true;
- +
- + /* Match exactly ".." (double dot) */
- + if ((us->Length == (2*sizeof(wchar_t)) &&
- + (!memcmp(&us->Buffer[0], L"..", (2*sizeof(wchar_t))))))
- + return true;
- +
- + /* Match "..\..." */
- + if ((us->Length >= (3*sizeof(wchar_t))) &&
- + (!memcmp(&us->Buffer[0], L"..\\", (3*sizeof(wchar_t)))))
- + return true;
- +
- + /* Match ".\..." */
- + if ((us->Length >= (2*sizeof(wchar_t))) &&
- + (!memcmp(&us->Buffer[0], L".\\", (2*sizeof(wchar_t)))))
- + return true;
- +
- + /* Reject any absolute paths or similar stuff */
- + if ((us->Length >= (1*sizeof(wchar_t)) &&
- + (
- + (us->Buffer[0] == L'\\') ||
- + (us->Buffer[0] == L'/')
- + ))) {
- + return false;
- + }
- +
- + /*
- + * Reject paths like L: (':' is an illegal filesystem name
- + * character, reserved for alternate data streams only)
- + */
- + if ((us->Length >= (2*sizeof(wchar_t)) &&
- + (us->Buffer[1] == L':'))) {
- + return false;
- + }
- +
- + /*
- + * Handle the case of symlink foo --> bar (and foo -->bar/baz),
- + * e.g. symlinking one name to a file/dir in the same directory
- + */
- + return true;
- +}
- +
- +static
- +bool is_us_unc_path(UNICODE_STRING *restrict us)
- +{
- + if (!memcmp(&us->Buffer[0], L"\\\\", (2*sizeof(wchar_t))))
- + return true;
- + return false;
- +}
- +
- +static
- +bool is_us_cygdrive_path(UNICODE_STRING *restrict us)
- +{
- + /* Fixme: What about MSYS2 ? */
- +
- + /* "/cygdrive/l" == 11 characters */
- + if ((us->Length >= (11*sizeof(wchar_t))) &&
- + (!memcmp(&us->Buffer[0],
- + L"\\cygdrive\\", (10*sizeof(wchar_t)))))
- + return true;
- + return false;
- +}
- +
- NTSTATUS nfs41_GetSymlinkReparsePoint(
- IN OUT PRX_CONTEXT RxContext)
- {
- @@ -352,9 +527,8 @@ NTSTATUS nfs41_GetSymlinkReparsePoint(
- NFS41GetVNetRootExtension(SrvOpen->pVNetRoot);
- __notnull PNFS41_NETROOT_EXTENSION pNetRootContext =
- NFS41GetNetRootExtension(SrvOpen->pVNetRoot->pNetRoot);
- - nfs41_updowncall_entry *entry;
- - const USHORT HeaderLen = FIELD_OFFSET(REPARSE_DATA_BUFFER,
- - SymbolicLinkReparseBuffer.PathBuffer);
- + nfs41_updowncall_entry *entry = NULL;
- + PWSTR targetname_buffer = NULL;
- #ifdef DEBUG_SYMLINK
- DbgEn();
- @@ -368,9 +542,16 @@ NTSTATUS nfs41_GetSymlinkReparsePoint(
- goto out;
- }
- - TargetName.Buffer = (PWCH)((PBYTE)FsCtl->pOutputBuffer + HeaderLen);
- - TargetName.MaximumLength = (USHORT)min(FsCtl->OutputBufferLength -
- - HeaderLen, 0xFFFF);
- + size_t targetname_buffer_len = 4096*sizeof(wchar_t);
- + targetname_buffer = RxAllocatePoolWithTag(NonPagedPoolNx,
- + targetname_buffer_len, NFS41_MM_POOLTAG);
- + if (targetname_buffer == NULL) {
- + status = STATUS_INSUFFICIENT_RESOURCES;
- + goto out;
- + }
- +
- + TargetName.Buffer = targetname_buffer;
- + TargetName.MaximumLength = (USHORT)targetname_buffer_len;
- status = nfs41_UpcallCreate(NFS41_SYSOP_SYMLINK_GET, &Fobx->sec_ctx,
- VNetRootContext->session, Fobx->nfs41_open_state,
- @@ -387,27 +568,195 @@ NTSTATUS nfs41_GetSymlinkReparsePoint(
- /* fill in the output buffer */
- PREPARSE_DATA_BUFFER Reparse = (PREPARSE_DATA_BUFFER)
- FsCtl->pOutputBuffer;
- - Reparse->ReparseTag = IO_REPARSE_TAG_SYMLINK;
- - Reparse->ReparseDataLength = HeaderLen + TargetName.Length -
- +
- + DbgP("nfs41_GetSymlinkReparsePoint: "
- + "got TargetName='%wZ', len=%d\n",
- + &TargetName, (int)TargetName.Length);
- +
- + /* POSIX slash to Win32 backslash */
- + size_t i;
- + for (i=0 ; i < TargetName.Length ; i++) {
- + if (TargetName.Buffer[i] == L'/')
- + TargetName.Buffer[i] = L'\\';
- + }
- +
- + DbgP("nfs41_GetSymlinkReparsePoint: "
- + "TargetName='%wZ' with '/'-->'\\' conversion\n",
- + &TargetName);
- +
- + if (is_us_cygdrive_path(&TargetName)) {
- + const USHORT HeaderLen = FIELD_OFFSET(REPARSE_DATA_BUFFER,
- + SymbolicLinkReparseBuffer.PathBuffer);
- +
- + DbgP("nfs41_GetSymlinkReparsePoint: /cygdrive/ codepath\n");
- +
- + wchar_t dosletter;
- + dosletter = towupper(TargetName.Buffer[10]);
- + TargetName.Buffer += 9;
- + TargetName.MaximumLength = TargetName.Length =
- + TargetName.Length-(9*sizeof(wchar_t));
- +
- + /* If we only have "L:" turn this into "L:\" */
- + if (TargetName.Length == (2*sizeof(wchar_t))) {
- + TargetName.MaximumLength = TargetName.Length =
- + TargetName.Length + (1*sizeof(wchar_t));
- + }
- +
- + TargetName.Buffer[0] = dosletter;
- + TargetName.Buffer[1] = L':';
- + TargetName.Buffer[2] = L'\\';
- +
- + DbgP("nfs41_GetSymlinkReparsePoint: new TargetName='%wZ'\n",
- + &TargetName);
- +
- + /* Copy data into FsCtl buffer */
- + PWCH outbuff = (PWCH)(((PBYTE)FsCtl->pOutputBuffer) + HeaderLen);
- + (void)memcpy(outbuff, TargetName.Buffer, TargetName.Length);
- + TargetName.Buffer = outbuff;
- +
- + DbgP("nfs41_GetSymlinkReparsePoint: new TargetName='%wZ'\n",
- + &TargetName);
- +
- + Reparse->ReparseTag = IO_REPARSE_TAG_SYMLINK;
- + Reparse->ReparseDataLength = HeaderLen + TargetName.Length -
- + REPARSE_DATA_BUFFER_HEADER_SIZE;
- + Reparse->Reserved = 0;
- + /* /cygwin/<devletter>/ are absolute paths */
- +#define CYGWIN_WANTS_SYMLINKFLAGRELATIVE_FOR_ABS_PATHS 1 /* FIXME: Why ? */
- +
- +#ifdef CYGWIN_WANTS_SYMLINKFLAGRELATIVE_FOR_ABS_PATHS
- + Reparse->SymbolicLinkReparseBuffer.Flags = SYMLINK_FLAG_RELATIVE;
- +#else
- + Reparse->SymbolicLinkReparseBuffer.Flags = 0;
- +#endif
- +
- + /* PrintName and SubstituteName point to the same string */
- + Reparse->SymbolicLinkReparseBuffer.SubstituteNameOffset = 0;
- + Reparse->SymbolicLinkReparseBuffer.SubstituteNameLength =
- + TargetName.Length;
- + Reparse->SymbolicLinkReparseBuffer.PrintNameOffset = 0;
- + Reparse->SymbolicLinkReparseBuffer.PrintNameLength =
- + TargetName.Length;
- +
- + print_reparse_buffer(Reparse);
- +
- + RxContext->IoStatusBlock.Information =
- + (ULONG_PTR)HeaderLen + TargetName.Length;
- + }
- + else if (is_us_unc_path(&TargetName)) {
- + /*
- + * FIXME: UNC paths should return
- + * |IO_REPARSE_TAG_MOUNT_POINT|, but Cygwin does not
- + * support |IO_REPARSE_TAG_MOUNT_POINT| for remote
- + * filesystems.
- + * Note that we if we switch this over to
- + * |IO_REPARSE_TAG_MOUNT_POINT| we also have to teach
- + * daemon/readdir.c&co that we have more than one type
- + * of reparse tag
- + */
- + const USHORT HeaderLen = FIELD_OFFSET(REPARSE_DATA_BUFFER,
- + SymbolicLinkReparseBuffer.PathBuffer);
- +
- + DbgP("nfs41_GetSymlinkReparsePoint: UNC codepath\n");
- +
- + /* Copy data into FsCtl buffer */
- + PWCH outbuff = (PWCH)(((PBYTE)FsCtl->pOutputBuffer) + HeaderLen);
- + (void)memcpy(outbuff, TargetName.Buffer, TargetName.Length);
- + TargetName.Buffer = outbuff;
- +
- +
- + DbgP("nfs41_GetSymlinkReparsePoint: "
- + "new UNC TargetName='%wZ'\n",
- + &TargetName);
- +
- + Reparse->ReparseTag = IO_REPARSE_TAG_SYMLINK;
- + Reparse->ReparseDataLength = HeaderLen + TargetName.Length -
- REPARSE_DATA_BUFFER_HEADER_SIZE;
- - Reparse->Reserved = 0;
- - Reparse->SymbolicLinkReparseBuffer.Flags = SYMLINK_FLAG_RELATIVE;
- - /* PrintName and SubstituteName point to the same string */
- - Reparse->SymbolicLinkReparseBuffer.SubstituteNameOffset = 0;
- - Reparse->SymbolicLinkReparseBuffer.SubstituteNameLength =
- - TargetName.Length;
- - Reparse->SymbolicLinkReparseBuffer.PrintNameOffset = 0;
- - Reparse->SymbolicLinkReparseBuffer.PrintNameLength = TargetName.Length;
- - print_reparse_buffer(Reparse);
- -
- - RxContext->IoStatusBlock.Information =
- - (ULONG_PTR)HeaderLen + TargetName.Length;
- + Reparse->Reserved = 0;
- + /* UNC paths are absolute paths */
- +#ifdef CYGWIN_WANTS_SYMLINKFLAGRELATIVE_FOR_ABS_PATHS
- + Reparse->SymbolicLinkReparseBuffer.Flags = SYMLINK_FLAG_RELATIVE;
- +#else
- + Reparse->SymbolicLinkReparseBuffer.Flags = 0;
- +#endif
- +
- + /* PrintName and SubstituteName point to the same string */
- + Reparse->SymbolicLinkReparseBuffer.SubstituteNameOffset = 0;
- + Reparse->SymbolicLinkReparseBuffer.SubstituteNameLength =
- + TargetName.Length;
- + Reparse->SymbolicLinkReparseBuffer.PrintNameOffset = 0;
- + Reparse->SymbolicLinkReparseBuffer.PrintNameLength =
- + TargetName.Length;
- +
- + print_reparse_buffer(Reparse);
- +
- + RxContext->IoStatusBlock.Information =
- + (ULONG_PTR)HeaderLen + TargetName.Length;
- + }
- + else if (is_us_relative_path(&TargetName)) {
- + const USHORT HeaderLen = FIELD_OFFSET(REPARSE_DATA_BUFFER,
- + SymbolicLinkReparseBuffer.PathBuffer);
- +
- + DbgP("nfs41_GetSymlinkReparsePoint: relative symlink codepath\n");
- +
- + /* Copy data into FsCtl buffer */
- + (void)memcpy(((PBYTE)FsCtl->pOutputBuffer + HeaderLen),
- + TargetName.Buffer, TargetName.Length);
- + TargetName.Buffer =
- + (PWCH)((PBYTE)FsCtl->pOutputBuffer + HeaderLen);
- +
- + DbgP("nfs41_GetSymlinkReparsePoint: "
- + "new relative TargetName='%wZ'\n",
- + &TargetName);
- +
- + Reparse->ReparseTag = IO_REPARSE_TAG_SYMLINK;
- + Reparse->ReparseDataLength = HeaderLen + TargetName.Length -
- + REPARSE_DATA_BUFFER_HEADER_SIZE;
- + Reparse->Reserved = 0;
- + Reparse->SymbolicLinkReparseBuffer.Flags =
- + SYMLINK_FLAG_RELATIVE;
- + /* PrintName and SubstituteName point to the same string */
- + Reparse->SymbolicLinkReparseBuffer.SubstituteNameOffset = 0;
- + Reparse->SymbolicLinkReparseBuffer.SubstituteNameLength =
- + TargetName.Length;
- + Reparse->SymbolicLinkReparseBuffer.PrintNameOffset = 0;
- + Reparse->SymbolicLinkReparseBuffer.PrintNameLength =
- + TargetName.Length;
- +
- + print_reparse_buffer(Reparse);
- +
- + RxContext->IoStatusBlock.Information =
- + (ULONG_PTR)HeaderLen + TargetName.Length;
- + }
- + else {
- + status = STATUS_IO_REPARSE_DATA_INVALID;
- + DbgP("nfs41_GetSymlinkReparsePoint: "
- + "cannot parse symlink data TargetName='%wZ'\n",
- + &TargetName);
- + }
- } else if (status == STATUS_BUFFER_TOO_SMALL) {
- + const size_t sym_hdr_len =
- + FIELD_OFFSET(REPARSE_DATA_BUFFER,
- + MountPointReparseBuffer.PathBuffer);
- + const size_t mnt_hdr_len =
- + FIELD_OFFSET(REPARSE_DATA_BUFFER,
- + SymbolicLinkReparseBuffer.PathBuffer);
- + /*
- + * We don't know whether we have to return
- + * |IO_REPARSE_TAG_MOUNT_POINT| or |IO_REPARSE_TAG_SYMLINK|,
- + * so we return a size which can fit both
- + */
- +#define MAX(a, b) (((a) > (b)) ? (a) : (b))
- RxContext->InformationToReturn =
- - (ULONG_PTR)HeaderLen + TargetName.Length;
- + MAX(sym_hdr_len, mnt_hdr_len) + TargetName.Length;
- }
- - nfs41_UpcallDestroy(entry);
- +
- out:
- + if (entry)
- + nfs41_UpcallDestroy(entry);
- + if (targetname_buffer)
- + RxFreePool(targetname_buffer);
- +
- #ifdef DEBUG_SYMLINK
- DbgEx();
- #endif
- --
- 2.45.1
msnfs41client: Patches for Win32 symlink/reparse point to/from POSIX symlink translation, compiler opt cleanup, FCL aliasing+misc, 2025-02-05
Posted by Anonymous on Wed 5th Feb 2025 20:30
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.