From d0f5ea69a220837d39f17681c72cd81f59da1b64 Mon Sep 17 00:00:00 2001 From: FrKaram Date: Thu, 28 Jun 2018 23:01:26 +0200 Subject: [PATCH 01/12] Added FlushAndPurgeOnCleanup property in .NET wrapper --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..9c4196a4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +################################################################################ +# This .gitignore file was automatically created by Microsoft(R) Visual Studio. +################################################################################ + +*.db From fb8cb8aca9badcc06d164dbf398712d4c4376ed8 Mon Sep 17 00:00:00 2001 From: FrKaram Date: Sat, 30 Jun 2018 20:20:17 +0200 Subject: [PATCH 02/12] Added FpsVersion as a static method in FileSystemHost Added FlushAndPurgeOnCleanup --- .gitignore | 1 + src/dotnet/FileSystemHost.cs | 13 +++++++ src/dotnet/Interop.cs | 40 ++++++++++++-------- tst/memfs-dotnet/Program.cs | 71 ++++++++++++++++++------------------ 4 files changed, 75 insertions(+), 50 deletions(-) diff --git a/.gitignore b/.gitignore index 9c4196a4..48511677 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ ################################################################################ *.db +*.opendb diff --git a/src/dotnet/FileSystemHost.cs b/src/dotnet/FileSystemHost.cs index 55a14c2c..7d7cd53e 100644 --- a/src/dotnet/FileSystemHost.cs +++ b/src/dotnet/FileSystemHost.cs @@ -194,6 +194,11 @@ namespace Fsp get { return 0 != (_VolumeParams.Flags & VolumeParams.PassQueryDirectoryFileName); } set { _VolumeParams.Flags |= (value ? VolumeParams.PassQueryDirectoryFileName : 0); } } + public Boolean FlushAndPurgeOnCleanup + { + get { return 0 != (_VolumeParams.Flags & VolumeParams.FlushAndPurgeOnCleanup); } + set { _VolumeParams.Flags |= (value ? VolumeParams.FlushAndPurgeOnCleanup : 0); } + } /// /// Gets or sets the prefix for a network file system. /// @@ -347,6 +352,14 @@ namespace Fsp { return Api.SetDebugLogFile(FileName); } + /// + /// Return the installed version for WinFSP + /// + /// + public static Version GetFspVersion() + { + return Api.GetFspVersion(); + } /* FSP_FILE_SYSTEM_INTERFACE */ private static Byte[] ByteBufferNotNull = new Byte[0]; diff --git a/src/dotnet/Interop.cs b/src/dotnet/Interop.cs index c81e9b67..b00915e8 100644 --- a/src/dotnet/Interop.cs +++ b/src/dotnet/Interop.cs @@ -43,6 +43,7 @@ namespace Fsp.Interop internal const UInt32 PassQueryDirectoryPattern = 0x00000800; internal const UInt32 AlwaysUseDoubleBuffering = 0x00001000; internal const UInt32 PassQueryDirectoryFileName = 0x00002000; + internal const UInt32 FlushAndPurgeOnCleanup = 0x00004000; internal const UInt32 UmFileContextIsUserContext2 = 0x00010000; internal const UInt32 UmFileContextIsFullContext = 0x00020000; internal const int PrefixSize = 192; @@ -903,17 +904,17 @@ namespace Fsp.Interop Byte[] ModificationDescriptorBytes) { fixed (Byte *S = SecurityDescriptorBytes) - fixed (Byte *M = ModificationDescriptorBytes) - { - IntPtr SecurityDescriptor; - Int32 Result = FspSetSecurityDescriptor( - (IntPtr)S, SecurityInformation, (IntPtr)M, out SecurityDescriptor); - if (0 > Result) - return null; - SecurityDescriptorBytes = MakeSecurityDescriptor(SecurityDescriptor); - FspDeleteSecurityDescriptor(SecurityDescriptor, _FspSetSecurityDescriptorPtr); - return SecurityDescriptorBytes; - } + fixed (Byte *M = ModificationDescriptorBytes) + { + IntPtr SecurityDescriptor; + Int32 Result = FspSetSecurityDescriptor( + (IntPtr)S, SecurityInformation, (IntPtr)M, out SecurityDescriptor); + if (0 > Result) + return null; + SecurityDescriptorBytes = MakeSecurityDescriptor(SecurityDescriptor); + FspDeleteSecurityDescriptor(SecurityDescriptor, _FspSetSecurityDescriptorPtr); + return SecurityDescriptorBytes; + } } internal unsafe static Int32 CopyReparsePoint( @@ -953,10 +954,10 @@ namespace Fsp.Interop Byte[] ReplaceReparseData) { fixed (Byte *C = CurrentReparseData) - fixed (Byte *R = ReplaceReparseData) - return _FspFileSystemCanReplaceReparsePoint( - (IntPtr)C, (UIntPtr)CurrentReparseData.Length, - (IntPtr)R, (UIntPtr)ReplaceReparseData.Length); + fixed (Byte *R = ReplaceReparseData) + return _FspFileSystemCanReplaceReparsePoint( + (IntPtr)C, (UIntPtr)CurrentReparseData.Length, + (IntPtr)R, (UIntPtr)ReplaceReparseData.Length); } internal static Int32 SetDebugLogFile(String FileName) @@ -979,6 +980,15 @@ namespace Fsp.Interop return 0/*STATUS_SUCCESS*/; } + internal static Version GetFspVersion() + { + UInt32 Version = 0, VersionMajor, VersionMinor; + FspVersion(out Version); + VersionMajor = Version >> 16; + VersionMinor = Version & 0xFFFF; + return new System.Version((Int32)VersionMajor, (Int32)VersionMinor); + } + /* initialization */ private static IntPtr LoadDll() { diff --git a/tst/memfs-dotnet/Program.cs b/tst/memfs-dotnet/Program.cs index a3802b61..f3d8c838 100644 --- a/tst/memfs-dotnet/Program.cs +++ b/tst/memfs-dotnet/Program.cs @@ -70,7 +70,7 @@ namespace memfs { FileInfo FileInfo = MainFileNode.FileInfo; FileInfo.FileAttributes &= ~(UInt32)FileAttributes.Directory; - /* named streams cannot be directories */ + /* named streams cannot be directories */ FileInfo.AllocationSize = this.FileInfo.AllocationSize; FileInfo.FileSize = this.FileInfo.FileSize; return FileInfo; @@ -255,6 +255,7 @@ namespace memfs Host.NamedStreams = true; Host.PostCleanupWhenModifiedOnly = true; Host.PassQueryDirectoryFileName = true; + Host.FlushAndPurgeOnCleanup = true; return STATUS_SUCCESS; } @@ -1066,40 +1067,40 @@ namespace memfs break; switch (Arg[1]) { - case '?': - throw new CommandLineUsageException(); - case 'D': - argtos(Args, ref I, ref DebugLogFile); - break; - case 'd': - argtol(Args, ref I, ref DebugFlags); - break; - case 'F': - argtos(Args, ref I, ref FileSystemName); - break; - case 'i': - CaseInsensitive = true; - break; - case 'm': - argtos(Args, ref I, ref MountPoint); - break; - case 'n': - argtol(Args, ref I, ref MaxFileNodes); - break; - case 'S': - argtos(Args, ref I, ref RootSddl); - break; - case 's': - argtol(Args, ref I, ref MaxFileSize); - break; - case 't': - argtol(Args, ref I, ref FileInfoTimeout); - break; - case 'u': - argtos(Args, ref I, ref VolumePrefix); - break; - default: - throw new CommandLineUsageException(); + case '?': + throw new CommandLineUsageException(); + case 'D': + argtos(Args, ref I, ref DebugLogFile); + break; + case 'd': + argtol(Args, ref I, ref DebugFlags); + break; + case 'F': + argtos(Args, ref I, ref FileSystemName); + break; + case 'i': + CaseInsensitive = true; + break; + case 'm': + argtos(Args, ref I, ref MountPoint); + break; + case 'n': + argtol(Args, ref I, ref MaxFileNodes); + break; + case 'S': + argtos(Args, ref I, ref RootSddl); + break; + case 's': + argtol(Args, ref I, ref MaxFileSize); + break; + case 't': + argtol(Args, ref I, ref FileInfoTimeout); + break; + case 'u': + argtos(Args, ref I, ref VolumePrefix); + break; + default: + throw new CommandLineUsageException(); } } From a7424c911bfe34564978c3043739fa5bec82620e Mon Sep 17 00:00:00 2001 From: FrKaram Date: Sun, 1 Jul 2018 13:29:52 +0200 Subject: [PATCH 03/12] Changes following PR remarks --- .gitignore | 6 ------ build/VStudio/.gitignore | 6 ------ src/dotnet/FileSystemHost.cs | 4 ++-- src/dotnet/Interop.cs | 12 +++++------- tst/memfs-dotnet/Program.cs | 1 - 5 files changed, 7 insertions(+), 22 deletions(-) delete mode 100644 .gitignore delete mode 100644 build/VStudio/.gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 48511677..00000000 --- a/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -################################################################################ -# This .gitignore file was automatically created by Microsoft(R) Visual Studio. -################################################################################ - -*.db -*.opendb diff --git a/build/VStudio/.gitignore b/build/VStudio/.gitignore deleted file mode 100644 index c23cca77..00000000 --- a/build/VStudio/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -build -*.ncb -*.suo -*.vcproj.* -*.vcxproj.user -*.csproj.user diff --git a/src/dotnet/FileSystemHost.cs b/src/dotnet/FileSystemHost.cs index 7d7cd53e..4bb9fc26 100644 --- a/src/dotnet/FileSystemHost.cs +++ b/src/dotnet/FileSystemHost.cs @@ -353,10 +353,10 @@ namespace Fsp return Api.SetDebugLogFile(FileName); } /// - /// Return the installed version for WinFSP + /// Return the installed version of WinFsp. /// /// - public static Version GetFspVersion() + public static Version Version() { return Api.GetFspVersion(); } diff --git a/src/dotnet/Interop.cs b/src/dotnet/Interop.cs index b00915e8..01e5f4e1 100644 --- a/src/dotnet/Interop.cs +++ b/src/dotnet/Interop.cs @@ -955,9 +955,9 @@ namespace Fsp.Interop { fixed (Byte *C = CurrentReparseData) fixed (Byte *R = ReplaceReparseData) - return _FspFileSystemCanReplaceReparsePoint( - (IntPtr)C, (UIntPtr)CurrentReparseData.Length, - (IntPtr)R, (UIntPtr)ReplaceReparseData.Length); + return _FspFileSystemCanReplaceReparsePoint( + (IntPtr)C, (UIntPtr)CurrentReparseData.Length, + (IntPtr)R, (UIntPtr)ReplaceReparseData.Length); } internal static Int32 SetDebugLogFile(String FileName) @@ -982,11 +982,9 @@ namespace Fsp.Interop internal static Version GetFspVersion() { - UInt32 Version = 0, VersionMajor, VersionMinor; + UInt32 Version = 0; FspVersion(out Version); - VersionMajor = Version >> 16; - VersionMinor = Version & 0xFFFF; - return new System.Version((Int32)VersionMajor, (Int32)VersionMinor); + return new System.Version((Int32)Version >> 16, (Int32)Version & 0xFFFF); } /* initialization */ diff --git a/tst/memfs-dotnet/Program.cs b/tst/memfs-dotnet/Program.cs index f3d8c838..fd258cd9 100644 --- a/tst/memfs-dotnet/Program.cs +++ b/tst/memfs-dotnet/Program.cs @@ -255,7 +255,6 @@ namespace memfs Host.NamedStreams = true; Host.PostCleanupWhenModifiedOnly = true; Host.PassQueryDirectoryFileName = true; - Host.FlushAndPurgeOnCleanup = true; return STATUS_SUCCESS; } From 916b4f5c3d4887623d167f05393ca8942dbfa53b Mon Sep 17 00:00:00 2001 From: FrKaram Date: Sun, 1 Jul 2018 13:35:25 +0200 Subject: [PATCH 04/12] Wrongly remove gitignore --- build/VStudio/.gitignore | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 build/VStudio/.gitignore diff --git a/build/VStudio/.gitignore b/build/VStudio/.gitignore new file mode 100644 index 00000000..c23cca77 --- /dev/null +++ b/build/VStudio/.gitignore @@ -0,0 +1,6 @@ +build +*.ncb +*.suo +*.vcproj.* +*.vcxproj.user +*.csproj.user From 88516f371a3091b2fc2ddfd0d2ba71e23ecc2a98 Mon Sep 17 00:00:00 2001 From: FrKaram Date: Sun, 1 Jul 2018 13:45:47 +0200 Subject: [PATCH 05/12] Fixed indentation --- src/dotnet/Interop.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/dotnet/Interop.cs b/src/dotnet/Interop.cs index 01e5f4e1..950dbe5a 100644 --- a/src/dotnet/Interop.cs +++ b/src/dotnet/Interop.cs @@ -904,17 +904,17 @@ namespace Fsp.Interop Byte[] ModificationDescriptorBytes) { fixed (Byte *S = SecurityDescriptorBytes) - fixed (Byte *M = ModificationDescriptorBytes) - { - IntPtr SecurityDescriptor; - Int32 Result = FspSetSecurityDescriptor( - (IntPtr)S, SecurityInformation, (IntPtr)M, out SecurityDescriptor); - if (0 > Result) - return null; - SecurityDescriptorBytes = MakeSecurityDescriptor(SecurityDescriptor); - FspDeleteSecurityDescriptor(SecurityDescriptor, _FspSetSecurityDescriptorPtr); - return SecurityDescriptorBytes; - } + fixed (Byte *M = ModificationDescriptorBytes) + { + IntPtr SecurityDescriptor; + Int32 Result = FspSetSecurityDescriptor( + (IntPtr)S, SecurityInformation, (IntPtr)M, out SecurityDescriptor); + if (0 > Result) + return null; + SecurityDescriptorBytes = MakeSecurityDescriptor(SecurityDescriptor); + FspDeleteSecurityDescriptor(SecurityDescriptor, _FspSetSecurityDescriptorPtr); + return SecurityDescriptorBytes; + } } internal unsafe static Int32 CopyReparsePoint( From 8422e8121c711dcc892141684716f18c262afa36 Mon Sep 17 00:00:00 2001 From: FrKaram Date: Sun, 1 Jul 2018 13:46:20 +0200 Subject: [PATCH 06/12] Fixed identation --- src/dotnet/Interop.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dotnet/Interop.cs b/src/dotnet/Interop.cs index 950dbe5a..f42dd098 100644 --- a/src/dotnet/Interop.cs +++ b/src/dotnet/Interop.cs @@ -954,10 +954,10 @@ namespace Fsp.Interop Byte[] ReplaceReparseData) { fixed (Byte *C = CurrentReparseData) - fixed (Byte *R = ReplaceReparseData) - return _FspFileSystemCanReplaceReparsePoint( - (IntPtr)C, (UIntPtr)CurrentReparseData.Length, - (IntPtr)R, (UIntPtr)ReplaceReparseData.Length); + fixed (Byte *R = ReplaceReparseData) + return _FspFileSystemCanReplaceReparsePoint( + (IntPtr)C, (UIntPtr)CurrentReparseData.Length, + (IntPtr)R, (UIntPtr)ReplaceReparseData.Length); } internal static Int32 SetDebugLogFile(String FileName) From c9c62b1831de7b79ad0f0723d367583790143d4f Mon Sep 17 00:00:00 2001 From: FrKaram Date: Sun, 1 Jul 2018 13:48:48 +0200 Subject: [PATCH 07/12] Fixed Indentation --- tst/memfs-dotnet/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tst/memfs-dotnet/Program.cs b/tst/memfs-dotnet/Program.cs index fd258cd9..3d5b04d2 100644 --- a/tst/memfs-dotnet/Program.cs +++ b/tst/memfs-dotnet/Program.cs @@ -70,7 +70,7 @@ namespace memfs { FileInfo FileInfo = MainFileNode.FileInfo; FileInfo.FileAttributes &= ~(UInt32)FileAttributes.Directory; - /* named streams cannot be directories */ + /* named streams cannot be directories */ FileInfo.AllocationSize = this.FileInfo.AllocationSize; FileInfo.FileSize = this.FileInfo.FileSize; return FileInfo; From 3513f0da5fac2aab63c7522a41c3aab5575c8b59 Mon Sep 17 00:00:00 2001 From: FrKaram Date: Sun, 1 Jul 2018 13:50:02 +0200 Subject: [PATCH 08/12] Correct VS auto-format --- tst/memfs-dotnet/Program.cs | 68 ++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/tst/memfs-dotnet/Program.cs b/tst/memfs-dotnet/Program.cs index 3d5b04d2..a3802b61 100644 --- a/tst/memfs-dotnet/Program.cs +++ b/tst/memfs-dotnet/Program.cs @@ -1066,40 +1066,40 @@ namespace memfs break; switch (Arg[1]) { - case '?': - throw new CommandLineUsageException(); - case 'D': - argtos(Args, ref I, ref DebugLogFile); - break; - case 'd': - argtol(Args, ref I, ref DebugFlags); - break; - case 'F': - argtos(Args, ref I, ref FileSystemName); - break; - case 'i': - CaseInsensitive = true; - break; - case 'm': - argtos(Args, ref I, ref MountPoint); - break; - case 'n': - argtol(Args, ref I, ref MaxFileNodes); - break; - case 'S': - argtos(Args, ref I, ref RootSddl); - break; - case 's': - argtol(Args, ref I, ref MaxFileSize); - break; - case 't': - argtol(Args, ref I, ref FileInfoTimeout); - break; - case 'u': - argtos(Args, ref I, ref VolumePrefix); - break; - default: - throw new CommandLineUsageException(); + case '?': + throw new CommandLineUsageException(); + case 'D': + argtos(Args, ref I, ref DebugLogFile); + break; + case 'd': + argtol(Args, ref I, ref DebugFlags); + break; + case 'F': + argtos(Args, ref I, ref FileSystemName); + break; + case 'i': + CaseInsensitive = true; + break; + case 'm': + argtos(Args, ref I, ref MountPoint); + break; + case 'n': + argtol(Args, ref I, ref MaxFileNodes); + break; + case 'S': + argtos(Args, ref I, ref RootSddl); + break; + case 's': + argtol(Args, ref I, ref MaxFileSize); + break; + case 't': + argtol(Args, ref I, ref FileInfoTimeout); + break; + case 'u': + argtos(Args, ref I, ref VolumePrefix); + break; + default: + throw new CommandLineUsageException(); } } From c73f7099b7f135cf1d5d3175ffefe9154c3c49b0 Mon Sep 17 00:00:00 2001 From: FrKaram Date: Sun, 1 Jul 2018 13:51:17 +0200 Subject: [PATCH 09/12] Indentation again --- src/dotnet/Interop.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dotnet/Interop.cs b/src/dotnet/Interop.cs index f42dd098..1db7d329 100644 --- a/src/dotnet/Interop.cs +++ b/src/dotnet/Interop.cs @@ -955,9 +955,9 @@ namespace Fsp.Interop { fixed (Byte *C = CurrentReparseData) fixed (Byte *R = ReplaceReparseData) - return _FspFileSystemCanReplaceReparsePoint( - (IntPtr)C, (UIntPtr)CurrentReparseData.Length, - (IntPtr)R, (UIntPtr)ReplaceReparseData.Length); + return _FspFileSystemCanReplaceReparsePoint( + (IntPtr)C, (UIntPtr)CurrentReparseData.Length, + (IntPtr)R, (UIntPtr)ReplaceReparseData.Length); } internal static Int32 SetDebugLogFile(String FileName) From 2056766b4f9b0395d63662c228c044aa7e459002 Mon Sep 17 00:00:00 2001 From: FrKaram Date: Sun, 1 Jul 2018 13:52:09 +0200 Subject: [PATCH 10/12] Indentation again --- src/dotnet/Interop.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dotnet/Interop.cs b/src/dotnet/Interop.cs index 1db7d329..41b65aea 100644 --- a/src/dotnet/Interop.cs +++ b/src/dotnet/Interop.cs @@ -955,9 +955,9 @@ namespace Fsp.Interop { fixed (Byte *C = CurrentReparseData) fixed (Byte *R = ReplaceReparseData) - return _FspFileSystemCanReplaceReparsePoint( - (IntPtr)C, (UIntPtr)CurrentReparseData.Length, - (IntPtr)R, (UIntPtr)ReplaceReparseData.Length); + return _FspFileSystemCanReplaceReparsePoint( + (IntPtr)C, (UIntPtr)CurrentReparseData.Length, + (IntPtr)R, (UIntPtr)ReplaceReparseData.Length); } internal static Int32 SetDebugLogFile(String FileName) From fd817e37c90f50da074d6406ab5b0d43582b06dd Mon Sep 17 00:00:00 2001 From: FrKaram Date: Tue, 3 Jul 2018 10:01:57 +0200 Subject: [PATCH 11/12] Updated Contributor Agreement --- Contributors.asciidoc | 1 + 1 file changed, 1 insertion(+) diff --git a/Contributors.asciidoc b/Contributors.asciidoc index ac89dd98..43e224bc 100644 --- a/Contributors.asciidoc +++ b/Contributors.asciidoc @@ -60,4 +60,5 @@ CONTRIBUTOR LIST |John Oberschelp |john at oberschelp.net |Sam Kelly (DuroSoft Technologies LLC, https://durosoft.com) |sam at durosoft.com |Tobias Urlaub |saibotu at outlook.de +|Francois Karam (KS2, http://www.ks2.fr) |francois.karam@ks2.fr |=== From ee4145e947de2e95cb3555346f4ad0fcd49763be Mon Sep 17 00:00:00 2001 From: Francois Karam Date: Tue, 3 Jul 2018 11:20:44 +0200 Subject: [PATCH 12/12] Update Contributors.asciidoc --- Contributors.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Contributors.asciidoc b/Contributors.asciidoc index 43e224bc..99c61678 100644 --- a/Contributors.asciidoc +++ b/Contributors.asciidoc @@ -60,5 +60,5 @@ CONTRIBUTOR LIST |John Oberschelp |john at oberschelp.net |Sam Kelly (DuroSoft Technologies LLC, https://durosoft.com) |sam at durosoft.com |Tobias Urlaub |saibotu at outlook.de -|Francois Karam (KS2, http://www.ks2.fr) |francois.karam@ks2.fr +|Francois Karam (KS2, http://www.ks2.fr) |francois.karam at ks2.fr |===