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