43 IN BOOLEAN OpenForWriting
62 VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID,
65 if (EFI_ERROR (Status)) {
70 if (EFI_ERROR (Status)) {
75 return EFI_ACCESS_DENIED;
80 if (EFI_ERROR (Status)) {
84 NewVirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (*NewHandle);
85 NewVirtioFsFile->IsOpenForWriting = OpenForWriting;
143 IN BOOLEAN OpenForWriting,
145 OUT UINT64 *FuseHandle,
146 OUT BOOLEAN *NodeIsDirectory
150 UINT64 ResolvedNodeId;
154 UINT64 NewFuseHandle;
163 if (EFI_ERROR (Status)) {
168 if (EFI_ERROR (Status)) {
169 goto ForgetResolvedNodeId;
173 Status = EFI_ACCESS_DENIED;
174 goto ForgetResolvedNodeId;
195 if (EFI_ERROR (Status)) {
196 goto ForgetResolvedNodeId;
199 *NodeId = ResolvedNodeId;
200 *FuseHandle = NewFuseHandle;
201 *NodeIsDirectory = IsDirectory;
206 return (Status == EFI_NOT_FOUND) ? EFI_DEVICE_ERROR : Status;
239 OUT UINT64 *FuseHandle
243 UINT64 NewChildDirNodeId;
244 UINT64 NewFuseHandle;
247 if (EFI_ERROR (Status)) {
252 if (EFI_ERROR (Status)) {
253 goto RemoveNewChildDir;
256 *NodeId = NewChildDirNodeId;
257 *FuseHandle = NewFuseHandle;
296 OUT UINT64 *FuseHandle
310VirtioFsSimpleFileOpen (
320 BOOLEAN OpenForWriting;
321 BOOLEAN PermitCreation;
322 BOOLEAN CreateDirectoryIfCreating;
325 CHAR8 *NewCanonicalPath;
328 CHAR8 *LastComponent;
330 UINT64 NewFuseHandle;
331 BOOLEAN NewNodeIsDirectory;
333 VirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This);
334 VirtioFs = VirtioFsFile->OwnerFs;
340 case EFI_FILE_MODE_READ:
341 OpenForWriting =
FALSE;
342 PermitCreation =
FALSE;
344 case EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE:
345 OpenForWriting =
TRUE;
346 PermitCreation =
FALSE;
348 case EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE:
349 OpenForWriting =
TRUE;
350 PermitCreation =
TRUE;
353 return EFI_INVALID_PARAMETER;
360 CreateDirectoryIfCreating =
FALSE;
366 if (PermitCreation) {
367 if ((Attributes & ~EFI_FILE_VALID_ATTR) != 0) {
371 return EFI_INVALID_PARAMETER;
374 ASSERT (OpenForWriting);
375 if ((Attributes & EFI_FILE_READ_ONLY) != 0) {
378 (
"%a: Label=\"%s\" CanonicalPathname=\"%a\" FileName=\"%s\" "
379 "OpenMode=0x%Lx Attributes=0x%Lx: nonsensical request to possibly "
380 "create a file marked read-only, for read-write access\n"),
383 VirtioFsFile->CanonicalPathname,
388 return EFI_INVALID_PARAMETER;
391 CreateDirectoryIfCreating = (BOOLEAN)((Attributes &
392 EFI_FILE_DIRECTORY) != 0);
400 if (!VirtioFsFile->IsDirectory) {
408 BugCompat = (FileName[0] == L
'\\');
411 BugCompat ? DEBUG_WARN : DEBUG_ERROR,
412 (
"%a: Label=\"%s\" CanonicalPathname=\"%a\" FileName=\"%s\": "
413 "nonsensical request to open a file or directory relative to a regular "
417 VirtioFsFile->CanonicalPathname,
421 return EFI_INVALID_PARAMETER;
428 NewVirtioFsFile =
AllocatePool (
sizeof *NewVirtioFsFile);
429 if (NewVirtioFsFile ==
NULL) {
430 return EFI_OUT_OF_RESOURCES;
438 VirtioFsFile->CanonicalPathname,
443 if (EFI_ERROR (Status)) {
444 goto FreeNewVirtioFsFile;
448 Status = EFI_ACCESS_DENIED;
449 goto FreeNewCanonicalPath;
473 if (EFI_ERROR (Status)) {
474 goto FreeNewCanonicalPath;
480 NewNodeIsDirectory =
FALSE;
500 if ((Status == EFI_NOT_FOUND) && PermitCreation) {
501 ASSERT (OpenForWriting);
502 if (CreateDirectoryIfCreating) {
520 NewNodeIsDirectory = CreateDirectoryIfCreating;
526 if (DirNodeId != VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID) {
530 if (EFI_ERROR (Status)) {
531 goto FreeNewCanonicalPath;
537 NewVirtioFsFile->Signature = VIRTIO_FS_FILE_SIG;
538 NewVirtioFsFile->SimpleFile.
Revision = EFI_FILE_PROTOCOL_REVISION;
539 NewVirtioFsFile->SimpleFile.Open = VirtioFsSimpleFileOpen;
540 NewVirtioFsFile->SimpleFile.Close = VirtioFsSimpleFileClose;
541 NewVirtioFsFile->SimpleFile.Delete = VirtioFsSimpleFileDelete;
542 NewVirtioFsFile->SimpleFile.Read = VirtioFsSimpleFileRead;
543 NewVirtioFsFile->SimpleFile.Write = VirtioFsSimpleFileWrite;
544 NewVirtioFsFile->SimpleFile.GetPosition = VirtioFsSimpleFileGetPosition;
545 NewVirtioFsFile->SimpleFile.SetPosition = VirtioFsSimpleFileSetPosition;
546 NewVirtioFsFile->SimpleFile.GetInfo = VirtioFsSimpleFileGetInfo;
547 NewVirtioFsFile->SimpleFile.SetInfo = VirtioFsSimpleFileSetInfo;
548 NewVirtioFsFile->SimpleFile.Flush = VirtioFsSimpleFileFlush;
549 NewVirtioFsFile->IsDirectory = NewNodeIsDirectory;
550 NewVirtioFsFile->IsOpenForWriting = OpenForWriting;
551 NewVirtioFsFile->OwnerFs = VirtioFs;
552 NewVirtioFsFile->CanonicalPathname = NewCanonicalPath;
553 NewVirtioFsFile->FilePosition = 0;
554 NewVirtioFsFile->NodeId = NewNodeId;
555 NewVirtioFsFile->FuseHandle = NewFuseHandle;
556 NewVirtioFsFile->FileInfoArray =
NULL;
557 NewVirtioFsFile->SingleFileInfoSize = 0;
558 NewVirtioFsFile->NumFileInfo = 0;
559 NewVirtioFsFile->NextFileInfo = 0;
564 InsertTailList (&VirtioFs->OpenFiles, &NewVirtioFsFile->OpenFilesEntry);
566 *NewHandle = &NewVirtioFsFile->SimpleFile;
INTN EFIAPI AsciiStrCmp(IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS VirtioFsFuseForget(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId)
EFI_STATUS VirtioFsFuseGetAttr(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId, OUT VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr)
EFI_STATUS VirtioFsFuseLookup(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 DirNodeId, IN CHAR8 *Name, OUT UINT64 *NodeId, OUT VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr)
EFI_STATUS VirtioFsFuseMkDir(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 ParentNodeId, IN CHAR8 *Name, OUT UINT64 *NodeId)
EFI_STATUS VirtioFsFuseOpen(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId, IN BOOLEAN ReadWrite, OUT UINT64 *FuseHandle)
EFI_STATUS VirtioFsFuseOpenDir(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId, OUT UINT64 *FuseHandle)
EFI_STATUS VirtioFsFuseOpenOrCreate(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 ParentNodeId, IN CHAR8 *Name, OUT UINT64 *NodeId, OUT UINT64 *FuseHandle)
EFI_STATUS VirtioFsFuseRemoveFileOrDir(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 ParentNodeId, IN CHAR8 *Name, IN BOOLEAN IsDir)
#define DEBUG(Expression)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
EFI_FILE_INFO * FileInfo(IN EFI_FILE_HANDLE FHand)
STATIC EFI_STATUS OpenRootDirectory(IN OUT VIRTIO_FS *VirtioFs, OUT EFI_FILE_PROTOCOL **NewHandle, IN BOOLEAN OpenForWriting)
STATIC EFI_STATUS CreateDirectory(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 DirNodeId, IN CHAR8 *Name, OUT UINT64 *NodeId, OUT UINT64 *FuseHandle)
STATIC EFI_STATUS CreateRegularFile(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 DirNodeId, IN CHAR8 *Name, OUT UINT64 *NodeId, OUT UINT64 *FuseHandle)
STATIC EFI_STATUS OpenExistentFileOrDirectory(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 DirNodeId, IN CHAR8 *Name, IN BOOLEAN OpenForWriting, OUT UINT64 *NodeId, OUT UINT64 *FuseHandle, OUT BOOLEAN *NodeIsDirectory)
EFI_STATUS EFIAPI VirtioFsOpenVolume(IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This, OUT EFI_FILE_PROTOCOL **Root)
EFI_STATUS VirtioFsLookupMostSpecificParentDir(IN OUT VIRTIO_FS *VirtioFs, IN OUT CHAR8 *Path, OUT UINT64 *DirNodeId, OUT CHAR8 **LastComponent)
EFI_STATUS VirtioFsAppendPath(IN CHAR8 *LhsPath8, IN CHAR16 *RhsPath16, OUT CHAR8 **ResultPath8, OUT BOOLEAN *RootEscape)
EFI_STATUS VirtioFsFuseAttrToEfiFileInfo(IN VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr, OUT EFI_FILE_INFO *FileInfo)