TianoCore EDK2 master
Loading...
Searching...
No Matches
FuseOpen.c
Go to the documentation of this file.
1
9#include "VirtioFsDxe.h"
10
41 IN OUT VIRTIO_FS *VirtioFs,
42 IN UINT64 NodeId,
43 IN BOOLEAN ReadWrite,
44 OUT UINT64 *FuseHandle
45 )
46{
47 VIRTIO_FS_FUSE_REQUEST CommonReq;
49 VIRTIO_FS_IO_VECTOR ReqIoVec[2];
51 VIRTIO_FS_FUSE_RESPONSE CommonResp;
53 VIRTIO_FS_IO_VECTOR RespIoVec[2];
55 EFI_STATUS Status;
56
57 //
58 // Set up the scatter-gather lists.
59 //
60 ReqIoVec[0].Buffer = &CommonReq;
61 ReqIoVec[0].Size = sizeof CommonReq;
62 ReqIoVec[1].Buffer = &OpenReq;
63 ReqIoVec[1].Size = sizeof OpenReq;
64 ReqSgList.IoVec = ReqIoVec;
65 ReqSgList.NumVec = ARRAY_SIZE (ReqIoVec);
66
67 RespIoVec[0].Buffer = &CommonResp;
68 RespIoVec[0].Size = sizeof CommonResp;
69 RespIoVec[1].Buffer = &OpenResp;
70 RespIoVec[1].Size = sizeof OpenResp;
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 VirtioFsFuseOpOpen,
90 NodeId
91 );
92 if (EFI_ERROR (Status)) {
93 return Status;
94 }
95
96 //
97 // Populate the FUSE_OPEN-specific fields.
98 //
99 OpenReq.Flags = (ReadWrite ?
100 VIRTIO_FS_FUSE_OPEN_REQ_F_RDWR :
101 VIRTIO_FS_FUSE_OPEN_REQ_F_RDONLY);
102 OpenReq.Unused = 0;
103
104 //
105 // Submit the request.
106 //
107 Status = VirtioFsSgListsSubmit (VirtioFs, &ReqSgList, &RespSgList);
108 if (EFI_ERROR (Status)) {
109 return Status;
110 }
111
112 //
113 // Verify the response (all response buffers are fixed size).
114 //
115 Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NULL);
116 if (EFI_ERROR (Status)) {
117 if (Status == EFI_DEVICE_ERROR) {
118 DEBUG ((
119 DEBUG_ERROR,
120 "%a: Label=\"%s\" NodeId=%Lu ReadWrite=%d "
121 "Errno=%d\n",
122 __func__,
123 VirtioFs->Label,
124 NodeId,
125 ReadWrite,
126 CommonResp.Error
127 ));
128 Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
129 }
130
131 return Status;
132 }
133
134 //
135 // Output the open handle.
136 //
137 *FuseHandle = OpenResp.FileHandle;
138 return EFI_SUCCESS;
139}
EFI_STATUS VirtioFsFuseOpen(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId, IN BOOLEAN ReadWrite, OUT UINT64 *FuseHandle)
Definition: FuseOpen.c:40
#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