mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 08:23:05 -05:00
sys,dll: Overwrite now correctly handles AllocationSize
This commit is contained in:
parent
6de998ff98
commit
bbb51b4971
@ -240,6 +240,7 @@ typedef struct
|
||||
UINT64 UserContext;
|
||||
UINT64 UserContext2;
|
||||
UINT32 FileAttributes; /* file attributes for overwritten/superseded files */
|
||||
UINT64 AllocationSize; /* allocation size for overwritten/superseded files */
|
||||
UINT32 Supersede:1; /* 0: FILE_OVERWRITE operation, 1: FILE_SUPERSEDE operation */
|
||||
} Overwrite;
|
||||
struct
|
||||
|
@ -301,6 +301,8 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
|
||||
* @param ReplaceFileAttributes
|
||||
* When TRUE the existing file attributes should be replaced with the new ones.
|
||||
* When FALSE the existing file attributes should be merged (or'ed) with the new ones.
|
||||
* @param AllocationSize
|
||||
* Allocation size for the overwritten file.
|
||||
* @param FileInfo [out]
|
||||
* Pointer to a structure that will receive the file information on successful return
|
||||
* from this call. This information includes file attributes, file times, etc.
|
||||
@ -308,7 +310,7 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
|
||||
* STATUS_SUCCESS or error code.
|
||||
*/
|
||||
NTSTATUS (*Overwrite)(FSP_FILE_SYSTEM *FileSystem,
|
||||
PVOID FileContext, UINT32 FileAttributes, BOOLEAN ReplaceFileAttributes,
|
||||
PVOID FileContext, UINT32 FileAttributes, BOOLEAN ReplaceFileAttributes, UINT64 AllocationSize,
|
||||
FSP_FSCTL_FILE_INFO *FileInfo);
|
||||
/**
|
||||
* Cleanup a file.
|
||||
|
@ -847,6 +847,7 @@ FSP_API NTSTATUS FspFileSystemOpOverwrite(FSP_FILE_SYSTEM *FileSystem,
|
||||
(PVOID)ValOfFileContext(Request->Req.Overwrite),
|
||||
Request->Req.Overwrite.FileAttributes,
|
||||
Request->Req.Overwrite.Supersede,
|
||||
Request->Req.Overwrite.AllocationSize,
|
||||
&FileInfo);
|
||||
if (!NT_SUCCESS(Result))
|
||||
{
|
||||
|
@ -1011,7 +1011,7 @@ exit:
|
||||
}
|
||||
|
||||
static NTSTATUS fsp_fuse_intf_Overwrite(FSP_FILE_SYSTEM *FileSystem,
|
||||
PVOID FileNode, UINT32 FileAttributes, BOOLEAN ReplaceFileAttributes,
|
||||
PVOID FileNode, UINT32 FileAttributes, BOOLEAN ReplaceFileAttributes, UINT64 AllocationSize,
|
||||
FSP_FSCTL_FILE_INFO *FileInfo)
|
||||
{
|
||||
struct fuse *f = FileSystem->UserContext;
|
||||
|
@ -933,6 +933,7 @@ NTSTATUS FspFsvolCreateComplete(
|
||||
*/
|
||||
|
||||
USHORT FileAttributes = IrpSp->Parameters.Create.FileAttributes;
|
||||
UINT64 AllocationSize = Request->Req.Create.AllocationSize;
|
||||
|
||||
ClearFlag(FileAttributes, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY);
|
||||
if (FileNode->IsDirectory)
|
||||
@ -957,6 +958,7 @@ NTSTATUS FspFsvolCreateComplete(
|
||||
Request->Req.Overwrite.UserContext = FileNode->UserContext;
|
||||
Request->Req.Overwrite.UserContext2 = FileDesc->UserContext2;
|
||||
Request->Req.Overwrite.FileAttributes = FileAttributes;
|
||||
Request->Req.Overwrite.AllocationSize = AllocationSize;
|
||||
Request->Req.Overwrite.Supersede = FILE_SUPERSEDED == Response->IoStatus.Information;
|
||||
|
||||
/*
|
||||
|
@ -858,11 +858,16 @@ static NTSTATUS Open(FSP_FILE_SYSTEM *FileSystem,
|
||||
}
|
||||
|
||||
static NTSTATUS Overwrite(FSP_FILE_SYSTEM *FileSystem,
|
||||
PVOID FileNode0, UINT32 FileAttributes, BOOLEAN ReplaceFileAttributes,
|
||||
PVOID FileNode0, UINT32 FileAttributes, BOOLEAN ReplaceFileAttributes, UINT64 AllocationSize,
|
||||
FSP_FSCTL_FILE_INFO *FileInfo)
|
||||
{
|
||||
MEMFS *Memfs = (MEMFS *)FileSystem->UserContext;
|
||||
MEMFS_FILE_NODE *FileNode = (MEMFS_FILE_NODE *)FileNode0;
|
||||
NTSTATUS Result;
|
||||
|
||||
Result = SetFileSize(FileSystem, FileNode, AllocationSize, TRUE, FileInfo);
|
||||
if (!NT_SUCCESS(Result))
|
||||
return Result;
|
||||
|
||||
if (ReplaceFileAttributes)
|
||||
FileNode->FileInfo.FileAttributes = FileAttributes | FILE_ATTRIBUTE_ARCHIVE;
|
||||
@ -982,6 +987,7 @@ static NTSTATUS Write(FSP_FILE_SYSTEM *FileSystem,
|
||||
|
||||
MEMFS_FILE_NODE *FileNode = (MEMFS_FILE_NODE *)FileNode0;
|
||||
UINT64 EndOffset;
|
||||
NTSTATUS Result;
|
||||
|
||||
if (ConstrainedIo)
|
||||
{
|
||||
@ -997,7 +1003,11 @@ static NTSTATUS Write(FSP_FILE_SYSTEM *FileSystem,
|
||||
Offset = FileNode->FileInfo.FileSize;
|
||||
EndOffset = Offset + Length;
|
||||
if (EndOffset > FileNode->FileInfo.FileSize)
|
||||
SetFileSize(FileSystem, FileNode, EndOffset, FALSE, FileInfo);
|
||||
{
|
||||
Result = SetFileSize(FileSystem, FileNode, EndOffset, FALSE, FileInfo);
|
||||
if (!NT_SUCCESS(Result))
|
||||
return Result;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy((PUINT8)FileNode->FileData + Offset, Buffer, (size_t)(EndOffset - Offset));
|
||||
|
Loading…
x
Reference in New Issue
Block a user