Added FpsVersion as a static method in FileSystemHost

Added FlushAndPurgeOnCleanup
This commit is contained in:
FrKaram 2018-06-30 20:20:17 +02:00
parent d0f5ea69a2
commit fb8cb8aca9
4 changed files with 75 additions and 50 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
################################################################################ ################################################################################
*.db *.db
*.opendb

View File

@ -194,6 +194,11 @@ namespace Fsp
get { return 0 != (_VolumeParams.Flags & VolumeParams.PassQueryDirectoryFileName); } get { return 0 != (_VolumeParams.Flags & VolumeParams.PassQueryDirectoryFileName); }
set { _VolumeParams.Flags |= (value ? VolumeParams.PassQueryDirectoryFileName : 0); } set { _VolumeParams.Flags |= (value ? VolumeParams.PassQueryDirectoryFileName : 0); }
} }
public Boolean FlushAndPurgeOnCleanup
{
get { return 0 != (_VolumeParams.Flags & VolumeParams.FlushAndPurgeOnCleanup); }
set { _VolumeParams.Flags |= (value ? VolumeParams.FlushAndPurgeOnCleanup : 0); }
}
/// <summary> /// <summary>
/// Gets or sets the prefix for a network file system. /// Gets or sets the prefix for a network file system.
/// </summary> /// </summary>
@ -347,6 +352,14 @@ namespace Fsp
{ {
return Api.SetDebugLogFile(FileName); return Api.SetDebugLogFile(FileName);
} }
/// <summary>
/// Return the installed version for WinFSP
/// </summary>
/// <returns></returns>
public static Version GetFspVersion()
{
return Api.GetFspVersion();
}
/* FSP_FILE_SYSTEM_INTERFACE */ /* FSP_FILE_SYSTEM_INTERFACE */
private static Byte[] ByteBufferNotNull = new Byte[0]; private static Byte[] ByteBufferNotNull = new Byte[0];

View File

