mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-23 17:03:12 -05:00
dll, sys: FSP_NEXT_EA
This commit is contained in:
parent
d59976bd5d
commit
d3efdd9219
@ -1805,19 +1805,14 @@ FSP_API NTSTATUS FspFileSystemEnumerateEa(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
PVOID Context,
|
PVOID Context,
|
||||||
PFILE_FULL_EA_INFORMATION Ea, ULONG EaLength)
|
PFILE_FULL_EA_INFORMATION Ea, ULONG EaLength)
|
||||||
{
|
{
|
||||||
PFILE_FULL_EA_INFORMATION EaEnd = (PVOID)((PUINT8)Ea + EaLength);
|
NTSTATUS Result = STATUS_SUCCESS;
|
||||||
NTSTATUS Result;
|
for (PFILE_FULL_EA_INFORMATION EaEnd = (PVOID)((PUINT8)Ea + EaLength);
|
||||||
|
EaEnd > Ea; FSP_NEXT_EA(Ea, EaEnd))
|
||||||
Result = STATUS_SUCCESS;
|
|
||||||
for (;
|
|
||||||
EaEnd > Ea && 0 != Ea->NextEntryOffset;
|
|
||||||
Ea = (PVOID)((PUINT8)Ea + Ea->NextEntryOffset))
|
|
||||||
{
|
{
|
||||||
Result = EnumerateEa(FileSystem, Context, Ea);
|
Result = EnumerateEa(FileSystem, Context, Ea);
|
||||||
if (!NT_SUCCESS(Result))
|
if (!NT_SUCCESS(Result))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,4 +92,7 @@ static inline BOOLEAN FspPathIsDrive(PWSTR FileName)
|
|||||||
L':' == FileName[1] && L'\0' == FileName[2];
|
L':' == FileName[1] && L'\0' == FileName[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define FSP_NEXT_EA(Ea, EaEnd) \
|
||||||
|
(0 != (Ea)->NextEntryOffset ? (PVOID)((PUINT8)(Ea) + (Ea)->NextEntryOffset) : (EaEnd))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -908,9 +908,10 @@ namespace Fsp.Interop
|
|||||||
FullEaInformation *EndP = (FullEaInformation *)(Ea.ToInt64() + EaLength);
|
FullEaInformation *EndP = (FullEaInformation *)(Ea.ToInt64() + EaLength);
|
||||||
Int32 Result;
|
Int32 Result;
|
||||||
Result = 0/*STATUS_SUCCESS*/;
|
Result = 0/*STATUS_SUCCESS*/;
|
||||||
for (;
|
for (; EndP > P;
|
||||||
EndP > P && 0 != P->NextEntryOffset;
|
P = 0 != P->NextEntryOffset ?
|
||||||
P = (FullEaInformation *)(((IntPtr)P).ToInt64() + P->NextEntryOffset))
|
(FullEaInformation *)(((IntPtr)P).ToInt64() + P->NextEntryOffset) :
|
||||||
|
EndP)
|
||||||
{
|
{
|
||||||
String EaName = Marshal.PtrToStringAnsi((IntPtr)P->EaName, P->EaNameLength);
|
String EaName = Marshal.PtrToStringAnsi((IntPtr)P->EaName, P->EaNameLength);
|
||||||
Byte[] EaValue = new Byte[P->EaValueLength];
|
Byte[] EaValue = new Byte[P->EaValueLength];
|
||||||
|
@ -573,6 +573,8 @@ NTSTATUS FspOplockFsctrl(
|
|||||||
FspNotifyFullChangeDirectory(NS, NL, FC, 0, 0, FALSE, 0, 0, 0, 0)
|
FspNotifyFullChangeDirectory(NS, NL, FC, 0, 0, FALSE, 0, 0, 0, 0)
|
||||||
#define FspNotifyReportChange(NS, NL, FN, FO, NP, F, A)\
|
#define FspNotifyReportChange(NS, NL, FN, FO, NP, F, A)\
|
||||||
FspNotifyFullReportChange(NS, NL, (PSTRING)(FN), FO, 0, (PSTRING)(NP), F, A, 0)
|
FspNotifyFullReportChange(NS, NL, (PSTRING)(FN), FO, 0, (PSTRING)(NP), F, A, 0)
|
||||||
|
#define FSP_NEXT_EA(Ea, EaEnd) \
|
||||||
|
(0 != (Ea)->NextEntryOffset ? (PVOID)((PUINT8)(Ea) + (Ea)->NextEntryOffset) : (EaEnd))
|
||||||
|
|
||||||
/* utility: synchronous work queue */
|
/* utility: synchronous work queue */
|
||||||
typedef struct
|
typedef struct
|
||||||
|
27
src/sys/ea.c
27
src/sys/ea.c
@ -97,17 +97,13 @@ static VOID FspFsvolQueryEaGetCopy(
|
|||||||
IoStatus->Status = STATUS_SUCCESS;
|
IoStatus->Status = STATUS_SUCCESS;
|
||||||
IoStatus->Information = 0;
|
IoStatus->Information = 0;
|
||||||
DstBuf = DstBufBgn, PrevDstBuf = 0;
|
DstBuf = DstBufBgn, PrevDstBuf = 0;
|
||||||
for (GetBuf = GetBufBgn;
|
for (GetBuf = GetBufBgn; GetBufEnd > GetBuf; GetBuf = FSP_NEXT_EA(GetBuf, GetBufEnd))
|
||||||
GetBufEnd > GetBuf && 0 != GetBuf->NextEntryOffset;
|
|
||||||
GetBuf = (PVOID)((PUINT8)GetBuf + GetBuf->NextEntryOffset))
|
|
||||||
{
|
{
|
||||||
GetName.Length = GetName.MaximumLength = GetBuf->EaNameLength;
|
GetName.Length = GetName.MaximumLength = GetBuf->EaNameLength;
|
||||||
GetName.Buffer = GetBuf->EaName;
|
GetName.Buffer = GetBuf->EaName;
|
||||||
|
|
||||||
/* ignore duplicate names */
|
/* ignore duplicate names */
|
||||||
for (Get = GetBufBgn;
|
for (Get = GetBufBgn; GetBuf > Get; Get = (PVOID)((PUINT8)Get + Get->NextEntryOffset))
|
||||||
GetBuf > Get;
|
|
||||||
Get = (PVOID)((PUINT8)Get + Get->NextEntryOffset))
|
|
||||||
{
|
{
|
||||||
Name.Length = Name.MaximumLength = Get->EaNameLength;
|
Name.Length = Name.MaximumLength = Get->EaNameLength;
|
||||||
Name.Buffer = Get->EaName;
|
Name.Buffer = Get->EaName;
|
||||||
@ -126,9 +122,7 @@ static VOID FspFsvolQueryEaGetCopy(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Src = GetBuf;
|
Src = GetBuf;
|
||||||
for (SrcBuf = SrcBufBgn;
|
for (SrcBuf = SrcBufBgn; SrcBufEnd > SrcBuf; SrcBuf = FSP_NEXT_EA(SrcBuf, SrcBufEnd))
|
||||||
SrcBufEnd > SrcBuf && 0 != SrcBuf->NextEntryOffset;
|
|
||||||
SrcBuf = (PVOID)((PUINT8)SrcBuf + SrcBuf->NextEntryOffset))
|
|
||||||
{
|
{
|
||||||
Name.Length = Name.MaximumLength = SrcBuf->EaNameLength;
|
Name.Length = Name.MaximumLength = SrcBuf->EaNameLength;
|
||||||
Name.Buffer = SrcBuf->EaName;
|
Name.Buffer = SrcBuf->EaName;
|
||||||
@ -201,18 +195,14 @@ static VOID FspFsvolQueryEaIndexCopy(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (SrcBuf = SrcBufBgn;
|
for (SrcBuf = SrcBufBgn; EaIndex < *PEaIndex && SrcBufEnd > SrcBuf;
|
||||||
EaIndex < *PEaIndex &&
|
SrcBuf = FSP_NEXT_EA(SrcBuf, SrcBufEnd), EaIndex++)
|
||||||
SrcBufEnd > SrcBuf && 0 != SrcBuf->NextEntryOffset;
|
|
||||||
SrcBuf = (PVOID)((PUINT8)SrcBuf + SrcBuf->NextEntryOffset), EaIndex++)
|
|
||||||
;
|
;
|
||||||
|
|
||||||
IoStatus->Status = STATUS_SUCCESS;
|
IoStatus->Status = STATUS_SUCCESS;
|
||||||
IoStatus->Information = 0;
|
IoStatus->Information = 0;
|
||||||
DstBuf = DstBufBgn, PrevDstBuf = 0;
|
DstBuf = DstBufBgn, PrevDstBuf = 0;
|
||||||
for (;
|
for (; SrcBufEnd > SrcBuf; SrcBuf = FSP_NEXT_EA(SrcBuf, SrcBufEnd), EaIndex++)
|
||||||
SrcBufEnd > SrcBuf && 0 != SrcBuf->NextEntryOffset;
|
|
||||||
SrcBuf = (PVOID)((PUINT8)SrcBuf + SrcBuf->NextEntryOffset), EaIndex++)
|
|
||||||
{
|
{
|
||||||
if ((PUINT8)DstBuf + FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName) > (PUINT8)DstBufEnd)
|
if ((PUINT8)DstBuf + FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName) > (PUINT8)DstBufEnd)
|
||||||
break;
|
break;
|
||||||
@ -256,7 +246,7 @@ static VOID FspFsvolQueryEaIndexCopy(
|
|||||||
if (SrcBufBgn == SrcBuf)
|
if (SrcBufBgn == SrcBuf)
|
||||||
IoStatus->Status = IndexSpecified ?
|
IoStatus->Status = IndexSpecified ?
|
||||||
STATUS_NONEXISTENT_EA_ENTRY : STATUS_NO_EAS_ON_FILE;
|
STATUS_NONEXISTENT_EA_ENTRY : STATUS_NO_EAS_ON_FILE;
|
||||||
else if (SrcBufEnd > SrcBuf && 0 != SrcBuf->NextEntryOffset)
|
else if (SrcBufEnd > SrcBuf)
|
||||||
IoStatus->Status = STATUS_BUFFER_TOO_SMALL;
|
IoStatus->Status = STATUS_BUFFER_TOO_SMALL;
|
||||||
else
|
else
|
||||||
IoStatus->Status = IndexSpecified && *PEaIndex != EaIndex ?
|
IoStatus->Status = IndexSpecified && *PEaIndex != EaIndex ?
|
||||||
@ -503,8 +493,7 @@ static NTSTATUS FspFsvolSetEa(
|
|||||||
return Result;
|
return Result;
|
||||||
|
|
||||||
for (PFILE_FULL_EA_INFORMATION Ea = Buffer, EaEnd = (PVOID)((PUINT8)Ea + Length);
|
for (PFILE_FULL_EA_INFORMATION Ea = Buffer, EaEnd = (PVOID)((PUINT8)Ea + Length);
|
||||||
EaEnd > Ea && 0 != Ea->NextEntryOffset;
|
EaEnd > Ea; Ea = FSP_NEXT_EA(Ea, EaEnd))
|
||||||
Ea = (PVOID)((PUINT8)Ea + Ea->NextEntryOffset))
|
|
||||||
{
|
{
|
||||||
STRING Name;
|
STRING Name;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user