[edk2-devel] [edk2 PATCH 37/48] OvmfPkg/VirtioFsDxe: implement EFI_FILE_PROTOCOL.Flush()

Laszlo Ersek lersek at redhat.com
Wed Dec 16 21:11:14 UTC 2020


For directories, implement EFI_FILE_PROTOCOL.Flush() by sending the
FUSE_FSYNCDIR command to the Virtio Filesystem device.

For regular files, send FUSE_FLUSH, followed by FUSE_FSYNC.

Cc: Ard Biesheuvel <ard.biesheuvel at arm.com>
Cc: Jordan Justen <jordan.l.justen at intel.com>
Cc: Philippe Mathieu-Daudé <philmd at redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3097
Signed-off-by: Laszlo Ersek <lersek at redhat.com>
---
 OvmfPkg/VirtioFsDxe/SimpleFsFlush.c | 26 +++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsFlush.c b/OvmfPkg/VirtioFsDxe/SimpleFsFlush.c
index e48d92140f64..ba4a611e5a21 100644
--- a/OvmfPkg/VirtioFsDxe/SimpleFsFlush.c
+++ b/OvmfPkg/VirtioFsDxe/SimpleFsFlush.c
@@ -9,10 +9,34 @@
 #include "VirtioFsDxe.h"
 
 EFI_STATUS
 EFIAPI
 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;
 }
-- 
2.19.1.3.g30247aa5d201




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#69051): https://edk2.groups.io/g/devel/message/69051
Mute This Topic: https://groups.io/mt/79024215/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-






More information about the edk2-devel-archive mailing list