@ -43,6 +43,7 @@ namespace Fsp.Interop
internal const UInt32 PassQueryDirectoryPattern = 0x00000800; internal const UInt32 PassQueryDirectoryPattern = 0x00000800;
internal const UInt32 AlwaysUseDoubleBuffering = 0x00001000; internal const UInt32 AlwaysUseDoubleBuffering = 0x00001000;
internal const UInt32 PassQueryDirectoryFileName = 0x00002000; internal const UInt32 PassQueryDirectoryFileName = 0x00002000;
internal const UInt32 FlushAndPurgeOnCleanup = 0x00004000;
internal const UInt32 UmFileContextIsUserContext2 = 0x00010000; internal const UInt32 UmFileContextIsUserContext2 = 0x00010000;
internal const UInt32 UmFileContextIsFullContext = 0x00020000; internal const UInt32 UmFileContextIsFullContext = 0x00020000;
internal const int PrefixSize = 192; internal const int PrefixSize = 192;
@ -903,17 +904,17 @@ namespace Fsp.Interop
Byte[] ModificationDescriptorBytes) Byte[] ModificationDescriptorBytes)
{ {
fixed (Byte *S = SecurityDescriptorBytes) fixed (Byte *S = SecurityDescriptorBytes)
fixed (Byte *M = ModificationDescriptorBytes) fixed (Byte *M = ModificationDescriptorBytes)
{ {
IntPtr SecurityDescriptor; IntPtr SecurityDescriptor;
Int32 Result = FspSetSecurityDescriptor( Int32 Result = FspSetSecurityDescriptor(
(IntPtr)S, SecurityInformation, (IntPtr)M, out SecurityDescriptor); (IntPtr)S, SecurityInformation, (IntPtr)M, out SecurityDescriptor);
if (0 > Result) if (0 > Result)
return null; return null;
SecurityDescriptorBytes = MakeSecurityDescriptor(SecurityDescriptor); SecurityDescriptorBytes = MakeSecurityDescriptor(SecurityDescriptor);
FspDeleteSecurityDescriptor(SecurityDescriptor, _FspSetSecurityDescriptorPtr); FspDeleteSecurityDescriptor(SecurityDescriptor, _FspSetSecurityDescriptorPtr);
return SecurityDescriptorBytes; return SecurityDescriptorBytes;
} }
} }
internal unsafe static Int32 CopyReparsePoint( internal unsafe static Int32 CopyReparsePoint(
@ -953,10 +954,10 @@ namespace Fsp.Interop
Byte[] ReplaceReparseData) Byte[] ReplaceReparseData)
{ {
fixed (Byte *C = CurrentReparseData) fixed (Byte *C = CurrentReparseData)
fixed (Byte *R = ReplaceReparseData) fixed (Byte *R = ReplaceReparseData)
return _FspFileSystemCanReplaceReparsePoint( return _FspFileSystemCanReplaceReparsePoint(
(IntPtr)C, (UIntPtr)CurrentReparseData.Length, (IntPtr)C, (UIntPtr)CurrentReparseData.Length,
(IntPtr)R, (UIntPtr)ReplaceReparseData.Length); (IntPtr)R, (UIntPtr)ReplaceReparseData.Length);
} }
internal static Int32 SetDebugLogFile(String FileName) internal static Int32 SetDebugLogFile(String FileName)
@ -979,6 +980,15 @@ namespace Fsp.Interop
return 0/*STATUS_SUCCESS*/; 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 */ /* initialization */
private static IntPtr LoadDll() private static IntPtr LoadDll()
{ {

View File

@ -70,7 +70,7 @@ namespace memfs
{ {
FileInfo FileInfo = MainFileNode.FileInfo; FileInfo FileInfo = MainFileNode.FileInfo;
FileInfo.FileAttributes &= ~(UInt32)FileAttributes.Directory; FileInfo.FileAttributes &= ~(UInt32)FileAttributes.Directory;
/* named streams cannot be directories */ /* named streams cannot be directories */
FileInfo.AllocationSize = this.FileInfo.AllocationSize; FileInfo.AllocationSize = this.FileInfo.AllocationSize;
FileInfo.FileSize = this.FileInfo.FileSize; FileInfo.FileSize = this.FileInfo.FileSize;
return FileInfo; return FileInfo;
@ -255,6 +255,7 @@ namespace memfs
Host.NamedStreams = true; Host.NamedStreams = true;
Host.PostCleanupWhenModifiedOnly = true; Host.PostCleanupWhenModifiedOnly = true;
Host.PassQueryDirectoryFileName = true; Host.PassQueryDirectoryFileName = true;
Host.FlushAndPurgeOnCleanup = true;
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -1066,40 +1067,40 @@ namespace memfs
break; break;
switch (Arg[1]) switch (Arg[1])
{ {
case '?': case '?':
throw new CommandLineUsageException(); throw new CommandLineUsageException();
case 'D': case 'D':
argtos(Args, ref I, ref DebugLogFile); argtos(Args, ref I, ref DebugLogFile);
break; break;
case 'd': case 'd':
argtol(Args, ref I, ref DebugFlags); argtol(Args, ref I, ref DebugFlags);
break; break;
case 'F': case 'F':
argtos(Args, ref I, ref FileSystemName); argtos(Args, ref I, ref FileSystemName);
break; break;
case 'i': case 'i':
CaseInsensitive = true; CaseInsensitive = true;
break; break;
case 'm': case 'm':
argtos(Args, ref I, ref MountPoint); argtos(Args, ref I, ref MountPoint);
break; break;
case 'n': case 'n':
argtol(Args, ref I, ref MaxFileNodes); argtol(Args, ref I, ref MaxFileNodes);
break; break;
case 'S': case 'S':
argtos(Args, ref I, ref RootSddl); argtos(Args, ref I, ref RootSddl);
break; break;
case 's': case 's':
argtol(Args, ref I, ref MaxFileSize); argtol(Args, ref I, ref MaxFileSize);
break; break;
case 't': case 't':
argtol(Args, ref I, ref FileInfoTimeout); argtol(Args, ref I, ref FileInfoTimeout);
break; break;
case 'u': case 'u':
argtos(Args, ref I, ref VolumePrefix); argtos(Args, ref I, ref VolumePrefix);
break; break;
default: default:
throw new CommandLineUsageException(); throw new CommandLineUsageException();
} }
} }