VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/VirtioFsDxe/SimpleFsClose.c@ 94264

Last change on this file since 94264 was 89983, checked in by vboxsync, 3 years ago

Devices/EFI: Merge edk-stable202105 and openssl 1.1.1j and make it build, bugref:4643

  • Property svn:eol-style set to native
File size: 2.0 KB
Line 
1/** @file
2 EFI_FILE_PROTOCOL.Close() 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 <Library/BaseLib.h> // RemoveEntryList()
10#include <Library/MemoryAllocationLib.h> // FreePool()
11
12#include "VirtioFsDxe.h"
13
14EFI_STATUS
15EFIAPI
16VirtioFsSimpleFileClose (
17 IN EFI_FILE_PROTOCOL *This
18 )
19{
20 VIRTIO_FS_FILE *VirtioFsFile;
21 VIRTIO_FS *VirtioFs;
22
23 VirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This);
24 VirtioFs = VirtioFsFile->OwnerFs;
25
26 //
27 // All actions in this function are "best effort"; the UEFI spec requires
28 // EFI_FILE_PROTOCOL.Close() to sync all data to the device, but it also
29 // requires EFI_FILE_PROTOCOL.Close() to release resources unconditionally,
30 // and to return EFI_SUCCESS unconditionally.
31 //
32 // Flush, sync, release, and (if needed) forget. If any action fails, we
33 // still try the others.
34 //
35 if (VirtioFsFile->IsOpenForWriting) {
36 if (!VirtioFsFile->IsDirectory) {
37 VirtioFsFuseFlush (VirtioFs, VirtioFsFile->NodeId,
38 VirtioFsFile->FuseHandle);
39 }
40
41 VirtioFsFuseFsyncFileOrDir (VirtioFs, VirtioFsFile->NodeId,
42 VirtioFsFile->FuseHandle, VirtioFsFile->IsDirectory);
43 }
44
45 VirtioFsFuseReleaseFileOrDir (VirtioFs, VirtioFsFile->NodeId,
46 VirtioFsFile->FuseHandle, VirtioFsFile->IsDirectory);
47
48 //
49 // VirtioFsFile->FuseHandle is gone at this point, but VirtioFsFile->NodeId
50 // is still valid. If we've known VirtioFsFile->NodeId from a lookup, then
51 // now we should ask the server to forget it *once*.
52 //
53 if (VirtioFsFile->NodeId != VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID) {
54 VirtioFsFuseForget (VirtioFs, VirtioFsFile->NodeId);
55 }
56
57 //
58 // One fewer file left open for the owner filesystem.
59 //
60 RemoveEntryList (&VirtioFsFile->OpenFilesEntry);
61
62 FreePool (VirtioFsFile->CanonicalPathname);
63 if (VirtioFsFile->FileInfoArray != NULL) {
64 FreePool (VirtioFsFile->FileInfoArray);
65 }
66 FreePool (VirtioFsFile);
67 return EFI_SUCCESS;
68}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette