TianoCore EDK2 master
Loading...
Searching...
No Matches
FuseLookup.c
Go to the documentation of this file.
1
9#include <Library/BaseLib.h> // AsciiStrSize()
10
11#include "VirtioFsDxe.h"
12
55 IN OUT VIRTIO_FS *VirtioFs,
56 IN UINT64 DirNodeId,
57 IN CHAR8 *Name,
58 OUT UINT64 *NodeId,
60 )
61{
62 VIRTIO_FS_FUSE_REQUEST CommonReq;
63 VIRTIO_FS_IO_VECTOR ReqIoVec[2];
65 VIRTIO_FS_FUSE_RESPONSE CommonResp;
67 VIRTIO_FS_IO_VECTOR RespIoVec[3];
69 EFI_STATUS Status;
70
71 //
72 // Set up the scatter-gather lists.
73 //
74 ReqIoVec[0].Buffer = &CommonReq;
75 ReqIoVec[0].Size = sizeof CommonReq;
76 ReqIoVec[1].Buffer = Name;
77 ReqIoVec[1].Size = AsciiStrSize (Name);
78 ReqSgList.IoVec = ReqIoVec;
79 ReqSgList.NumVec = ARRAY_SIZE (ReqIoVec);
80
81 RespIoVec[0].Buffer = &CommonResp;
82 RespIoVec[0].Size = sizeof CommonResp;
83 RespIoVec[1].Buffer = &NodeResp;
84 RespIoVec[1].Size = sizeof NodeResp;
85 RespIoVec[2].Buffer = FuseAttr;
86 RespIoVec[2].Size = sizeof *FuseAttr;
87 RespSgList.IoVec = RespIoVec;
88 RespSgList.NumVec = ARRAY_SIZE (RespIoVec);
89
90 //
91 // Validate the scatter-gather lists; calculate the total transfer sizes.
92 //
93 Status = VirtioFsSgListsValidate (VirtioFs, &ReqSgList, &RespSgList);
94 if (EFI_ERROR (Status)) {
95 goto Fail;
96 }
97
98 //
99 // Populate the common request header.
100 //
101 Status = VirtioFsFuseNewRequest (
102 VirtioFs,
103 &CommonReq,
104 ReqSgList.TotalSize,
105 VirtioFsFuseOpLookup,
106 DirNodeId
107 );
108 if (EFI_ERROR (Status)) {
109 goto Fail;
110 }
111
112 //
113 // Submit the request.
114 //
115 Status = VirtioFsSgListsSubmit (VirtioFs, &ReqSgList, &RespSgList);
116 if (EFI_ERROR (Status)) {
117 goto Fail;
118 }
119
120 //
121 // Verify the response (all response buffers are fixed size).
122 //
123 Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NULL);
124 if (EFI_ERROR (Status)) {
125 if (Status == EFI_DEVICE_ERROR) {
126 DEBUG ((
127 ((CommonResp.Error == VIRTIO_FS_FUSE_ERRNO_ENOENT) ?
128 DEBUG_VERBOSE :
129 DEBUG_ERROR),
130 "%a: Label=\"%s\" DirNodeId=%Lu Name=\"%a\" Errno=%d\n",
131 __func__,
132 VirtioFs->Label,
133 DirNodeId,
134 Name,
135 CommonResp.Error
136 ));
137 if (CommonResp.Error == VIRTIO_FS_FUSE_ERRNO_ENOENT) {
138 return EFI_NOT_FOUND;
139 }
140
141 Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
142 }
143
144 goto Fail;
145 }
146
147 //
148 // Output the NodeId to which Name has been resolved to.
149 //
150 *NodeId = NodeResp.NodeId;
151 return EFI_SUCCESS;
152
153Fail:
154 return (Status == EFI_NOT_FOUND) ? EFI_DEVICE_ERROR : Status;
155}
UINTN EFIAPI AsciiStrSize(IN CONST CHAR8 *String)
Definition: String.c:681
EFI_STATUS VirtioFsFuseLookup(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 DirNodeId, IN CHAR8 *Name, OUT UINT64 *NodeId, OUT VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr)
Definition: FuseLookup.c:54
#define NULL
Definition: Base.h:319
#define ARRAY_SIZE(Array)
Definition: Base.h:1393
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define DEBUG(Expression)
Definition: DebugLib.h:434
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_STATUS VirtioFsFuseCheckResponse(IN VIRTIO_FS_SCATTER_GATHER_LIST *ResponseSgList, IN UINT64 RequestId, OUT UINTN *TailBufferFill)
Definition: Helpers.c:873
EFI_STATUS VirtioFsFuseNewRequest(IN OUT VIRTIO_FS *VirtioFs, OUT VIRTIO_FS_FUSE_REQUEST *Request, IN UINT32 RequestSize, IN VIRTIO_FS_FUSE_OPCODE Opcode, IN UINT64 NodeId)
Definition: Helpers.c:790
EFI_STATUS VirtioFsSgListsSubmit(IN OUT VIRTIO_FS *VirtioFs, IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *RequestSgList, IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *ResponseSgList OPTIONAL)
Definition: Helpers.c:538
EFI_STATUS VirtioFsErrnoToEfiStatus(IN INT32 Errno)
Definition: Helpers.c:991
EFI_STATUS VirtioFsSgListsValidate(IN VIRTIO_FS *VirtioFs, IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *RequestSgList, IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *ResponseSgList OPTIONAL)
Definition: Helpers.c:398