VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/VirtioFsDxe/FuseGetAttr.c

Last change on this file was 101291, checked in by vboxsync, 19 months ago

EFI/FirmwareNew: Make edk2-stable202308 build on all supported platforms (using gcc at least, msvc not tested yet), bugref:4643

  • Property svn:eol-style set to native
File size: 3.7 KB
Line 
1/** @file
2 FUSE_GETATTR 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 a FUSE_GETATTR request to the Virtio Filesystem device, for fetching the
13 attributes of an inode.
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
19 FUSE_GETATTR request to. On output, the FUSE request
20 counter "VirtioFs->RequestId" will have been
21 incremented.
22
23 @param[in] NodeId The inode number for which the attributes should be
24 retrieved.
25
26 @param[out] FuseAttr The VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE object
27 describing the properties of the inode.
28
29 @retval EFI_SUCCESS FuseAttr has been filled in.
30
31 @return The "errno" value mapped to an EFI_STATUS code, if the
32 Virtio Filesystem device explicitly reported an error.
33
34 @return Error codes propagated from VirtioFsSgListsValidate(),
35 VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit(),
36 VirtioFsFuseCheckResponse().
37**/
38EFI_STATUS
39VirtioFsFuseGetAttr (
40 IN OUT VIRTIO_FS *VirtioFs,
41 IN UINT64 NodeId,
42 OUT VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr
43 )
44{
45 VIRTIO_FS_FUSE_REQUEST CommonReq;
46 VIRTIO_FS_FUSE_GETATTR_REQUEST GetAttrReq;
47 VIRTIO_FS_IO_VECTOR ReqIoVec[2];
48 VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
49 VIRTIO_FS_FUSE_RESPONSE CommonResp;
50 VIRTIO_FS_FUSE_GETATTR_RESPONSE GetAttrResp;
51 VIRTIO_FS_IO_VECTOR RespIoVec[3];
52 VIRTIO_FS_SCATTER_GATHER_LIST RespSgList;
53 EFI_STATUS Status;
54
55 //
56 // Set up the scatter-gather lists.
57 //
58 ReqIoVec[0].Buffer = &CommonReq;
59 ReqIoVec[0].Size = sizeof CommonReq;
60 ReqIoVec[1].Buffer = &GetAttrReq;
61 ReqIoVec[1].Size = sizeof GetAttrReq;
62 ReqSgList.IoVec = ReqIoVec;
63 ReqSgList.NumVec = ARRAY_SIZE (ReqIoVec);
64
65 RespIoVec[0].Buffer = &CommonResp;
66 RespIoVec[0].Size = sizeof CommonResp;
67 RespIoVec[1].Buffer = &GetAttrResp;
68 RespIoVec[1].Size = sizeof GetAttrResp;
69 RespIoVec[2].Buffer = FuseAttr;
70 RespIoVec[2].Size = sizeof *FuseAttr;
71 RespSgList.IoVec = RespIoVec;
72 RespSgList.NumVec = ARRAY_SIZE (RespIoVec);
73
74 //
75 // Validate the scatter-gather lists; calculate the total transfer sizes.
76 //
77 Status = VirtioFsSgListsValidate (VirtioFs, &ReqSgList, &RespSgList);
78 if (EFI_ERROR (Status)) {
79 return Status;
80 }
81
82 //
83 // Populate the common request header.
84 //
85 Status = VirtioFsFuseNewRequest (
86 VirtioFs,
87 &CommonReq,
88 ReqSgList.TotalSize,
89 VirtioFsFuseOpGetAttr,
90 NodeId
91 );
92 if (EFI_ERROR (Status)) {
93 return Status;
94 }
95
96 //
97 // Populate the FUSE_GETATTR-specific fields.
98 //
99 GetAttrReq.GetAttrFlags = 0;
100 GetAttrReq.Dummy = 0;
101 GetAttrReq.FileHandle = 0;
102
103 //
104 // Submit the request.
105 //
106 Status = VirtioFsSgListsSubmit (VirtioFs, &ReqSgList, &RespSgList);
107 if (EFI_ERROR (Status)) {
108 return Status;
109 }
110
111 //
112 // Verify the response (all response buffers are fixed size).
113 //
114 Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NULL);
115 if (Status == EFI_DEVICE_ERROR) {
116 DEBUG ((
117 DEBUG_ERROR,
118 "%a: Label=\"%s\" NodeId=%Lu Errno=%d\n",
119 __func__,
120 VirtioFs->Label,
121 NodeId,
122 CommonResp.Error
123 ));
124 Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
125 }
126
127 return Status;
128}
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