VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/VirtioFsDxe/FuseStatFs.c@ 100836

Last change on this file since 100836 was 99404, checked in by vboxsync, 2 years ago

Devices/EFI/FirmwareNew: Update to edk2-stable202302 and make it build, bugref:4643

  • Property svn:eol-style set to native
File size: 3.4 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 (
79 VirtioFs,
80 &CommonReq,
81 ReqSgList.TotalSize,
82 VirtioFsFuseOpStatFs,
83 NodeId
84 );
85 if (EFI_ERROR (Status)) {
86 return Status;
87 }
88
89 //
90 // Submit the request.
91 //
92 Status = VirtioFsSgListsSubmit (VirtioFs, &ReqSgList, &RespSgList);
93 if (EFI_ERROR (Status)) {
94 return Status;
95 }
96
97 //
98 // Verify the response (all response buffers are fixed size).
99 //
100 Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NULL);
101 if (Status == EFI_DEVICE_ERROR) {
102 DEBUG ((
103 DEBUG_ERROR,
104 "%a: Label=\"%s\" NodeId=%Lu Errno=%d\n",
105 __FUNCTION__,
106 VirtioFs->Label,
107 NodeId,
108 CommonResp.Error
109 ));
110 Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
111 }
112
113 return Status;
114}
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