TianoCore EDK2 master
Loading...
Searching...
No Matches
SimpleFsClose.c
Go to the documentation of this file.
1
9#include <Library/BaseLib.h> // RemoveEntryList()
10#include <Library/MemoryAllocationLib.h> // FreePool()
11
12#include "VirtioFsDxe.h"
13
15EFIAPI
16VirtioFsSimpleFileClose (
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) {
38 VirtioFs,
39 VirtioFsFile->NodeId,
40 VirtioFsFile->FuseHandle
41 );
42 }
43
45 VirtioFs,
46 VirtioFsFile->NodeId,
47 VirtioFsFile->FuseHandle,
48 VirtioFsFile->IsDirectory
49 );
50 }
51
53 VirtioFs,
54 VirtioFsFile->NodeId,
55 VirtioFsFile->FuseHandle,
56 VirtioFsFile->IsDirectory
57 );
58
59 //
60 // VirtioFsFile->FuseHandle is gone at this point, but VirtioFsFile->NodeId
61 // is still valid. If we've known VirtioFsFile->NodeId from a lookup, then
62 // now we should ask the server to forget it *once*.
63 //
64 if (VirtioFsFile->NodeId != VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID) {
65 VirtioFsFuseForget (VirtioFs, VirtioFsFile->NodeId);
66 }
67
68 //
69 // One fewer file left open for the owner filesystem.
70 //
71 RemoveEntryList (&VirtioFsFile->OpenFilesEntry);
72
73 FreePool (VirtioFsFile->CanonicalPathname);
74 if (VirtioFsFile->FileInfoArray != NULL) {
75 FreePool (VirtioFsFile->FileInfoArray);
76 }
77
78 FreePool (VirtioFsFile);
79 return EFI_SUCCESS;
80}
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
Definition: LinkedList.c:590
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS VirtioFsFuseFlush(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId, IN UINT64 FuseHandle)
Definition: FuseFlush.c:37
EFI_STATUS VirtioFsFuseForget(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId)
Definition: FuseForget.c:36
EFI_STATUS VirtioFsFuseFsyncFileOrDir(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId, IN UINT64 FuseHandle, IN BOOLEAN IsDir)
Definition: FuseFsync.c:42
EFI_STATUS VirtioFsFuseReleaseFileOrDir(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId, IN UINT64 FuseHandle, IN BOOLEAN IsDir)
Definition: FuseRelease.c:41
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112