summaryrefslogtreecommitdiff
path: root/OvmfPkg/VirtioFsDxe/SimpleFsFlush.c
diff options
context:
space:
mode:
Diffstat (limited to 'OvmfPkg/VirtioFsDxe/SimpleFsFlush.c')
-rw-r--r--OvmfPkg/VirtioFsDxe/SimpleFsFlush.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsFlush.c b/OvmfPkg/VirtioFsDxe/SimpleFsFlush.c
index e48d921..ba4a611 100644
--- a/OvmfPkg/VirtioFsDxe/SimpleFsFlush.c
+++ b/OvmfPkg/VirtioFsDxe/SimpleFsFlush.c
@@ -14,5 +14,29 @@ VirtioFsSimpleFileFlush (
IN EFI_FILE_PROTOCOL *This
)
{
- return EFI_NO_MEDIA;
+ VIRTIO_FS_FILE *VirtioFsFile;
+ VIRTIO_FS *VirtioFs;
+ EFI_STATUS Status;
+
+ VirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This);
+ VirtioFs = VirtioFsFile->OwnerFs;
+
+ if (!VirtioFsFile->IsOpenForWriting) {
+ return EFI_ACCESS_DENIED;
+ }
+
+ //
+ // FUSE_FLUSH is for regular files only.
+ //
+ if (!VirtioFsFile->IsDirectory) {
+ Status = VirtioFsFuseFlush (VirtioFs, VirtioFsFile->NodeId,
+ VirtioFsFile->FuseHandle);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+
+ Status = VirtioFsFuseFsyncFileOrDir (VirtioFs, VirtioFsFile->NodeId,
+ VirtioFsFile->FuseHandle, VirtioFsFile->IsDirectory);
+ return Status;
}