viofs-svc: implement the Overwrite callback function.
@@ -102,6 +102,10 @@ typedef struct
} VIRTFS_FILE_CONTEXT, *PVIRTFS_FILE_CONTEXT;
+static NTSTATUS SetBasicInfo(FSP_FILE_SYSTEM *FileSystem, PVOID FileContext0,
+ UINT32 FileAttributes, UINT64 CreationTime, UINT64 LastAccessTime,
+ UINT64 LastWriteTime, UINT64 ChangeTime, FSP_FSCTL_FILE_INFO *FileInfo);
+
static NTSTATUS SetFileSize(FSP_FILE_SYSTEM *FileSystem, PVOID FileContext0,
UINT64 NewSize, BOOLEAN SetAllocationSize, FSP_FSCTL_FILE_INFO *FileInfo);
@@ -903,6 +907,8 @@ static NTSTATUS Overwrite(FSP_FILE_SYSTEM *FileSystem,
"AllocationSize: %Iu", FileAttributes, ReplaceFileAttributes,
AllocationSize);
+ if ((FileAttributes != 0) && (FileAttributes != INVALID_FILE_ATTRIBUTES))
+ {
if (ReplaceFileAttributes == FALSE)
{
Status = GetFileInfoInternal(VirtFs, FileContext, FileInfo, NULL);
@@ -914,9 +920,20 @@ static NTSTATUS Overwrite(FSP_FILE_SYSTEM *FileSystem,
FileAttributes |= FileInfo->FileAttributes;
}
- // XXX Call SetBasicInfo and SetFileSize?
+ if ((FileAttributes != FileInfo->FileAttributes))
+ {
+ Status = SetBasicInfo(FileSystem, FileContext0, FileAttributes,
+ 0LL, 0LL, 0LL, 0LL, FileInfo);
- return GetFileInfoInternal(VirtFs, FileContext, FileInfo, NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ return Status;
+ }
+ }
+ }
+
+ return SetFileSize(FileSystem, FileContext0, AllocationSize, FALSE,
+ FileInfo);
}
static VOID Close(FSP_FILE_SYSTEM *FileSystem, PVOID FileContext0)
