TianoCore EDK2 master
Loading...
Searching...
No Matches
FuseGetAttr.c
Go to the documentation of this file.
1
9#include "VirtioFsDxe.h"
10
40 IN OUT VIRTIO_FS *VirtioFs,
41 IN UINT64 NodeId,
43 )
44{
45 VIRTIO_FS_FUSE_REQUEST CommonReq;
47 VIRTIO_FS_IO_VECTOR ReqIoVec[2];
49 VIRTIO_FS_FUSE_RESPONSE CommonResp;
51 VIRTIO_FS_IO_VECTOR RespIoVec[3];
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}
EFI_STATUS VirtioFsFuseGetAttr(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId, OUT VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr)
Definition: FuseGetAttr.c:39
#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
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