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@arm.com> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Philippe Mathieu-Daudé <philmd@redhat.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3097 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Message-Id: <20201216211125.19496-38-lersek@redhat.com> Acked-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
43 lines
999 B
C
43 lines
999 B
C
/** @file
|
|
EFI_FILE_PROTOCOL.Flush() member function for the Virtio Filesystem driver.
|
|
|
|
Copyright (C) 2020, Red Hat, Inc.
|
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
**/
|
|
|
|
#include "VirtioFsDxe.h"
|
|
|
|
EFI_STATUS
|
|
EFIAPI
|
|
VirtioFsSimpleFileFlush (
|
|
IN EFI_FILE_PROTOCOL *This
|
|
)
|
|
{
|
|
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;
|
|
}
|