VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/VirtioFsDxe/SimpleFsOpenVolume.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: 3.0 KB
Line 
1/** @file
2 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume() member function for the Virtio
3 Filesystem driver.
4
5 Copyright (C) 2020, Red Hat, Inc.
6
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8**/
9
10#include <Library/BaseLib.h> // InsertTailList()
11#include <Library/MemoryAllocationLib.h> // AllocatePool()
12
13#include "VirtioFsDxe.h"
14
15/**
16 Open the root directory on the Virtio Filesystem.
17
18 Refer to EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME for the interface
19 contract.
20**/
21EFI_STATUS
22EFIAPI
23VirtioFsOpenVolume (
24 IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
25 OUT EFI_FILE_PROTOCOL **Root
26 )
27{
28 VIRTIO_FS *VirtioFs;
29 VIRTIO_FS_FILE *VirtioFsFile;
30 EFI_STATUS Status;
31 CHAR8 *CanonicalPathname;
32 UINT64 RootDirHandle;
33
34 VirtioFs = VIRTIO_FS_FROM_SIMPLE_FS (This);
35
36 VirtioFsFile = AllocatePool (sizeof *VirtioFsFile);
37 if (VirtioFsFile == NULL) {
38 return EFI_OUT_OF_RESOURCES;
39 }
40
41 CanonicalPathname = AllocateCopyPool (sizeof "/", "/");
42 if (CanonicalPathname == NULL) {
43 Status = EFI_OUT_OF_RESOURCES;
44 goto FreeVirtioFsFile;
45 }
46
47 //
48 // Open the root directory.
49 //
50 Status = VirtioFsFuseOpenDir (VirtioFs, VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID,
51 &RootDirHandle);
52 if (EFI_ERROR (Status)) {
53 goto FreeCanonicalPathname;
54 }
55
56 //
57 // Populate the new VIRTIO_FS_FILE object.
58 //
59 VirtioFsFile->Signature = VIRTIO_FS_FILE_SIG;
60 VirtioFsFile->SimpleFile.Revision = EFI_FILE_PROTOCOL_REVISION;
61 VirtioFsFile->SimpleFile.Open = VirtioFsSimpleFileOpen;
62 VirtioFsFile->SimpleFile.Close = VirtioFsSimpleFileClose;
63 VirtioFsFile->SimpleFile.Delete = VirtioFsSimpleFileDelete;
64 VirtioFsFile->SimpleFile.Read = VirtioFsSimpleFileRead;
65 VirtioFsFile->SimpleFile.Write = VirtioFsSimpleFileWrite;
66 VirtioFsFile->SimpleFile.GetPosition = VirtioFsSimpleFileGetPosition;
67 VirtioFsFile->SimpleFile.SetPosition = VirtioFsSimpleFileSetPosition;
68 VirtioFsFile->SimpleFile.GetInfo = VirtioFsSimpleFileGetInfo;
69 VirtioFsFile->SimpleFile.SetInfo = VirtioFsSimpleFileSetInfo;
70 VirtioFsFile->SimpleFile.Flush = VirtioFsSimpleFileFlush;
71 VirtioFsFile->IsDirectory = TRUE;
72 VirtioFsFile->IsOpenForWriting = FALSE;
73 VirtioFsFile->OwnerFs = VirtioFs;
74 VirtioFsFile->CanonicalPathname = CanonicalPathname;
75 VirtioFsFile->FilePosition = 0;
76 VirtioFsFile->NodeId = VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID;
77 VirtioFsFile->FuseHandle = RootDirHandle;
78 VirtioFsFile->FileInfoArray = NULL;
79 VirtioFsFile->SingleFileInfoSize = 0;
80 VirtioFsFile->NumFileInfo = 0;
81 VirtioFsFile->NextFileInfo = 0;
82
83 //
84 // One more file open for the filesystem.
85 //
86 InsertTailList (&VirtioFs->OpenFiles, &VirtioFsFile->OpenFilesEntry);
87
88 *Root = &VirtioFsFile->SimpleFile;
89 return EFI_SUCCESS;
90
91FreeCanonicalPathname:
92 FreePool (CanonicalPathname);
93
94FreeVirtioFsFile:
95 FreePool (VirtioFsFile);
96
97 return Status;
98}
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