TianoCore EDK2 master
Loading...
Searching...
No Matches
FuseOpenDir.c
Go to the documentation of this file.
1
9#include "VirtioFsDxe.h"
10
39 IN OUT VIRTIO_FS *VirtioFs,
40 IN UINT64 NodeId,
41 OUT UINT64 *FuseHandle
42 )
43{
44 VIRTIO_FS_FUSE_REQUEST CommonReq;
46 VIRTIO_FS_IO_VECTOR ReqIoVec[2];
48 VIRTIO_FS_FUSE_RESPONSE CommonResp;
50 VIRTIO_FS_IO_VECTOR RespIoVec[2];
52 EFI_STATUS Status;
53
54 //
55 // Set up the scatter-gather lists.
56 //
57 ReqIoVec[0].Buffer = &CommonReq;
58 ReqIoVec[0].Size = sizeof CommonReq;
59 ReqIoVec[1].Buffer = &OpenReq;
60 ReqIoVec[1].Size = sizeof OpenReq;
61 ReqSgList.IoVec = ReqIoVec;
62 ReqSgList.NumVec = ARRAY_SIZE (ReqIoVec);
63
64 RespIoVec[0].Buffer = &CommonResp;
65 RespIoVec[0].Size = sizeof CommonResp;
66 RespIoVec[1].Buffer = &OpenResp;
67 RespIoVec[1].Size = sizeof OpenResp;
68 RespSgList.IoVec = RespIoVec;
69 RespSgList.NumVec = ARRAY_SIZE (RespIoVec);
70
71 //
72 // Validate the scatter-gather lists; calculate the total transfer sizes.
73 //
74 Status = VirtioFsSgListsValidate (VirtioFs, &ReqSgList, &RespSgList);
75 if (EFI_ERROR (Status)) {
76 return Status;
77 }
78
79 //
80 // Populate the common request header.
81 //
82 Status = VirtioFsFuseNewRequest (
83 VirtioFs,
84 &CommonReq,
85 ReqSgList.TotalSize,
86 VirtioFsFuseOpOpenDir,
87 NodeId
88 );
89 if (EFI_ERROR (Status)) {
90 return Status;
91 }
92
93 //
94 // Populate the FUSE_OPENDIR-specific fields.
95 //
96 OpenReq.Flags = 0;
97 OpenReq.Unused = 0;
98
99 //
100 // Submit the request.
101 //
102 Status = VirtioFsSgListsSubmit (VirtioFs, &ReqSgList, &RespSgList);
103 if (EFI_ERROR (Status)) {
104 return Status;
105 }
106
107 //
108 // Verify the response (all response buffers are fixed size).
109 //
110 Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NULL);
111 if (EFI_ERROR (Status)) {
112 if (Status == EFI_DEVICE_ERROR) {
113 DEBUG ((
114 DEBUG_ERROR,
115 "%a: Label=\"%s\" NodeId=%Lu Errno=%d\n",
116 __func__,
117 VirtioFs->Label,
118 NodeId,
119 CommonResp.Error
120 ));
121 Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
122 }
123
124 return Status;
125 }
126
127 //
128 // Output the open file handle.
129 //
130 *FuseHandle = OpenResp.FileHandle;
131 return EFI_SUCCESS;
132}
EFI_STATUS VirtioFsFuseOpenDir(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId, OUT UINT64 *FuseHandle)
Definition: FuseOpenDir.c:38
#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