TianoCore EDK2 master
Loading...
Searching...
No Matches
FuseMkDir.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 OUT UINT64 *NodeId
48 )
49{
50 VIRTIO_FS_FUSE_REQUEST CommonReq;
52 VIRTIO_FS_IO_VECTOR ReqIoVec[3];
54 VIRTIO_FS_FUSE_RESPONSE CommonResp;
57 VIRTIO_FS_IO_VECTOR RespIoVec[3];
59 EFI_STATUS Status;
60
61 //
62 // Set up the scatter-gather lists.
63 //
64 ReqIoVec[0].Buffer = &CommonReq;
65 ReqIoVec[0].Size = sizeof CommonReq;
66 ReqIoVec[1].Buffer = &MkDirReq;
67 ReqIoVec[1].Size = sizeof MkDirReq;
68 ReqIoVec[2].Buffer = Name;
69 ReqIoVec[2].Size = AsciiStrSize (Name);
70 ReqSgList.IoVec = ReqIoVec;
71 ReqSgList.NumVec = ARRAY_SIZE (ReqIoVec);
72
73 RespIoVec[0].Buffer = &CommonResp;
74 RespIoVec[0].Size = sizeof CommonResp;
75 RespIoVec[1].Buffer = &NodeResp;
76 RespIoVec[1].Size = sizeof NodeResp;
77 RespIoVec[2].Buffer = &AttrResp;
78 RespIoVec[2].Size = sizeof AttrResp;
79 RespSgList.IoVec = RespIoVec;
80 RespSgList.NumVec = ARRAY_SIZE (RespIoVec);
81
82 //
83 // Validate the scatter-gather lists; calculate the total transfer sizes.
84 //
85 Status = VirtioFsSgListsValidate (VirtioFs, &ReqSgList, &RespSgList);
86 if (EFI_ERROR (Status)) {
87 return Status;
88 }
89
90 //
91 // Populate the common request header.
92 //
93 Status = VirtioFsFuseNewRequest (
94 VirtioFs,
95 &CommonReq,
96 ReqSgList.TotalSize,
97 VirtioFsFuseOpMkDir,
98 ParentNodeId
99 );
100 if (EFI_ERROR (Status)) {
101 return Status;
102 }
103
104 //
105 // Populate the FUSE_MKDIR-specific fields.
106 //
107 MkDirReq.Mode = (VIRTIO_FS_FUSE_MODE_PERM_RWXU |
108 VIRTIO_FS_FUSE_MODE_PERM_RWXG |
109 VIRTIO_FS_FUSE_MODE_PERM_RWXO);
110 MkDirReq.Umask = 0;
111
112 //
113 // Submit the request.
114 //
115 Status = VirtioFsSgListsSubmit (VirtioFs, &ReqSgList, &RespSgList);
116 if (EFI_ERROR (Status)) {
117 return Status;
118 }
119
120 //
121 // Verify the response (all response buffers are fixed size).
122 //
123 Status = VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NULL);
124 if (EFI_ERROR (Status)) {
125 if (Status == EFI_DEVICE_ERROR) {
126 DEBUG ((
127 DEBUG_ERROR,
128 "%a: Label=\"%s\" ParentNodeId=%Lu Name=\"%a\" "
129 "Errno=%d\n",
130 __func__,
131 VirtioFs->Label,
132 ParentNodeId,
133 Name,
134 CommonResp.Error
135 ));
136 Status = VirtioFsErrnoToEfiStatus (CommonResp.Error);
137 }
138
139 return Status;
140 }
141
142 //
143 // Output the NodeId of the new directory.
144 //
145 *NodeId = NodeResp.NodeId;
146 return EFI_SUCCESS;
147}
UINTN EFIAPI AsciiStrSize(IN CONST CHAR8 *String)
Definition: String.c:681
EFI_STATUS VirtioFsFuseMkDir(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 ParentNodeId, IN CHAR8 *Name, OUT UINT64 *NodeId)
Definition: FuseMkDir.c:43
#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