VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/VirtioFsDxe/FuseStatFs.c@ 89983

Last change on this file since 89983 was 89983, checked in by vboxsync, 4 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.3 KB
Line 
1/** @file
2 FUSE_STATFS wrapper for the Virtio Filesystem device.
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/**
12 Send the FUSE_STATFS request to the Virtio Filesysem device, for retrieving
13 the attributes of the host-side filesystem that contains NodeId.
14
15 The function may only be called after VirtioFsFuseInitSession() returns
16 successfully and before VirtioFsUninit() is called.
17
18 @param[in,out] VirtioFs The Virtio Filesystem device to send the FUSE_STATFS
19 request to. On output, the FUSE request counter
20 "VirtioFs->RequestId" will have been incremented.
21
22 @param[in] NodeId The inode whose containing filesystem is to be
23 queried for its attributes.
24
25 @param[out] FilesysAttr The VIRTIO_FS_FUSE_STATFS_RESPONSE object describing
26 the filesystem that underlies NodeId.
27
28 @retval EFI_SUCCESS FilesysAttr has been filled in.
29
30 @return The "errno" value mapped to an EFI_STATUS code, if the
31 Virtio Filesystem device explicitly reported an error.
32
33 @return Error codes propagated from VirtioFsSgListsValidate(),
34 VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit(),
35 VirtioFsFuseCheckResponse().
36**/
37EFI_STATUS
38VirtioFsFuseStatFs (
39 IN OUT VIRTIO_FS *VirtioFs,
40 IN UINT64 NodeId,
41 OUT VIRTIO_FS_FUSE_STATFS_RESPONSE *FilesysAttr
42 )
43{
44 VIRTIO_FS_FUSE_REQUEST CommonReq;
45 VIRTIO_FS_IO_VECTOR ReqIoVec[1];
46 VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
47 VIRTIO_FS_FUSE_RESPONSE CommonResp;
48 VIRTIO_FS_IO_VECTOR RespIoVec[2];
49 VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
50 EFI_STATUS Status;
51
52 //
53 // Set up the scatter-gather lists.
54 //
55 ReqIoVec[0].Buffer = &CommonReq;
56 ReqIoVec[0].Size = sizeof CommonReq;
57 ReqSgList.IoVec = ReqIoVec;
58 ReqSgList.NumVec = ARRAY_SIZE (ReqIoVec);
59
60 RespIoVec[0].Buffer = &CommonResp;
61 RespIoVec[0].Size = sizeof CommonResp;
62 RespIoVec[1].Buffer = FilesysAttr;
63 RespIoVec[1].Size = sizeof *FilesysAttr;
64 RespSgList.IoVec = RespIoVec;
65 RespSgList.NumVec = ARRAY_SIZE (RespIoVec);
66
67 //
68 // Validate the scatter-gather lists; calculate the total transfer sizes.
69 //
70 Status = VirtioFsSgListsValidate (VirtioFs, &ReqSgList, &RespSgList);
71 if (EFI_ERROR (Status)) {
72 return Status;
73 }
74
75 //
76 // Populate the common request header.
77 //
78 Status = VirtioFsFuseNewRequest (VirtioFs, &CommonReq, ReqSgList.TotalSize,
79 VirtioFsFuseOpStatFs, NodeId);
80 if (EFI_ERROR (Status)) {
81 return Status;
82 }
83
84 //
85 // Submit the request.
86 //
87 Status = VirtioFsSgListsSubmit (VirtioFs, &ReqSgList, &RespSgList);
88 if (EFI_ERROR (Status)) {
89 return Status;
90 }
91
92 //
93 // Verify the response (all response buffers are fixed size).
94 //
95 Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NULL);
96 if (Status == EFI_DEVICE_ERROR) {
97 DEBUG ((DEBUG_ERROR, "%a: Label=\"%s\" NodeId=%Lu Errno=%d\n",
98 __FUNCTION__, VirtioFs->Label, NodeId, CommonResp.Error));
99 Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
100 }
101 return Status;
102}
Note: See TracBrowser for help on using the repository browser.

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