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