tst: memfs: MEMFS_REPARSE_POINTS conditional

This commit is contained in:
Bill Zissimopoulos 2016-12-08 18:58:05 -08:00
parent ee3918436b
commit 228f9e2708

View File

@ -23,16 +23,21 @@
#include <map> #include <map>
#include <unordered_map> #include <unordered_map>
/*
* Define the MEMFS_NAMED_STREAMS macro to include named streams support.
*/
#define MEMFS_NAMED_STREAMS
/* /*
* Define the MEMFS_NAME_NORMALIZATION macro to include name normalization support. * Define the MEMFS_NAME_NORMALIZATION macro to include name normalization support.
*/ */
#define MEMFS_NAME_NORMALIZATION #define MEMFS_NAME_NORMALIZATION
/*
* Define the MEMFS_REPARSE_POINTS macro to include reparse points support.
*/
#define MEMFS_REPARSE_POINTS
/*
* Define the MEMFS_NAMED_STREAMS macro to include named streams support.
*/
#define MEMFS_NAMED_STREAMS
/* /*
* Define the DEBUG_BUFFER_CHECK macro on Windows 8 or above. This includes * Define the DEBUG_BUFFER_CHECK macro on Windows 8 or above. This includes
* a check for the Write buffer to ensure that it is read-only. * a check for the Write buffer to ensure that it is read-only.
@ -177,8 +182,10 @@ typedef struct _MEMFS_FILE_NODE
SIZE_T FileSecuritySize; SIZE_T FileSecuritySize;
PVOID FileSecurity; PVOID FileSecurity;
PVOID FileData; PVOID FileData;
#if defined(MEMFS_REPARSE_POINTS)
SIZE_T ReparseDataSize; SIZE_T ReparseDataSize;
PVOID ReparseData; PVOID ReparseData;
#endif
ULONG RefCount; ULONG RefCount;
#if defined(MEMFS_NAMED_STREAMS) #if defined(MEMFS_NAMED_STREAMS)
struct _MEMFS_FILE_NODE *MainFileNode; struct _MEMFS_FILE_NODE *MainFileNode;
@ -239,7 +246,9 @@ NTSTATUS MemfsFileNodeCreate(PWSTR FileName, MEMFS_FILE_NODE **PFileNode)
static inline static inline
VOID MemfsFileNodeDelete(MEMFS_FILE_NODE *FileNode) VOID MemfsFileNodeDelete(MEMFS_FILE_NODE *FileNode)
{ {
#if defined(MEMFS_REPARSE_POINTS)
free(FileNode->ReparseData); free(FileNode->ReparseData);
#endif
LargeHeapFree(FileNode->FileData); LargeHeapFree(FileNode->FileData);
free(FileNode->FileSecurity); free(FileNode->FileSecurity);
free(FileNode); free(FileNode);
@ -551,9 +560,11 @@ NTSTATUS MemfsDirDescInsertFileName(MEMFS_DIR_DESC *DirDesc, UINT64 Offset, PWST
* FSP_FILE_SYSTEM_INTERFACE * FSP_FILE_SYSTEM_INTERFACE
*/ */
#if defined(MEMFS_REPARSE_POINTS)
static NTSTATUS GetReparsePointByName( static NTSTATUS GetReparsePointByName(
FSP_FILE_SYSTEM *FileSystem, PVOID Context, FSP_FILE_SYSTEM *FileSystem, PVOID Context,
PWSTR FileName, BOOLEAN IsDirectory, PVOID Buffer, PSIZE_T PSize); PWSTR FileName, BOOLEAN IsDirectory, PVOID Buffer, PSIZE_T PSize);
#endif
static NTSTATUS SetFileSize(FSP_FILE_SYSTEM *FileSystem, static NTSTATUS SetFileSize(FSP_FILE_SYSTEM *FileSystem,
PVOID FileNode0, UINT64 NewSize, BOOLEAN SetAllocationSize, PVOID FileNode0, UINT64 NewSize, BOOLEAN SetAllocationSize,
@ -606,10 +617,12 @@ static NTSTATUS GetSecurityByName(FSP_FILE_SYSTEM *FileSystem,
{ {
Result = STATUS_OBJECT_NAME_NOT_FOUND; Result = STATUS_OBJECT_NAME_NOT_FOUND;
#if defined(MEMFS_REPARSE_POINTS)
if (FspFileSystemFindReparsePoint(FileSystem, GetReparsePointByName, 0, if (FspFileSystemFindReparsePoint(FileSystem, GetReparsePointByName, 0,
FileName, PFileAttributes)) FileName, PFileAttributes))
Result = STATUS_REPARSE; Result = STATUS_REPARSE;
else else
#endif
MemfsFileNodeMapGetParent(Memfs->FileNodeMap, FileName, &Result); MemfsFileNodeMapGetParent(Memfs->FileNodeMap, FileName, &Result);
return Result; return Result;
@ -1371,6 +1384,7 @@ static NTSTATUS ReadDirectory(FSP_FILE_SYSTEM *FileSystem,
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
#if defined(MEMFS_REPARSE_POINTS)
static NTSTATUS ResolveReparsePoints(FSP_FILE_SYSTEM *FileSystem, static NTSTATUS ResolveReparsePoints(FSP_FILE_SYSTEM *FileSystem,
PWSTR FileName, UINT32 ReparsePointIndex, BOOLEAN ResolveLastPathComponent, PWSTR FileName, UINT32 ReparsePointIndex, BOOLEAN ResolveLastPathComponent,
PIO_STATUS_BLOCK PIoStatus, PVOID Buffer, PSIZE_T PSize) PIO_STATUS_BLOCK PIoStatus, PVOID Buffer, PSIZE_T PSize)
@ -1506,6 +1520,7 @@ static NTSTATUS DeleteReparsePoint(FSP_FILE_SYSTEM *FileSystem,
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
#endif
#if defined(MEMFS_NAMED_STREAMS) #if defined(MEMFS_NAMED_STREAMS)
typedef struct _MEMFS_GET_STREAM_INFO_CONTEXT typedef struct _MEMFS_GET_STREAM_INFO_CONTEXT
@ -1593,10 +1608,17 @@ static FSP_FILE_SYSTEM_INTERFACE MemfsInterface =
GetSecurity, GetSecurity,
SetSecurity, SetSecurity,
ReadDirectory, ReadDirectory,
#if defined(MEMFS_REPARSE_POINTS)
ResolveReparsePoints, ResolveReparsePoints,
GetReparsePoint, GetReparsePoint,
SetReparsePoint, SetReparsePoint,
DeleteReparsePoint, DeleteReparsePoint,
#else
0,
0,
0,
0,
#endif
#if defined(MEMFS_NAMED_STREAMS) #if defined(MEMFS_NAMED_STREAMS)
GetStreamInfo, GetStreamInfo,
#else #else