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