mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-23 08:53:01 -05:00
sys: Create requests now send additional information on response
This commit is contained in:
parent
c15ace9653
commit
68795652b3
@ -164,12 +164,19 @@ typedef struct
|
|||||||
/* IoStatus.Status == STATUS_SUCCESS */
|
/* IoStatus.Status == STATUS_SUCCESS */
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
UINT64 UserContext; /* user context (unique file id) associated with file node */
|
UINT64 UserContext; /* user context associated with file node */
|
||||||
UINT64 UserContext2; /* user context associated with file descriptor (handle) */
|
UINT64 UserContext2; /* user context associated with file descriptor (handle) */
|
||||||
UINT32 FileAttributes; /* file attributes of opened file */
|
UINT32 FileAttributes; /* file attributes of opened file */
|
||||||
|
UINT32 ReparseTag; /* reparse tag of opened file (FILE_ATTRIBUTE_REPARSE_POINT) */
|
||||||
UINT64 AllocationSize; /* file allocation size */
|
UINT64 AllocationSize; /* file allocation size */
|
||||||
UINT64 FileSize; /* file size */
|
UINT64 FileSize; /* file size */
|
||||||
|
UINT64 CreationTime;
|
||||||
|
UINT64 LastAccessTime;
|
||||||
|
UINT64 LastWriteTime;
|
||||||
|
UINT64 ChangeTime;
|
||||||
|
UINT64 IndexNumber; /* unique file id */
|
||||||
UINT32 GrantedAccess; /* FILE_{READ_DATA,WRITE_DATA,etc.} */
|
UINT32 GrantedAccess; /* FILE_{READ_DATA,WRITE_DATA,etc.} */
|
||||||
|
|
||||||
} Opened;
|
} Opened;
|
||||||
/* IoStatus.Status == STATUS_REPARSE */
|
/* IoStatus.Status == STATUS_REPARSE */
|
||||||
struct
|
struct
|
||||||
|
@ -35,8 +35,14 @@ typedef struct _FSP_FILE_NODE_INFO
|
|||||||
{
|
{
|
||||||
PVOID FileNode;
|
PVOID FileNode;
|
||||||
DWORD FileAttributes;
|
DWORD FileAttributes;
|
||||||
|
DWORD ReparseTag;
|
||||||
UINT64 AllocationSize;
|
UINT64 AllocationSize;
|
||||||
UINT64 FileSize;
|
UINT64 FileSize;
|
||||||
|
UINT64 CreationTime;
|
||||||
|
UINT64 LastAccessTime;
|
||||||
|
UINT64 LastWriteTime;
|
||||||
|
UINT64 ChangeTime;
|
||||||
|
UINT64 IndexNumber;
|
||||||
} FSP_FILE_NODE_INFO;
|
} FSP_FILE_NODE_INFO;
|
||||||
typedef struct _FSP_FILE_SIZE_INFO
|
typedef struct _FSP_FILE_SIZE_INFO
|
||||||
{
|
{
|
||||||
|
@ -574,8 +574,14 @@ FSP_API NTSTATUS FspFileSystemSendCreateResponse(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
Response.IoStatus.Information = Information;
|
Response.IoStatus.Information = Information;
|
||||||
Response.Rsp.Create.Opened.UserContext = (UINT_PTR)NodeInfo->FileNode;
|
Response.Rsp.Create.Opened.UserContext = (UINT_PTR)NodeInfo->FileNode;
|
||||||
Response.Rsp.Create.Opened.FileAttributes = NodeInfo->FileAttributes;
|
Response.Rsp.Create.Opened.FileAttributes = NodeInfo->FileAttributes;
|
||||||
|
Response.Rsp.Create.Opened.ReparseTag = NodeInfo->ReparseTag;
|
||||||
Response.Rsp.Create.Opened.AllocationSize = NodeInfo->AllocationSize;
|
Response.Rsp.Create.Opened.AllocationSize = NodeInfo->AllocationSize;
|
||||||
Response.Rsp.Create.Opened.FileSize = NodeInfo->FileSize;
|
Response.Rsp.Create.Opened.FileSize = NodeInfo->FileSize;
|
||||||
|
Response.Rsp.Create.Opened.CreationTime = NodeInfo->CreationTime;
|
||||||
|
Response.Rsp.Create.Opened.LastAccessTime = NodeInfo->LastAccessTime;
|
||||||
|
Response.Rsp.Create.Opened.LastWriteTime = NodeInfo->LastWriteTime;
|
||||||
|
Response.Rsp.Create.Opened.ChangeTime = NodeInfo->ChangeTime;
|
||||||
|
Response.Rsp.Create.Opened.IndexNumber = NodeInfo->IndexNumber;
|
||||||
Response.Rsp.Create.Opened.GrantedAccess = GrantedAccess;
|
Response.Rsp.Create.Opened.GrantedAccess = GrantedAccess;
|
||||||
return FspFileSystemSendResponse(FileSystem, &Response);
|
return FspFileSystemSendResponse(FileSystem, &Response);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,14 @@
|
|||||||
|
|
||||||
#define MEMFS_SECTOR_SIZE 512
|
#define MEMFS_SECTOR_SIZE 512
|
||||||
|
|
||||||
|
static inline
|
||||||
|
UINT64 MemfsGetSystemTime(VOID)
|
||||||
|
{
|
||||||
|
FILETIME FileTime;
|
||||||
|
GetSystemTimeAsFileTime(&FileTime);
|
||||||
|
return ((PLARGE_INTEGER)&FileTime)->QuadPart;
|
||||||
|
}
|
||||||
|
|
||||||
static inline
|
static inline
|
||||||
int MemfsFileNameCompare(PWSTR a, PWSTR b)
|
int MemfsFileNameCompare(PWSTR a, PWSTR b)
|
||||||
{
|
{
|
||||||
@ -19,11 +27,9 @@ int MemfsFileNameCompare(PWSTR a, PWSTR b)
|
|||||||
typedef struct _MEMFS_FILE_NODE
|
typedef struct _MEMFS_FILE_NODE
|
||||||
{
|
{
|
||||||
WCHAR FileName[MAX_PATH];
|
WCHAR FileName[MAX_PATH];
|
||||||
DWORD FileAttributes;
|
FSP_FILE_NODE_INFO NodeInfo;
|
||||||
SIZE_T FileSecuritySize;
|
SIZE_T FileSecuritySize;
|
||||||
PVOID FileSecurity;
|
PVOID FileSecurity;
|
||||||
ULONG AllocationSize;
|
|
||||||
ULONG FileSize;
|
|
||||||
PVOID FileData;
|
PVOID FileData;
|
||||||
ULONG RefCount;
|
ULONG RefCount;
|
||||||
} MEMFS_FILE_NODE;
|
} MEMFS_FILE_NODE;
|
||||||
@ -49,6 +55,7 @@ typedef struct _MEMFS
|
|||||||
static inline
|
static inline
|
||||||
NTSTATUS MemfsFileNodeCreate(PWSTR FileName, MEMFS_FILE_NODE **PFileNode)
|
NTSTATUS MemfsFileNodeCreate(PWSTR FileName, MEMFS_FILE_NODE **PFileNode)
|
||||||
{
|
{
|
||||||
|
static UINT64 IndexNumber = 1;
|
||||||
MEMFS_FILE_NODE *FileNode;
|
MEMFS_FILE_NODE *FileNode;
|
||||||
|
|
||||||
*PFileNode = 0;
|
*PFileNode = 0;
|
||||||
@ -62,6 +69,12 @@ NTSTATUS MemfsFileNodeCreate(PWSTR FileName, MEMFS_FILE_NODE **PFileNode)
|
|||||||
|
|
||||||
memset(FileNode, 0, sizeof *FileNode);
|
memset(FileNode, 0, sizeof *FileNode);
|
||||||
wcscpy_s(FileNode->FileName, sizeof FileNode->FileName / sizeof(WCHAR), FileName);
|
wcscpy_s(FileNode->FileName, sizeof FileNode->FileName / sizeof(WCHAR), FileName);
|
||||||
|
FileNode->NodeInfo.FileNode = FileNode;
|
||||||
|
FileNode->NodeInfo.CreationTime =
|
||||||
|
FileNode->NodeInfo.LastAccessTime =
|
||||||
|
FileNode->NodeInfo.LastWriteTime =
|
||||||
|
FileNode->NodeInfo.ChangeTime = MemfsGetSystemTime();
|
||||||
|
FileNode->NodeInfo.IndexNumber = IndexNumber++;
|
||||||
|
|
||||||
*PFileNode = FileNode;
|
*PFileNode = FileNode;
|
||||||
|
|
||||||
@ -128,7 +141,7 @@ MEMFS_FILE_NODE *MemfsFileNodeMapGetParent(MEMFS_FILE_NODE_MAP *FileNodeMap, PWS
|
|||||||
*PResult = STATUS_OBJECT_PATH_NOT_FOUND;
|
*PResult = STATUS_OBJECT_PATH_NOT_FOUND;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (0 == (iter->second->FileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
if (0 == (iter->second->NodeInfo.FileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
||||||
{
|
{
|
||||||
*PResult = STATUS_NOT_A_DIRECTORY;
|
*PResult = STATUS_NOT_A_DIRECTORY;
|
||||||
return 0;
|
return 0;
|
||||||
@ -192,7 +205,7 @@ static NTSTATUS GetSecurity(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (0 != PFileAttributes)
|
if (0 != PFileAttributes)
|
||||||
*PFileAttributes = FileNode->FileAttributes;
|
*PFileAttributes = FileNode->NodeInfo.FileAttributes;
|
||||||
|
|
||||||
if (0 != PSecurityDescriptorSize)
|
if (0 != PSecurityDescriptorSize)
|
||||||
{
|
{
|
||||||
@ -241,7 +254,7 @@ static NTSTATUS Create(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
if (!NT_SUCCESS(Result))
|
if (!NT_SUCCESS(Result))
|
||||||
return Result;
|
return Result;
|
||||||
|
|
||||||
FileNode->FileAttributes = FileAttributes;
|
FileNode->NodeInfo.FileAttributes = FileAttributes;
|
||||||
|
|
||||||
if (0 != SecurityDescriptor)
|
if (0 != SecurityDescriptor)
|
||||||
{
|
{
|
||||||
@ -255,10 +268,10 @@ static NTSTATUS Create(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
memcpy(FileNode->FileSecurity, SecurityDescriptor, FileNode->FileSecuritySize);
|
memcpy(FileNode->FileSecurity, SecurityDescriptor, FileNode->FileSecuritySize);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileNode->AllocationSize = FSP_FSCTL_ALIGN_UP((ULONG)AllocationSize, MEMFS_SECTOR_SIZE);
|
FileNode->NodeInfo.AllocationSize = FSP_FSCTL_ALIGN_UP((ULONG)AllocationSize, MEMFS_SECTOR_SIZE);
|
||||||
if (0 != FileNode->AllocationSize)
|
if (0 != FileNode->NodeInfo.AllocationSize)
|
||||||
{
|
{
|
||||||
FileNode->FileData = malloc(FileNode->AllocationSize);
|
FileNode->FileData = malloc(FileNode->NodeInfo.AllocationSize);
|
||||||
if (0 == FileNode->FileData)
|
if (0 == FileNode->FileData)
|
||||||
{
|
{
|
||||||
MemfsFileNodeDelete(FileNode);
|
MemfsFileNodeDelete(FileNode);
|
||||||
@ -276,10 +289,7 @@ static NTSTATUS Create(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
}
|
}
|
||||||
|
|
||||||
FileNode->RefCount++;
|
FileNode->RefCount++;
|
||||||
NodeInfo->FileAttributes = FileNode->FileAttributes;
|
memcpy(NodeInfo, &FileNode->NodeInfo, sizeof *NodeInfo);
|
||||||
NodeInfo->AllocationSize = FileNode->AllocationSize;
|
|
||||||
NodeInfo->FileSize = FileNode->FileSize;
|
|
||||||
NodeInfo->FileNode = FileNode;
|
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -301,11 +311,10 @@ static NTSTATUS Open(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FileNode->NodeInfo.LastAccessTime = MemfsGetSystemTime();
|
||||||
|
|
||||||
FileNode->RefCount++;
|
FileNode->RefCount++;
|
||||||
NodeInfo->FileAttributes = FileNode->FileAttributes;
|
memcpy(NodeInfo, &FileNode->NodeInfo, sizeof *NodeInfo);
|
||||||
NodeInfo->AllocationSize = FileNode->AllocationSize;
|
|
||||||
NodeInfo->FileSize = FileNode->FileSize;
|
|
||||||
NodeInfo->FileNode = FileNode;
|
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -319,14 +328,16 @@ static NTSTATUS Overwrite(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
MEMFS_FILE_NODE *FileNode = (MEMFS_FILE_NODE *)FileNode0;
|
MEMFS_FILE_NODE *FileNode = (MEMFS_FILE_NODE *)FileNode0;
|
||||||
|
|
||||||
if (ReplaceFileAttributes)
|
if (ReplaceFileAttributes)
|
||||||
FileNode->FileAttributes = FileAttributes;
|
FileNode->NodeInfo.FileAttributes = FileAttributes;
|
||||||
else
|
else
|
||||||
FileNode->FileAttributes |= FileAttributes;
|
FileNode->NodeInfo.FileAttributes |= FileAttributes;
|
||||||
|
|
||||||
FileNode->FileSize = 0;
|
FileNode->NodeInfo.FileSize = 0;
|
||||||
|
FileNode->NodeInfo.LastWriteTime =
|
||||||
|
FileNode->NodeInfo.LastAccessTime = MemfsGetSystemTime();
|
||||||
|
|
||||||
SizeInfo->AllocationSize = FileNode->AllocationSize;
|
SizeInfo->AllocationSize = FileNode->NodeInfo.AllocationSize;
|
||||||
SizeInfo->FileSize = FileNode->FileSize;
|
SizeInfo->FileSize = FileNode->NodeInfo.FileSize;
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -435,7 +446,7 @@ NTSTATUS MemfsCreate(ULONG Flags, ULONG MaxFileNodes, ULONG MaxFileSize,
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
RootNode->FileAttributes = FILE_ATTRIBUTE_DIRECTORY;
|
RootNode->NodeInfo.FileAttributes = FILE_ATTRIBUTE_DIRECTORY;
|
||||||
|
|
||||||
Result = MemfsFileNodeMapInsert(Memfs->FileNodeMap, RootNode, &Inserted);
|
Result = MemfsFileNodeMapInsert(Memfs->FileNodeMap, RootNode, &Inserted);
|
||||||
if (!NT_SUCCESS(Result))
|
if (!NT_SUCCESS(Result))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user