VirtualBox

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

Last change on this file since 99396 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.6 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 (VirtioFs, &CommonReq, ReqSgList.TotalSize,
86 VirtioFsFuseOpGetAttr, NodeId);
87 if (EFI_ERROR (Status)) {
88 return Status;
89 }
90
91 //
92 // Populate the FUSE_GETATTR-specific fields.
93 //
94 GetAttrReq.GetAttrFlags = 0;
95 GetAttrReq.Dummy = 0;
96 GetAttrReq.FileHandle = 0;
97
98 //
99 // Submit the request.
100 //
101 Status = VirtioFsSgListsSubmit (VirtioFs, &ReqSgList, &RespSgList);
102 if (EFI_ERROR (Status)) {
103 return Status;
104 }
105
106 //
107 // Verify the response (all response buffers are fixed size).
108 //
109 Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NULL);
110 if (Status == EFI_DEVICE_ERROR) {
111 DEBUG ((DEBUG_ERROR, "%a: Label=\"%s\" NodeId=%Lu Errno=%d\n",
112 __FUNCTION__, VirtioFs->Label, NodeId, CommonResp.Error));
113 Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
114 }
115 return Status;
116}
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