From 948254f08356c7cf35c3202d35816eb54f64c44f Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Thu, 21 Mar 2019 15:05:14 -0700 Subject: [PATCH] dotnet: EA support --- src/dotnet/FileSystemBase.cs | 7 +++++++ src/dotnet/Interop.cs | 20 +++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/dotnet/FileSystemBase.cs b/src/dotnet/FileSystemBase.cs index 1991d188..2fea3c5c 100644 --- a/src/dotnet/FileSystemBase.cs +++ b/src/dotnet/FileSystemBase.cs @@ -1445,6 +1445,13 @@ namespace Fsp return self.ExceptionHandler(ex); } } + public static UInt32 GetEaEntrySize( + String EaName, + Byte[] EaValue, + Boolean NeedEa) + { + return FullEaInformation.Size(EaName, EaValue, NeedEa); + } } } diff --git a/src/dotnet/Interop.cs b/src/dotnet/Interop.cs index 7bc38599..0f5f471a 100644 --- a/src/dotnet/Interop.cs +++ b/src/dotnet/Interop.cs @@ -196,6 +196,10 @@ namespace Fsp.Interop /// Not currently implemented. Set to 0. /// public UInt32 HardLinks; + /// + /// The extended attribute size of the file. + /// + public UInt32 EaSize; } [StructLayout(LayoutKind.Sequential)] @@ -274,7 +278,13 @@ namespace Fsp.Interop [StructLayout(LayoutKind.Sequential)] internal struct FullEaInformation { - internal const int EaNameSize = 16384 - 8; + internal const int EaNameSize = 15 * 1024; + /* Set this to a value smaller than 16384 with sufficient space for additional data. + * This should really be: + * FSP_FSCTL_TRANSACT_RSP_BUFFER_SIZEMAX - FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName) + */ + internal static int EaNameOffset = + (int)Marshal.OffsetOf(typeof(FullEaInformation), "EaName"); internal UInt32 NextEntryOffset; internal Byte Flags; @@ -303,6 +313,14 @@ namespace Fsp.Interop P[I + J] = Value[J]; } } + internal static UInt32 Size(String Name, Byte[] Value, Boolean NeedEa) + { + int NameLength = 254 < Name.Length ? 254 : Name.Length; + int ValueLength = EaNameSize - Name.Length - 1 < Value.Length ? + EaNameSize - Name.Length - 1 : Value.Length; + + return (UInt32)((EaNameOffset + NameLength + 1 + ValueLength + 3) & ~3); + } } [StructLayout(LayoutKind.Sequential)]