TianoCore EDK2 master
Loading...
Searching...
No Matches
FuseRename.c
Go to the documentation of this file.
1
9#include <Library/BaseLib.h> // AsciiStrSize()
10
11#include "VirtioFsDxe.h"
12
52 IN OUT VIRTIO_FS *VirtioFs,
53 IN UINT64 OldParentNodeId,
54 IN CHAR8 *OldName,
55 IN UINT64 NewParentNodeId,
56 IN CHAR8 *NewName
57 )
58{
59 VIRTIO_FS_FUSE_REQUEST CommonReq;
61 VIRTIO_FS_IO_VECTOR ReqIoVec[4];
63 VIRTIO_FS_FUSE_RESPONSE CommonResp;
64 VIRTIO_FS_IO_VECTOR RespIoVec[1];
66 EFI_STATUS Status;
67
68 //
69 // Set up the scatter-gather lists.
70 //
71 ReqIoVec[0].Buffer = &CommonReq;
72 ReqIoVec[0].Size = sizeof CommonReq;
73 ReqIoVec[1].Buffer = &Rename2Req;
74 ReqIoVec[1].Size = sizeof Rename2Req;
75 ReqIoVec[2].Buffer = OldName;
76 ReqIoVec[2].Size = AsciiStrSize (OldName);
77 ReqIoVec[3].Buffer = NewName;
78 ReqIoVec[3].Size = AsciiStrSize (NewName);
79 ReqSgList.IoVec = ReqIoVec;
80 ReqSgList.NumVec = ARRAY_SIZE (ReqIoVec);
81
82 RespIoVec[0].Buffer = &CommonResp;
83 RespIoVec[0].Size = sizeof CommonResp;
84 RespSgList.IoVec = RespIoVec;
85 RespSgList.NumVec = ARRAY_SIZE (RespIoVec);
86
87 //
88 // Validate the scatter-gather lists; calculate the total transfer sizes.
89 //
90 Status = VirtioFsSgListsValidate (VirtioFs, &ReqSgList, &RespSgList);
91 if (EFI_ERROR (Status)) {
92 return Status;
93 }
94
95 //
96 // Populate the common request header.
97 //
98 Status = VirtioFsFuseNewRequest (
99 VirtioFs,
100 &CommonReq,
101 ReqSgList.TotalSize,
102 VirtioFsFuseOpRename2,
103 OldParentNodeId
104 );
105 if (EFI_ERROR (Status)) {
106 return Status;
107 }
108
109 //
110 // Populate the FUSE_RENAME2-specific fields.
111 //
112 Rename2Req.NewDir = NewParentNodeId;
113 Rename2Req.Flags = VIRTIO_FS_FUSE_RENAME2_REQ_F_NOREPLACE;
114 Rename2Req.Padding = 0;
115
116 //
117 // Submit the request.
118 //
119 Status = VirtioFsSgListsSubmit (VirtioFs, &ReqSgList, &RespSgList);
120 if (EFI_ERROR (Status)) {
121 return Status;
122 }
123
124 //
125 // Verify the response (all response buffers are fixed size).
126 //
127 Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NULL);
128 if (Status == EFI_DEVICE_ERROR) {
129 DEBUG ((
130 DEBUG_ERROR,
131 "%a: Label=\"%s\" OldParentNodeId=%Lu OldName=\"%a\" "
132 "NewParentNodeId=%Lu NewName=\"%a\" Errno=%d\n",
133 __func__,
134 VirtioFs->Label,
135 OldParentNodeId,
136 OldName,
137 NewParentNodeId,
138 NewName,
139 CommonResp.Error
140 ));
141 Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
142 }
143
144 return Status;
145}
UINTN EFIAPI AsciiStrSize(IN CONST CHAR8 *String)
Definition: String.c:681
EFI_STATUS VirtioFsFuseRename(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 OldParentNodeId, IN CHAR8 *OldName, IN UINT64 NewParentNodeId, IN CHAR8 *NewName)
Definition: FuseRename.c:51
#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