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