2 FUSE_GETATTR wrapper for the Virtio Filesystem device.
4 Copyright (C) 2020, Red Hat, Inc.
6 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "VirtioFsDxe.h"
12 Send a FUSE_GETATTR request to the Virtio Filesystem device, for fetching the
13 attributes of an inode.
15 The function may only be called after VirtioFsFuseInitSession() returns
16 successfully and before VirtioFsUninit() is called.
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
23 @param[in] NodeId The inode number for which the attributes should be
26 @param[out] FuseAttr The VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE object
27 describing the properties of the inode.
29 @retval EFI_SUCCESS FuseAttr has been filled in.
31 @return The "errno" value mapped to an EFI_STATUS code, if the
32 Virtio Filesystem device explicitly reported an error.
34 @return Error codes propagated from VirtioFsSgListsValidate(),
35 VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit(),
36 VirtioFsFuseCheckResponse().
40 IN OUT VIRTIO_FS
*VirtioFs
,
42 OUT VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE
*FuseAttr
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
;
56 // Set up the scatter-gather lists.
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
);
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
);
75 // Validate the scatter-gather lists; calculate the total transfer sizes.
77 Status
= VirtioFsSgListsValidate (VirtioFs
, &ReqSgList
, &RespSgList
);
78 if (EFI_ERROR (Status
)) {
83 // Populate the common request header.
85 Status
= VirtioFsFuseNewRequest (
89 VirtioFsFuseOpGetAttr
,
92 if (EFI_ERROR (Status
)) {
97 // Populate the FUSE_GETATTR-specific fields.
99 GetAttrReq
.GetAttrFlags
= 0;
100 GetAttrReq
.Dummy
= 0;
101 GetAttrReq
.FileHandle
= 0;
104 // Submit the request.
106 Status
= VirtioFsSgListsSubmit (VirtioFs
, &ReqSgList
, &RespSgList
);
107 if (EFI_ERROR (Status
)) {
112 // Verify the response (all response buffers are fixed size).
114 Status
= VirtioFsFuseCheckResponse (&RespSgList
, CommonReq
.Unique
, NULL
);
115 if (Status
== EFI_DEVICE_ERROR
) {
118 "%a: Label=\"%s\" NodeId=%Lu Errno=%d\n",
124 Status
= VirtioFsErrnoToEfiStatus (CommonResp
.Error
);