dotnet: EA support

This commit is contained in:
Bill Zissimopoulos 2019-03-21 15:05:14 -07:00
parent 62b0e889b2
commit 948254f083
No known key found for this signature in database
GPG Key ID: 3D4F95D52C7B3EA3
2 changed files with 26 additions and 1 deletions

View File

@ -1445,6 +1445,13 @@ namespace Fsp
return self.ExceptionHandler(ex); return self.ExceptionHandler(ex);
} }
} }
public static UInt32 GetEaEntrySize(
String EaName,
Byte[] EaValue,
Boolean NeedEa)
{
return FullEaInformation.Size(EaName, EaValue, NeedEa);
}
} }
} }

View File

@ -196,6 +196,10 @@ namespace Fsp.Interop
/// Not currently implemented. Set to 0. /// Not currently implemented. Set to 0.
/// </summary> /// </summary>
public UInt32 HardLinks; public UInt32 HardLinks;
/// <summary>
/// The extended attribute size of the file.
/// </summary>
public UInt32 EaSize;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
@ -274,7 +278,13 @@ namespace Fsp.Interop
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal struct FullEaInformation 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 UInt32 NextEntryOffset;
internal Byte Flags; internal Byte Flags;
@ -303,6 +313,14 @@ namespace Fsp.Interop
P[I + J] = Value[J]; 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)] [StructLayout(LayoutKind.Sequential)]