]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/VirtioFsDxe/SimpleFsFlush.c
OvmfPkg/VirtioFsDxe: implement EFI_FILE_PROTOCOL.Flush()
[mirror_edk2.git] / OvmfPkg / VirtioFsDxe / SimpleFsFlush.c
1 /** @file
2 EFI_FILE_PROTOCOL.Flush() member function for the Virtio Filesystem driver.
3
4 Copyright (C) 2020, Red Hat, Inc.
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7 **/
8
9 #include "VirtioFsDxe.h"
10
11 EFI_STATUS
12 EFIAPI
13 VirtioFsSimpleFileFlush (
14 IN EFI_FILE_PROTOCOL *This
15 )
16 {
17 VIRTIO_FS_FILE *VirtioFsFile;
18 VIRTIO_FS *VirtioFs;
19 EFI_STATUS Status;
20
21 VirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This);
22 VirtioFs = VirtioFsFile->OwnerFs;
23
24 if (!VirtioFsFile->IsOpenForWriting) {
25 return EFI_ACCESS_DENIED;
26 }
27
28 //
29 // FUSE_FLUSH is for regular files only.
30 //
31 if (!VirtioFsFile->IsDirectory) {
32 Status = VirtioFsFuseFlush (VirtioFs, VirtioFsFile->NodeId,
33 VirtioFsFile->FuseHandle);
34 if (EFI_ERROR (Status)) {
35 return Status;
36 }
37 }
38
39 Status = VirtioFsFuseFsyncFileOrDir (VirtioFs, VirtioFsFile->NodeId,
40 VirtioFsFile->FuseHandle, VirtioFsFile->IsDirectory);
41 return Status;
42 }