TianoCore EDK2 master
Loading...
Searching...
No Matches
VirtioFsDxe.h File Reference
#include <Base.h>
#include <Guid/FileInfo.h>
#include <IndustryStandard/VirtioFs.h>
#include <Library/DebugLib.h>
#include <Protocol/SimpleFileSystem.h>
#include <Protocol/VirtioDevice.h>
#include <Uefi/UefiBaseType.h>

Go to the source code of this file.

Data Structures

struct  VIRTIO_FS
 
struct  VIRTIO_FS_IO_VECTOR
 
struct  VIRTIO_FS_SCATTER_GATHER_LIST
 
struct  VIRTIO_FS_FILE
 

Macros

#define VIRTIO_FS_SIG   SIGNATURE_64 ('V', 'I', 'R', 'T', 'I', 'O', 'F', 'S')
 
#define VIRTIO_FS_FILE_SIG    SIGNATURE_64 ('V', 'I', 'O', 'F', 'S', 'F', 'I', 'L')
 
#define VIRTIO_FS_MAX_PATHNAME_LENGTH   ((UINTN)65535)
 
#define VIRTIO_FS_FILE_MAX_FILE_INFO   256
 
#define VIRTIO_FS_FROM_SIMPLE_FS(SimpleFsReference)    CR (SimpleFsReference, VIRTIO_FS, SimpleFs, VIRTIO_FS_SIG);
 
#define VIRTIO_FS_FILE_FROM_SIMPLE_FILE(SimpleFileReference)    CR (SimpleFileReference, VIRTIO_FS_FILE, SimpleFile, VIRTIO_FS_FILE_SIG);
 
#define VIRTIO_FS_FILE_FROM_OPEN_FILES_ENTRY(OpenFilesEntryReference)
 

Typedefs

typedef CHAR16 VIRTIO_FS_LABEL[VIRTIO_FS_TAG_BYTES+1]
 

Functions

EFI_STATUS VirtioFsInit (IN OUT VIRTIO_FS *VirtioFs)
 
VOID VirtioFsUninit (IN OUT VIRTIO_FS *VirtioFs)
 
VOID EFIAPI VirtioFsExitBoot (IN EFI_EVENT ExitBootEvent, IN VOID *VirtioFsAsVoid)
 
EFI_STATUS VirtioFsSgListsValidate (IN VIRTIO_FS *VirtioFs, IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *RequestSgList, IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *ResponseSgList OPTIONAL)
 
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)
 
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)
 
EFI_STATUS VirtioFsFuseCheckResponse (IN VIRTIO_FS_SCATTER_GATHER_LIST *ResponseSgList, IN UINT64 RequestId, OUT UINTN *TailBufferFill)
 
EFI_STATUS VirtioFsErrnoToEfiStatus (IN INT32 Errno)
 
EFI_STATUS VirtioFsAppendPath (IN CHAR8 *LhsPath8, IN CHAR16 *RhsPath16, OUT CHAR8 **ResultPath8, OUT BOOLEAN *RootEscape)
 
EFI_STATUS VirtioFsLookupMostSpecificParentDir (IN OUT VIRTIO_FS *VirtioFs, IN OUT CHAR8 *Path, OUT UINT64 *DirNodeId, OUT CHAR8 **LastComponent)
 
EFI_STATUS VirtioFsGetBasename (IN CHAR8 *Path, OUT CHAR16 *Basename OPTIONAL, IN OUT UINTN *BasenameSize)
 
EFI_STATUS VirtioFsComposeRenameDestination (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)
 
EFI_STATUS VirtioFsFuseDirentPlusToEfiFileInfo (IN VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE *FuseDirent, IN OUT EFI_FILE_INFO *FileInfo)
 
VOID VirtioFsGetFuseSizeUpdate (IN EFI_FILE_INFO *Info, IN EFI_FILE_INFO *NewInfo, OUT BOOLEAN *Update, OUT UINT64 *Size)
 
EFI_STATUS VirtioFsGetFuseTimeUpdates (IN EFI_FILE_INFO *Info, IN EFI_FILE_INFO *NewInfo, OUT BOOLEAN *UpdateAtime, OUT BOOLEAN *UpdateMtime, OUT UINT64 *Atime, OUT UINT64 *Mtime)
 
EFI_STATUS VirtioFsGetFuseModeUpdate (IN EFI_FILE_INFO *Info, IN EFI_FILE_INFO *NewInfo, OUT BOOLEAN *Update, OUT UINT32 *Mode)
 
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 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 VirtioFsFuseSetAttr (IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId, IN UINT64 *Size OPTIONAL, IN UINT64 *Atime OPTIONAL, IN UINT64 *Mtime OPTIONAL, IN UINT32 *Mode OPTIONAL)
 
EFI_STATUS VirtioFsFuseMkDir (IN OUT VIRTIO_FS *VirtioFs, IN UINT64 ParentNodeId, IN CHAR8 *Name, OUT UINT64 *NodeId)
 
EFI_STATUS VirtioFsFuseRemoveFileOrDir (IN OUT VIRTIO_FS *VirtioFs, IN UINT64 ParentNodeId, IN CHAR8 *Name, IN BOOLEAN IsDir)
 
EFI_STATUS VirtioFsFuseOpen (IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId, IN BOOLEAN ReadWrite, OUT UINT64 *FuseHandle)
 
EFI_STATUS VirtioFsFuseReadFileOrDir (IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId, IN UINT64 FuseHandle, IN BOOLEAN IsDir, IN UINT64 Offset, IN OUT UINT32 *Size, OUT VOID *Data)
 
EFI_STATUS VirtioFsFuseWrite (IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId, IN UINT64 FuseHandle, IN UINT64 Offset, IN OUT UINT32 *Size, IN VOID *Data)
 
EFI_STATUS VirtioFsFuseStatFs (IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId, OUT VIRTIO_FS_FUSE_STATFS_RESPONSE *FilesysAttr)
 
EFI_STATUS VirtioFsFuseReleaseFileOrDir (IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId, IN UINT64 FuseHandle, IN BOOLEAN IsDir)
 
EFI_STATUS VirtioFsFuseFsyncFileOrDir (IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId, IN UINT64 FuseHandle, IN BOOLEAN IsDir)
 
EFI_STATUS VirtioFsFuseFlush (IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId, IN UINT64 FuseHandle)
 
EFI_STATUS VirtioFsFuseInitSession (IN OUT VIRTIO_FS *VirtioFs)
 
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 VirtioFsFuseRename (IN OUT VIRTIO_FS *VirtioFs, IN UINT64 OldParentNodeId, IN CHAR8 *OldName, IN UINT64 NewParentNodeId, IN CHAR8 *NewName)
 
EFI_STATUS EFIAPI VirtioFsOpenVolume (IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This, OUT EFI_FILE_PROTOCOL **Root)
 
EFI_STATUS EFIAPI VirtioFsSimpleFileClose (IN EFI_FILE_PROTOCOL *This)
 
EFI_STATUS EFIAPI VirtioFsSimpleFileDelete (IN EFI_FILE_PROTOCOL *This)
 
EFI_STATUS EFIAPI VirtioFsSimpleFileFlush (IN EFI_FILE_PROTOCOL *This)
 
EFI_STATUS EFIAPI VirtioFsSimpleFileGetInfo (IN EFI_FILE_PROTOCOL *This, IN EFI_GUID *InformationType, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
 
EFI_STATUS EFIAPI VirtioFsSimpleFileGetPosition (IN EFI_FILE_PROTOCOL *This, OUT UINT64 *Position)
 
EFI_STATUS EFIAPI VirtioFsSimpleFileOpen (IN EFI_FILE_PROTOCOL *This, OUT EFI_FILE_PROTOCOL **NewHandle, IN CHAR16 *FileName, IN UINT64 OpenMode, IN UINT64 Attributes)
 
EFI_STATUS EFIAPI VirtioFsSimpleFileRead (IN EFI_FILE_PROTOCOL *This, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
 
EFI_STATUS EFIAPI VirtioFsSimpleFileSetInfo (IN EFI_FILE_PROTOCOL *This, IN EFI_GUID *InformationType, IN UINTN BufferSize, IN VOID *Buffer)
 
EFI_STATUS EFIAPI VirtioFsSimpleFileSetPosition (IN EFI_FILE_PROTOCOL *This, IN UINT64 Position)
 
EFI_STATUS EFIAPI VirtioFsSimpleFileWrite (IN EFI_FILE_PROTOCOL *This, IN OUT UINTN *BufferSize, IN VOID *Buffer)
 

Detailed Description

Internal macro definitions, type definitions, and function declarations for the Virtio Filesystem device driver.

Copyright (C) 2020, Red Hat, Inc.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file VirtioFsDxe.h.

Macro Definition Documentation

◆ VIRTIO_FS_FILE_FROM_OPEN_FILES_ENTRY

#define VIRTIO_FS_FILE_FROM_OPEN_FILES_ENTRY (   OpenFilesEntryReference)
Value:
CR (OpenFilesEntryReference, VIRTIO_FS_FILE, OpenFilesEntry, \
VIRTIO_FS_FILE_SIG);
#define CR(Record, TYPE, Field, TestSignature)
Definition: DebugLib.h:659

Definition at line 182 of file VirtioFsDxe.h.

◆ VIRTIO_FS_FILE_FROM_SIMPLE_FILE

#define VIRTIO_FS_FILE_FROM_SIMPLE_FILE (   SimpleFileReference)     CR (SimpleFileReference, VIRTIO_FS_FILE, SimpleFile, VIRTIO_FS_FILE_SIG);

Definition at line 179 of file VirtioFsDxe.h.

◆ VIRTIO_FS_FILE_MAX_FILE_INFO

#define VIRTIO_FS_FILE_MAX_FILE_INFO   256

Definition at line 53 of file VirtioFsDxe.h.

◆ VIRTIO_FS_FILE_SIG

#define VIRTIO_FS_FILE_SIG    SIGNATURE_64 ('V', 'I', 'O', 'F', 'S', 'F', 'I', 'L')

Definition at line 23 of file VirtioFsDxe.h.

◆ VIRTIO_FS_FROM_SIMPLE_FS

#define VIRTIO_FS_FROM_SIMPLE_FS (   SimpleFsReference)     CR (SimpleFsReference, VIRTIO_FS, SimpleFs, VIRTIO_FS_SIG);

Definition at line 87 of file VirtioFsDxe.h.

◆ VIRTIO_FS_MAX_PATHNAME_LENGTH

#define VIRTIO_FS_MAX_PATHNAME_LENGTH   ((UINTN)65535)

Definition at line 48 of file VirtioFsDxe.h.

◆ VIRTIO_FS_SIG

#define VIRTIO_FS_SIG   SIGNATURE_64 ('V', 'I', 'R', 'T', 'I', 'O', 'F', 'S')

Definition at line 21 of file VirtioFsDxe.h.

Typedef Documentation

◆ VIRTIO_FS_LABEL

typedef CHAR16 VIRTIO_FS_LABEL[VIRTIO_FS_TAG_BYTES+1]

Definition at line 60 of file VirtioFsDxe.h.

Function Documentation

◆ VirtioFsAppendPath()

EFI_STATUS VirtioFsAppendPath ( IN CHAR8 *  LhsPath8,
IN CHAR16 *  RhsPath16,
OUT CHAR8 **  ResultPath8,
OUT BOOLEAN *  RootEscape 
)

Append the UEFI-style RhsPath16 to the POSIX-style, canonical format LhsPath8. Output the POSIX-style, canonical format result in ResultPath, as a dynamically allocated string.

Canonicalization (aka sanitization) establishes the following properties:

  • ResultPath is absolute (starts with "/"),
  • dot (.) and dot-dot (..) components are resolved/eliminated in ResultPath, with the usual semantics,
  • ResultPath uses forward slashes,
  • sequences of slashes are squashed in ResultPath,
  • the printable ASCII character set covers ResultPath,
  • CHAR8 encoding is used in ResultPath,
  • no trailing slash present in ResultPath except for the standalone root directory,
  • the length of ResultPath is at most VIRTIO_FS_MAX_PATHNAME_LENGTH.

Any dot-dot in RhsPath16 that would remove the root directory is dropped, and reported through RootEscape, without failing the function call.

Parameters
[in]LhsPath8Identifies the base directory. The caller is responsible for ensuring that LhsPath8 conform to the above canonical pathname format on entry.
[in]RhsPath16Identifies the desired file with a UEFI-style CHAR16 pathname. If RhsPath16 starts with a backslash, then RhsPath16 is considered absolute, and LhsPath8 is ignored; RhsPath16 is sanitized in isolation, for producing ResultPath8. Otherwise (i.e., if RhsPath16 is relative), RhsPath16 is transliterated to CHAR8, and naively appended to LhsPath8. The resultant fused pathname is then sanitized, to produce ResultPath8.
[out]ResultPath8The POSIX-style, canonical format pathname that leads to the file desired by the caller. After use, the caller is responsible for freeing ResultPath8.
[out]RootEscapeSet to TRUE if at least one dot-dot component in RhsPath16 attempted to escape the root directory; set to FALSE otherwise.
Return values
EFI_SUCCESSResultPath8 has been produced. RootEscape has been output.
EFI_INVALID_PARAMETERRhsPath16 is zero-length.
EFI_INVALID_PARAMETERRhsPath16 failed the VIRTIO_FS_MAX_PATHNAME_LENGTH check.
EFI_OUT_OF_RESOURCESMemory allocation failed.
EFI_OUT_OF_RESOURCESResultPath8 would have failed the VIRTIO_FS_MAX_PATHNAME_LENGTH check.
EFI_UNSUPPORTEDRhsPath16 contains a character that either falls outside of the printable ASCII set, or is a forward slash.

Definition at line 1404 of file Helpers.c.

◆ VirtioFsComposeRenameDestination()

EFI_STATUS VirtioFsComposeRenameDestination ( IN CHAR8 *  LhsPath8,
IN CHAR16 *  RhsPath16,
OUT CHAR8 **  ResultPath8,
OUT BOOLEAN *  RootEscape 
)

Format the destination of a rename/move operation as a dynamically allocated canonical pathname.

Any dot-dot in RhsPath16 that would remove the root directory is dropped, and reported through RootEscape, without failing the function call.

Parameters
[in]LhsPath8The source pathname operand of the rename/move operation, expressed as a canonical pathname (as defined in the description of VirtioFsAppendPath()). The root directory "/" cannot be renamed/moved, and will be rejected.
[in]RhsPath16The destination pathname operand expressed as a UEFI-style CHAR16 pathname.

If RhsPath16 starts with a backslash, then RhsPath16 is considered absolute. Otherwise, RhsPath16 is interpreted relative to the most specific parent directory found in LhsPath8.

Independently, if RhsPath16 ends with a backslash (i.e., RhsPath16 is given in the "move into directory" convenience form), then RhsPath16 is interpreted with the basename of LhsPath8 appended. Otherwise, the last pathname component of RhsPath16 is taken as the last pathname component of the rename/move destination.

An empty RhsPath16 is rejected.

Parameters
[out]ResultPath8The POSIX-style, canonical format pathname that leads to the renamed/moved file. After use, the caller is responsible for freeing ResultPath8.
[out]RootEscapeSet to TRUE if at least one dot-dot component in RhsPath16 attempted to escape the root directory; set to FALSE otherwise.
Return values
EFI_SUCCESSResultPath8 has been produced. RootEscape has been output.
EFI_INVALID_PARAMETERLhsPath8 is "/".
EFI_INVALID_PARAMETERRhsPath16 is zero-length.
EFI_INVALID_PARAMETERRhsPath16 failed the VIRTIO_FS_MAX_PATHNAME_LENGTH check.
EFI_OUT_OF_RESOURCESMemory allocation failed.
EFI_OUT_OF_RESOURCESResultPath8 would have failed the VIRTIO_FS_MAX_PATHNAME_LENGTH check.
EFI_UNSUPPORTEDRhsPath16 contains a character that either falls outside of the printable ASCII set, or is a forward slash.

Definition at line 1918 of file Helpers.c.

◆ VirtioFsErrnoToEfiStatus()

EFI_STATUS VirtioFsErrnoToEfiStatus ( IN INT32  Errno)

An ad-hoc function for mapping FUSE (well, Linux) "errno" values to EFI_STATUS.

Parameters
[in]ErrnoThe "VIRTIO_FS_FUSE_RESPONSE.Error" value, returned by the Virtio Filesystem device. The value is expected to be negative.
Returns
An EFI_STATUS error code that's deemed a passable mapping for the Errno value.
Return values
EFI_DEVICE_ERRORFallback EFI_STATUS code for unrecognized Errno values.

Definition at line 991 of file Helpers.c.

◆ VirtioFsExitBoot()

VOID EFIAPI VirtioFsExitBoot ( IN EFI_EVENT  ExitBootEvent,
IN VOID *  VirtioFsAsVoid 
)

ExitBootServices event notification function for a Virtio Filesystem object.

This function resets the VIRTIO_FS.Virtio device, causing it to release all references to guest-side resources. The function may only be called after VirtioFsInit() returns successfully and before VirtioFsUninit() is called.

Parameters
[in]ExitBootEventThe VIRTIO_FS.ExitBoot event that has been signaled.
[in]VirtioFsAsVoidPointer to the VIRTIO_FS object, passed in as (VOID*).

Definition at line 312 of file Helpers.c.

◆ VirtioFsFuseAttrToEfiFileInfo()

EFI_STATUS VirtioFsFuseAttrToEfiFileInfo ( IN VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE FuseAttr,
OUT EFI_FILE_INFO FileInfo 
)

Convert select fields of a VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE object to corresponding fields in EFI_FILE_INFO.

Parameters
[in]FuseAttrThe VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE object to convert the relevant fields from.
[out]FileInfoThe EFI_FILE_INFO structure to modify. Importantly, the FileInfo->Size and FileInfo->FileName fields are not overwritten.
Return values
EFI_SUCCESSConversion successful.
EFI_UNSUPPORTEDThe allocated size of the file is inexpressible in EFI_FILE_INFO.
EFI_UNSUPPORTEDOne of the file access times is inexpressible in EFI_FILE_INFO.
EFI_UNSUPPORTEDThe file type is inexpressible in EFI_FILE_INFO.
EFI_UNSUPPORTEDThe file is a regular file that has multiple names on the host side (i.e., its hard link count is greater than one).

Definition at line 2090 of file Helpers.c.

◆ VirtioFsFuseCheckResponse()

EFI_STATUS VirtioFsFuseCheckResponse ( IN VIRTIO_FS_SCATTER_GATHER_LIST ResponseSgList,
IN UINT64  RequestId,
OUT UINTN TailBufferFill 
)

Check the common FUSE response format.

The first buffer in the response scatter-gather list is assumed a VIRTIO_FS_FUSE_RESPONSE structure. Subsequent response buffers, if any, up to and excluding the last one, are assumed fixed size. The last response buffer may or may not be fixed size, as specified by the caller.

This function may only be called after VirtioFsSgListsSubmit() returns successfully.

Parameters
[in]ResponseSgListThe scatter-gather list that describes the response part of the exchange – the buffers that the Virtio Filesystem device filled in during the virtio transfer.
[in]RequestIdThe request identifier to which the response is expected to belong.
[out]TailBufferFillIf NULL, then the last buffer in ResponseSgList is considered fixed size. Otherwise, the last buffer is considered variable size, and on successful return, TailBufferFill reports the number of bytes in the last buffer.
Return values
EFI_INVALID_PARAMETERTailBufferFill is not NULL (i.e., the last buffer is considered variable size), and ResponseSgList->NumVec is 1.
EFI_INVALID_PARAMETERThe allocated size of the first buffer does not match sizeof(VIRTIO_FS_FUSE_RESPONSE).
EFI_PROTOCOL_ERRORThe VIRTIO_FS_FUSE_RESPONSE structure in the first buffer has not been fully populated.
EFI_PROTOCOL_ERROR"VIRTIO_FS_FUSE_RESPONSE.Len" in the first buffer does not equal the sum of the individual buffer sizes (as populated).
EFI_PROTOCOL_ERROR"VIRTIO_FS_FUSE_RESPONSE.Unique" in the first buffer does not equal RequestId.
EFI_PROTOCOL_ERROR"VIRTIO_FS_FUSE_RESPONSE.Error" in the first buffer is zero, but a subsequent fixed size buffer has not been fully populated.
EFI_DEVICE_ERROR"VIRTIO_FS_FUSE_RESPONSE.Error" in the first buffer is nonzero. The caller may investigate "VIRTIO_FS_FUSE_RESPONSE.Error". Note that the completeness of the subsequent fixed size buffers is not verified in this case.
EFI_SUCCESSVerification successful.

Definition at line 873 of file Helpers.c.

◆ VirtioFsFuseDirentPlusToEfiFileInfo()

EFI_STATUS VirtioFsFuseDirentPlusToEfiFileInfo ( IN VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE FuseDirent,
IN OUT EFI_FILE_INFO FileInfo 
)

Convert a VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE filename to an EFI_FILE_INFO filename.

Parameters
[in]FuseDirentThe VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE object to convert the filename byte array from. The caller is responsible for ensuring that FuseDirent->Namelen describe valid storage.
[in,out]FileInfoThe EFI_FILE_INFO structure to modify. On input, the caller is responsible for setting FileInfo->Size according to the allocated size. On successful return, FileInfo->Size is reduced to reflect the filename converted into FileInfo->FileName. FileInfo->FileName is set from the filename byte array that directly follows the FuseDirent header object. Fields other than FileInfo->Size and FileInfo->FileName are not modified.
Return values
EFI_SUCCESSConversion successful.
EFI_INVALID_PARAMETERVIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE_SIZE() returns zero for FuseDirent->Namelen.
EFI_BUFFER_TOO_SMALLOn input, FileInfo->Size does not provide enough room for converting the filename byte array from FuseDirent.
EFI_UNSUPPORTEDThe FuseDirent filename byte array contains a byte that falls outside of the printable ASCII range, or is a forward slash or a backslash.

Definition at line 2219 of file Helpers.c.

◆ VirtioFsFuseFlush()

EFI_STATUS VirtioFsFuseFlush ( IN OUT VIRTIO_FS VirtioFs,
IN UINT64  NodeId,
IN UINT64  FuseHandle 
)

Flush changes queued on the local virtualization host to the remote storage server's memory (not storage device), over the network, by sending the FUSE_FLUSH request to the Virtio Filesystem device.

The function may only be called after VirtioFsFuseInitSession() returns successfully and before VirtioFsUninit() is called.

Parameters
[in,out]VirtioFsThe Virtio Filesystem device to send the FUSE_FLUSH request to. On output, the FUSE request counter "VirtioFs->RequestId" will have been incremented.
[in]NodeIdThe inode number of the regular file to flush.
[in]FuseHandleThe open handle to the regular file to flush.
Return values
EFI_SUCCESSThe regular file has been flushed.
Returns
The "errno" value mapped to an EFI_STATUS code, if the Virtio Filesystem device explicitly reported an error.
Error codes propagated from VirtioFsSgListsValidate(), VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit(), VirtioFsFuseCheckResponse().

Definition at line 37 of file FuseFlush.c.

◆ VirtioFsFuseForget()

EFI_STATUS VirtioFsFuseForget ( IN OUT VIRTIO_FS VirtioFs,
IN UINT64  NodeId 
)

Make the Virtio Filesysem device drop one reference count from a NodeId that the driver looked up by filename.

Send the FUSE_FORGET request to the Virtio Filesysem device for this. Unlike most other FUSE requests, FUSE_FORGET doesn't elicit a response, not even the common VIRTIO_FS_FUSE_RESPONSE header.

The function may only be called after VirtioFsFuseInitSession() returns successfully and before VirtioFsUninit() is called.

Parameters
[in,out]VirtioFsThe Virtio Filesystem device to send the FUSE_FORGET request to. On output, the FUSE request counter "VirtioFs->RequestId" will have been incremented.
[in]NodeIdThe inode number that the client learned by way of lookup, and that the server should now un-reference exactly once.
Return values
EFI_SUCCESSThe FUSE_FORGET request has been submitted.
Returns
Error codes propagated from VirtioFsSgListsValidate(), VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit().

Definition at line 36 of file FuseForget.c.

◆ VirtioFsFuseFsyncFileOrDir()

EFI_STATUS VirtioFsFuseFsyncFileOrDir ( IN OUT VIRTIO_FS VirtioFs,
IN UINT64  NodeId,
IN UINT64  FuseHandle,
IN BOOLEAN  IsDir 
)

Synchronize the in-core state of a regular file or a directory with the storage device on the host, by sending the FUSE_FSYNC or FUSE_FSYNCDIR request to the Virtio Filesystem device.

The function may only be called after VirtioFsFuseInitSession() returns successfully and before VirtioFsUninit() is called.

Parameters
[in,out]VirtioFsThe Virtio Filesystem device to send the FUSE_FSYNC / FUSE_FSYNCDIR request to. On output, the FUSE request counter "VirtioFs->RequestId" will have been incremented.
[in]NodeIdThe inode number of the file or directory to sync.
[in]FuseHandleThe open handle to the file or directory to sync.
[in]IsDirTRUE if NodeId and FuseHandle refer to a directory, FALSE if NodeId and FuseHandle refer to a regular file.
Return values
EFI_SUCCESSThe file or directory has been synchronized.
Returns
The "errno" value mapped to an EFI_STATUS code, if the Virtio Filesystem device explicitly reported an error.
Error codes propagated from VirtioFsSgListsValidate(), VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit(), VirtioFsFuseCheckResponse().

Definition at line 42 of file FuseFsync.c.

◆ VirtioFsFuseGetAttr()

EFI_STATUS VirtioFsFuseGetAttr ( IN OUT VIRTIO_FS VirtioFs,
IN UINT64  NodeId,
OUT VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE FuseAttr 
)

Send a FUSE_GETATTR request to the Virtio Filesystem device, for fetching the attributes of an inode.

The function may only be called after VirtioFsFuseInitSession() returns successfully and before VirtioFsUninit() is called.

Parameters
[in,out]VirtioFsThe Virtio Filesystem device to send the FUSE_GETATTR request to. On output, the FUSE request counter "VirtioFs->RequestId" will have been incremented.
[in]NodeIdThe inode number for which the attributes should be retrieved.
[out]FuseAttrThe VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE object describing the properties of the inode.
Return values
EFI_SUCCESSFuseAttr has been filled in.
Returns
The "errno" value mapped to an EFI_STATUS code, if the Virtio Filesystem device explicitly reported an error.
Error codes propagated from VirtioFsSgListsValidate(), VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit(), VirtioFsFuseCheckResponse().

Definition at line 39 of file FuseGetAttr.c.

◆ VirtioFsFuseInitSession()

EFI_STATUS VirtioFsFuseInitSession ( IN OUT VIRTIO_FS VirtioFs)

Send a FUSE_INIT request to the Virtio Filesystem device, for starting the FUSE session.

From virtio-v1.1-cs01-87fa6b5d8155, 5.11.5 Device Initialization: "On initialization the driver first discovers the device's virtqueues. The FUSE session is started by sending a FUSE_INIT request as defined by the FUSE protocol on one request virtqueue."

The function may only be called after VirtioFsInit() returns successfully and before VirtioFsUninit() is called.

Parameters
[in,out]VirtioFsThe Virtio Filesystem device to send the FUSE_INIT request to. The FUSE request counter "VirtioFs->RequestId" is set to 1 on output. The maximum write buffer size exposed in the FUSE_INIT response is saved in "VirtioFs->MaxWrite", on output.
Return values
EFI_SUCCESSThe FUSE session has been started.
EFI_UNSUPPORTEDFUSE interface version or feature negotiation failed.
Returns
The "errno" value mapped to an EFI_STATUS code, if the Virtio Filesystem device explicitly reported an error.
Error codes propagated from VirtioFsSgListsValidate(), VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit(), VirtioFsFuseCheckResponse().

Definition at line 45 of file FuseInit.c.

◆ VirtioFsFuseLookup()

EFI_STATUS VirtioFsFuseLookup ( IN OUT VIRTIO_FS VirtioFs,
IN UINT64  DirNodeId,
IN CHAR8 *  Name,
OUT UINT64 *  NodeId,
OUT VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE FuseAttr 
)

Send a FUSE_LOOKUP request to the Virtio Filesystem device, for resolving a filename to an inode.

The function returns EFI_NOT_FOUND exclusively if the Virtio Filesystem device explicitly responds with ENOENT – "No such file or directory".

The function may only be called after VirtioFsFuseInitSession() returns successfully and before VirtioFsUninit() is called.

Parameters
[in,out]VirtioFsThe Virtio Filesystem device to send the FUSE_LOOKUP request to. On output, the FUSE request counter "VirtioFs->RequestId" will have been incremented.
[in]DirNodeIdThe inode number of the directory in which Name should be resolved to an inode.
[in]NameThe single-component filename to resolve in the directory identified by DirNodeId.
[out]NodeIdThe inode number which Name has been resolved to.
[out]FuseAttrThe VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE object describing the properties of the resolved inode.
Return values
EFI_SUCCESSFilename to inode resolution successful.
EFI_NOT_FOUNDThe Virtio Filesystem device explicitly reported ENOENT – "No such file or directory".
Returns
The "errno" value mapped to an EFI_STATUS code, if the Virtio Filesystem device explicitly reported an error different from ENOENT. If said mapping resulted in EFI_NOT_FOUND, it is remapped to EFI_DEVICE_ERROR.
Error codes propagated from VirtioFsSgListsValidate(), VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit(), VirtioFsFuseCheckResponse(). EFI_NOT_FOUND is remapped to EFI_DEVICE_ERROR.

Definition at line 54 of file FuseLookup.c.

◆ VirtioFsFuseMkDir()

EFI_STATUS VirtioFsFuseMkDir ( IN OUT VIRTIO_FS VirtioFs,
IN UINT64  ParentNodeId,
IN CHAR8 *  Name,
OUT UINT64 *  NodeId 
)

Send a FUSE_MKDIR request to the Virtio Filesystem device, for creating a directory.

The function may only be called after VirtioFsFuseInitSession() returns successfully and before VirtioFsUninit() is called.

Parameters
[in,out]VirtioFsThe Virtio Filesystem device to send the FUSE_MKDIR request to. On output, the FUSE request counter "VirtioFs->RequestId" will have been incremented.
[in]ParentNodeIdThe inode number of the direct parent directory of the directory to create.
[in]NameThe single-component filename of the directory to create, under the parent directory identified by ParentNodeId.
[out]NodeIdThe inode number of the new directory.
Return values
EFI_SUCCESSThe directory has been created.
Returns
The "errno" value mapped to an EFI_STATUS code, if the Virtio Filesystem device explicitly reported an error.
Error codes propagated from VirtioFsSgListsValidate(), VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit(), VirtioFsFuseCheckResponse().

Definition at line 43 of file FuseMkDir.c.

◆ VirtioFsFuseNewRequest()

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 
)

Set up the fields of a new VIRTIO_FS_FUSE_REQUEST object.

The function may only be called after VirtioFsInit() returns successfully and before VirtioFsUninit() is called.

Parameters
[in,out]VirtioFsThe Virtio Filesystem device that the request is being prepared for. The "VirtioFs->RequestId" field will be copied into "Request->Unique". On output (on successful return), "VirtioFs->RequestId" will be incremented.
[out]RequestThe VIRTIO_FS_FUSE_REQUEST object whose fields are to be set.
[in]RequestSizeThe total size of the request, including sizeof(VIRTIO_FS_FUSE_REQUEST).
[in]OpcodeThe VIRTIO_FS_FUSE_OPCODE that identifies the command to send.
[in]NodeIdThe inode number of the file that the request refers to. When Opcode is VirtioFsFuseOpInit, NodeId is ignored by the Virtio Filesystem device.
Return values
EFI_INVALID_PARAMETERRequestSize is smaller than sizeof(VIRTIO_FS_FUSE_REQUEST).
EFI_OUT_OF_RESOURCES"VirtioFs->RequestId" is MAX_UINT64, and can be incremented no more.
EFI_SUCCESSRequest has been populated, "VirtioFs->RequestId" has been incremented.

Definition at line 790 of file Helpers.c.

◆ VirtioFsFuseOpen()

EFI_STATUS VirtioFsFuseOpen ( IN OUT VIRTIO_FS VirtioFs,
IN UINT64  NodeId,
IN BOOLEAN  ReadWrite,
OUT UINT64 *  FuseHandle 
)

Send a FUSE_OPEN request to the Virtio Filesystem device, for opening a regular file.

The function may only be called after VirtioFsFuseInitSession() returns successfully and before VirtioFsUninit() is called.

Parameters
[in,out]VirtioFsThe Virtio Filesystem device to send the FUSE_OPEN request to. On output, the FUSE request counter "VirtioFs->RequestId" will have been incremented.
[in]NodeIdThe inode number of the regular file to open.
[in]ReadWriteIf TRUE, open the regular file in read-write mode. If FALSE, open the regular file in read-only mode.
[out]FuseHandleThe open handle to the regular file, returned by the Virtio Filesystem device.
Return values
EFI_SUCCESSThe regular file has been opened.
Returns
The "errno" value mapped to an EFI_STATUS code, if the Virtio Filesystem device explicitly reported an error.
Error codes propagated from VirtioFsSgListsValidate(), VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit(), VirtioFsFuseCheckResponse().

Definition at line 40 of file FuseOpen.c.

◆ VirtioFsFuseOpenDir()

EFI_STATUS VirtioFsFuseOpenDir ( IN OUT VIRTIO_FS VirtioFs,
IN UINT64  NodeId,
OUT UINT64 *  FuseHandle 
)

Send a FUSE_OPENDIR request to the Virtio Filesystem device, for opening a directory.

The function may only be called after VirtioFsFuseInitSession() returns successfully and before VirtioFsUninit() is called.

Parameters
[in,out]VirtioFsThe Virtio Filesystem device to send the FUSE_OPENDIR request to. On output, the FUSE request counter "VirtioFs->RequestId" will have been incremented.
[in]NodeIdThe inode number of the directory to open.
[out]FuseHandleThe open file handle returned by the Virtio Filesystem device.
Return values
EFI_SUCCESSThe directory has been opened.
Returns
The "errno" value mapped to an EFI_STATUS code, if the Virtio Filesystem device explicitly reported an error.
Error codes propagated from VirtioFsSgListsValidate(), VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit(), VirtioFsFuseCheckResponse().

Definition at line 38 of file FuseOpenDir.c.

◆ VirtioFsFuseOpenOrCreate()

EFI_STATUS VirtioFsFuseOpenOrCreate ( IN OUT VIRTIO_FS VirtioFs,
IN UINT64  ParentNodeId,
IN CHAR8 *  Name,
OUT UINT64 *  NodeId,
OUT UINT64 *  FuseHandle 
)

Send a FUSE_CREATE request to the Virtio Filesystem device, for opening a regular file with (O_RDWR | O_CREAT) semantics.

The function may only be called after VirtioFsFuseInitSession() returns successfully and before VirtioFsUninit() is called.

Parameters
[in,out]VirtioFsThe Virtio Filesystem device to send the FUSE_CREATE request to. On output, the FUSE request counter "VirtioFs->RequestId" will have been incremented.
[in]ParentNodeIdThe inode number of the direct parent directory of the regular file to open or create.
[in]NameThe single-component filename of the regular file to open or create, under the parent directory identified by ParentNodeId.
[out]NodeIdThe inode number of the regular file, returned by the Virtio Filesystem device.
[out]FuseHandleThe open file handle returned by the Virtio Filesystem device.
Return values
EFI_SUCCESSThe regular file has been opened, and (if necessary) created.
Returns
The "errno" value mapped to an EFI_STATUS code, if the Virtio Filesystem device explicitly reported an error.
Error codes propagated from VirtioFsSgListsValidate(), VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit(), VirtioFsFuseCheckResponse().

Definition at line 48 of file FuseOpenOrCreate.c.

◆ VirtioFsFuseReadFileOrDir()

EFI_STATUS VirtioFsFuseReadFileOrDir ( IN OUT VIRTIO_FS VirtioFs,
IN UINT64  NodeId,
IN UINT64  FuseHandle,
IN BOOLEAN  IsDir,
IN UINT64  Offset,
IN OUT UINT32 *  Size,
OUT VOID *  Data 
)

Read a chunk from a regular file or a directory stream, by sending the FUSE_READ / FUSE_READDIRPLUS request to the Virtio Filesystem device.

The function may only be called after VirtioFsFuseInitSession() returns successfully and before VirtioFsUninit() is called.

Parameters
[in,out]VirtioFsThe Virtio Filesystem device to send the FUSE_READ or FUSE_READDIRPLUS request to. On output, the FUSE request counter "VirtioFs->RequestId" will have been incremented.
[in]NodeIdThe inode number of the regular file or directory stream to read from.
[in]FuseHandleThe open handle to the regular file or directory stream to read from.
[in]IsDirTRUE if NodeId and FuseHandle refer to a directory, FALSE if NodeId and FuseHandle refer to a regular file.
[in]OffsetIf IsDir is FALSE: the absolute file position at which to start reading.

If IsDir is TRUE: the directory stream cookie at which to start or continue reading. The zero-valued cookie identifies the start of the directory stream. Further positions in the directory stream can be passed in from the CookieForNextEntry field of VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE.

Parameters
[in,out]SizeOn input, the number of bytes to read. On successful return, the number of bytes actually read, which may be smaller than the value on input.

When reading a regular file (i.e., when IsDir is FALSE), EOF can be detected by passing in a nonzero Size, and finding a zero Size on output.

When reading a directory stream (i.e., when IsDir is TRUE), Data consists of a sequence of variably-sized records (directory entries). A read operation returns the maximal sequence of records that fits in Size, without having to truncate a record. In order to guarantee progress, call

VirtioFsFuseStatFs (VirtioFs, NodeId, &FilesysAttr)

first, to learn the maximum Namelen for the directory stream. Then assign Size at least

VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE_SIZE ( FilesysAttr.Namelen)

on input. (Remember that VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE_SIZE() may return 0 if its Namelen argument is invalid.) EOF can be detected if Size is set on input like described above, and Size is zero on output.

Parameters
[out]DataBuffer to read the bytes from the regular file or the directory stream into. The caller is responsible for providing room for (at least) as many bytes in Data as Size is on input.
Return values
EFI_SUCCESSRead successful. The caller is responsible for checking Size to learn the actual byte count transferred.
Returns
The "errno" value mapped to an EFI_STATUS code, if the Virtio Filesystem device explicitly reported an error.
Error codes propagated from VirtioFsSgListsValidate(), VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit(), VirtioFsFuseCheckResponse().

Definition at line 89 of file FuseRead.c.

◆ VirtioFsFuseReleaseFileOrDir()

EFI_STATUS VirtioFsFuseReleaseFileOrDir ( IN OUT VIRTIO_FS VirtioFs,
IN UINT64  NodeId,
IN UINT64  FuseHandle,
IN BOOLEAN  IsDir 
)

Close a regular file or a directory that is open, by sending the FUSE_RELEASE or FUSE_RELEASEDIR request to the Virtio Filesystem device.

The function may only be called after VirtioFsFuseInitSession() returns successfully and before VirtioFsUninit() is called.

Parameters
[in,out]VirtioFsThe Virtio Filesystem device to send the FUSE_RELEASE / FUSE_RELEASEDIR request to. On output, the FUSE request counter "VirtioFs->RequestId" will have been incremented.
[in]NodeIdThe inode number of the file or directory to close.
[in]FuseHandleThe open handle to the file or directory to close.
[in]IsDirTRUE if NodeId and FuseHandle refer to a directory, FALSE if NodeId and FuseHandle refer to a regular file.
Return values
EFI_SUCCESSThe file or directory has been closed.
Returns
The "errno" value mapped to an EFI_STATUS code, if the Virtio Filesystem device explicitly reported an error.
Error codes propagated from VirtioFsSgListsValidate(), VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit(), VirtioFsFuseCheckResponse().

Definition at line 41 of file FuseRelease.c.

◆ VirtioFsFuseRemoveFileOrDir()

EFI_STATUS VirtioFsFuseRemoveFileOrDir ( IN OUT VIRTIO_FS VirtioFs,
IN UINT64  ParentNodeId,
IN CHAR8 *  Name,
IN BOOLEAN  IsDir 
)

Remove a regular file or a directory, by sending the FUSE_UNLINK or FUSE_RMDIR request to the Virtio Filesystem device.

The function may only be called after VirtioFsFuseInitSession() returns successfully and before VirtioFsUninit() is called.

Parameters
[in,out]VirtioFsThe Virtio Filesystem device to send the FUSE_UNLINK / FUSE_RMDIR request to. On output, the FUSE request counter "VirtioFs->RequestId" will have been incremented.
[in]ParentNodeIdThe inode number of the directory in which Name should be removed.
[in]NameThe single-component filename to remove in the directory identified by ParentNodeId.
[in]IsDirTRUE if Name refers to a directory, FALSE otherwise.
Return values
EFI_SUCCESSThe file or directory has been removed.
Returns
The "errno" value mapped to an EFI_STATUS code, if the Virtio Filesystem device explicitly reported an error.
Error codes propagated from VirtioFsSgListsValidate(), VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit(), VirtioFsFuseCheckResponse().

Definition at line 43 of file FuseUnlink.c.

◆ VirtioFsFuseRename()

EFI_STATUS VirtioFsFuseRename ( IN OUT VIRTIO_FS VirtioFs,
IN UINT64  OldParentNodeId,
IN CHAR8 *  OldName,
IN UINT64  NewParentNodeId,
IN CHAR8 *  NewName 
)

Rename a regular file or a directory, by sending the FUSE_RENAME2 request to the Virtio Filesystem device. If the new filename exists, the request will fail.

The function may only be called after VirtioFsFuseInitSession() returns successfully and before VirtioFsUninit() is called.

Parameters
[in,out]VirtioFsThe Virtio Filesystem device to send the FUSE_RENAME2 request to. On output, the FUSE request counter "VirtioFs->RequestId" will have been incremented.
[in]OldParentNodeIdThe inode number of the directory in which OldName should be removed.
[in]OldNameThe single-component filename to remove in the directory identified by OldParentNodeId.
[in]NewParentNodeIdThe inode number of the directory in which NewName should be created, such that on successful return, (NewParentNodeId, NewName) refer to the same inode as (OldParentNodeId, OldName) did on entry.
[in]NewNameThe single-component filename to create in the directory identified by NewParentNodeId.
Return values
EFI_SUCCESSThe file or directory has been renamed.
Returns
The "errno" value mapped to an EFI_STATUS code, if the Virtio Filesystem device explicitly reported an error.
Error codes propagated from VirtioFsSgListsValidate(), VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit(), VirtioFsFuseCheckResponse().

Definition at line 51 of file FuseRename.c.

◆ VirtioFsFuseSetAttr()

EFI_STATUS VirtioFsFuseSetAttr ( IN OUT VIRTIO_FS VirtioFs,
IN UINT64  NodeId,
IN UINT64 *Size  OPTIONAL,
IN UINT64 *Atime  OPTIONAL,
IN UINT64 *Mtime  OPTIONAL,
IN UINT32 *Mode  OPTIONAL 
)

Send the FUSE_SETATTR request to the Virtio Filesystem device, for changing the attributes of an inode.

The function may only be called after VirtioFsFuseInitSession() returns successfully and before VirtioFsUninit() is called.

Parameters
[in,out]VirtioFsThe Virtio Filesystem device to send the FUSE_SETATTR request to. On output, the FUSE request counter "VirtioFs->RequestId" will have been incremented.
[in]NodeIdThe inode number representing the regular file or directory whose attributes should be changed.
[in]SizeThe new size to set for the regular file. If NULL, then the file size will not be changed. If NodeId refers to a directory, then the caller is responsible for passing NULL as Size.
[in]AtimeThe new last access time to set for the regular file or directory (seconds since the Epoch). If NULL, then the last access time is not changed.
[in]MtimeThe new last modification time to set for the regular file or directory (seconds since the Epoch). If NULL, then the last modification time is not changed.
[in]ModeThe new file mode bits to set for the regular file or directory. If NULL, then the file mode bits are not changed.
Return values
EFI_SUCCESSThe attributes have been updated.
Returns
The "errno" value mapped to an EFI_STATUS code, if the Virtio Filesystem device explicitly reported an error.
Error codes propagated from VirtioFsSgListsValidate(), VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit(), VirtioFsFuseCheckResponse().

Definition at line 54 of file FuseSetAttr.c.

◆ VirtioFsFuseStatFs()

EFI_STATUS VirtioFsFuseStatFs ( IN OUT VIRTIO_FS VirtioFs,
IN UINT64  NodeId,
OUT VIRTIO_FS_FUSE_STATFS_RESPONSE FilesysAttr 
)

Send the FUSE_STATFS request to the Virtio Filesysem device, for retrieving the attributes of the host-side filesystem that contains NodeId.

The function may only be called after VirtioFsFuseInitSession() returns successfully and before VirtioFsUninit() is called.

Parameters
[in,out]VirtioFsThe Virtio Filesystem device to send the FUSE_STATFS request to. On output, the FUSE request counter "VirtioFs->RequestId" will have been incremented.
[in]NodeIdThe inode whose containing filesystem is to be queried for its attributes.
[out]FilesysAttrThe VIRTIO_FS_FUSE_STATFS_RESPONSE object describing the filesystem that underlies NodeId.
Return values
EFI_SUCCESSFilesysAttr has been filled in.
Returns
The "errno" value mapped to an EFI_STATUS code, if the Virtio Filesystem device explicitly reported an error.
Error codes propagated from VirtioFsSgListsValidate(), VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit(), VirtioFsFuseCheckResponse().

Definition at line 38 of file FuseStatFs.c.

◆ VirtioFsFuseWrite()

EFI_STATUS VirtioFsFuseWrite ( IN OUT VIRTIO_FS VirtioFs,
IN UINT64  NodeId,
IN UINT64  FuseHandle,
IN UINT64  Offset,
IN OUT UINT32 *  Size,
IN VOID *  Data 
)

Write a chunk to a regular file, by sending the FUSE_WRITE request to the Virtio Filesystem device.

The function may only be called after VirtioFsFuseInitSession() returns successfully and before VirtioFsUninit() is called.

Parameters
[in,out]VirtioFsThe Virtio Filesystem device to send the FUSE_WRITE request to. On output, the FUSE request counter "VirtioFs->RequestId" will have been incremented.
[in]NodeIdThe inode number of the regular file to write to.
[in]FuseHandleThe open handle to the regular file to write to.
[in]OffsetThe absolute file position at which to start writing.
[in,out]SizeOn input, the number of bytes to write. On successful return, the number of bytes actually written, which may be smaller than the value on input.
[in]DataThe buffer to write to the regular file.
Return values
EFI_SUCCESSWrite successful. The caller is responsible for checking Size to learn the actual byte count transferred.
EFI_BAD_BUFFER_SIZEOn input, Size is larger than "VirtioFs->MaxWrite".
Returns
The "errno" value mapped to an EFI_STATUS code, if the Virtio Filesystem device explicitly reported an error.
Error codes propagated from VirtioFsSgListsValidate(), VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit(), VirtioFsFuseCheckResponse().

Definition at line 54 of file FuseWrite.c.

◆ VirtioFsGetBasename()

EFI_STATUS VirtioFsGetBasename ( IN CHAR8 *  Path,
OUT CHAR16 *Basename  OPTIONAL,
IN OUT UINTN BasenameSize 
)

Format the last component of a canonical pathname into a caller-provided CHAR16 array.

Parameters
[in]PathThe canonical pathname (as defined in the description of VirtioFsAppendPath()) to format the last component of.
[out]BasenameIf BasenameSize is zero on input, Basename may be NULL. Otherwise, Basename is allocated by the caller. On successful return, Basename contains the last component of Path, formatted as a NUL-terminated CHAR16 string. When Path is "/" on input, Basename is L"" on output.
[in,out]BasenameSizeOn input, the number of bytes the caller provides in Basename. On output, regardless of return value, the number of bytes required for formatting Basename, including the terminating L'\0'.
Return values
EFI_SUCCESSBasename has been filled in.
EFI_BUFFER_TOO_SMALLBasenameSize was too small on input; Basename has not been modified.

Definition at line 1823 of file Helpers.c.

◆ VirtioFsGetFuseModeUpdate()

EFI_STATUS VirtioFsGetFuseModeUpdate ( IN EFI_FILE_INFO Info,
IN EFI_FILE_INFO NewInfo,
OUT BOOLEAN *  Update,
OUT UINT32 *  Mode 
)

Given an EFI_FILE_INFO object received in an EFI_FILE_PROTOCOL.SetInfo() call, determine whether updating the file mode bits of the file is necessary, relative to an EFI_FILE_INFO object describing the current state of the file.

Parameters
[in]InfoThe EFI_FILE_INFO describing the current state of the file. The caller is responsible for populating Info on input with VirtioFsFuseAttrToEfiFileInfo(), from the current FUSE attributes of the file. The Info->Size and Info->FileName members are ignored.
[in]NewInfoThe EFI_FILE_INFO object received in the EFI_FILE_PROTOCOL.SetInfo() call.
[out]UpdateSet to TRUE on output if the file mode bits need to be updated. Set to FALSE otherwise.
[out]ModeIf Update is set to TRUE, then Mode provides the file mode bits to set. Otherwise, Mode is not written to.
Return values
EFI_SUCCESSOutput parameters have been set successfully.
EFI_ACCESS_DENIEDNewInfo requests toggling an unknown bit in the Attribute bitmask.
EFI_ACCESS_DENIEDNewInfo requests toggling EFI_FILE_DIRECTORY in the Attribute bitmask.

Definition at line 2459 of file Helpers.c.

◆ VirtioFsGetFuseSizeUpdate()

VOID VirtioFsGetFuseSizeUpdate ( IN EFI_FILE_INFO Info,
IN EFI_FILE_INFO NewInfo,
OUT BOOLEAN *  Update,
OUT UINT64 *  Size 
)

Given an EFI_FILE_INFO object received in an EFI_FILE_PROTOCOL.SetInfo() call, determine whether updating the size of the file is necessary, relative to an EFI_FILE_INFO object describing the current state of the file.

Parameters
[in]InfoThe EFI_FILE_INFO describing the current state of the file. The caller is responsible for populating Info on input with VirtioFsFuseAttrToEfiFileInfo(), from the current FUSE attributes of the file. The Info->Size and Info->FileName members are ignored.
[in]NewInfoThe EFI_FILE_INFO object received in the EFI_FILE_PROTOCOL.SetInfo() call.
[out]UpdateSet to TRUE on output if the file size needs to be updated. Set to FALSE otherwise.
[out]SizeIf Update is set to TRUE, then Size provides the new file size to set. Otherwise, Size is not written to.

Definition at line 2290 of file Helpers.c.

◆ VirtioFsGetFuseTimeUpdates()

EFI_STATUS VirtioFsGetFuseTimeUpdates ( IN EFI_FILE_INFO Info,
IN EFI_FILE_INFO NewInfo,
OUT BOOLEAN *  UpdateAtime,
OUT BOOLEAN *  UpdateMtime,
OUT UINT64 *  Atime,
OUT UINT64 *  Mtime 
)

Given an EFI_FILE_INFO object received in an EFI_FILE_PROTOCOL.SetInfo() call, determine whether updating the last access time and/or the last modification time of the file is necessary, relative to an EFI_FILE_INFO object describing the current state of the file.

Parameters
[in]InfoThe EFI_FILE_INFO describing the current state of the file. The caller is responsible for populating Info on input with VirtioFsFuseAttrToEfiFileInfo(), from the current FUSE attributes of the file. The Info->Size and Info->FileName members are ignored.
[in]NewInfoThe EFI_FILE_INFO object received in the EFI_FILE_PROTOCOL.SetInfo() call.
[out]UpdateAtimeSet to TRUE on output if the last access time needs to be updated. Set to FALSE otherwise.
[out]UpdateMtimeSet to TRUE on output if the last modification time needs to be updated. Set to FALSE otherwise.
[out]AtimeIf UpdateAtime is set to TRUE, then Atime provides the last access timestamp to set (as seconds since the Epoch). Otherwise, Atime is not written to.
[out]MtimeIf UpdateMtime is set to TRUE, then Mtime provides the last modification timestamp to set (as seconds since the Epoch). Otherwise, Mtime is not written to.
Return values
EFI_SUCCESSOutput parameters have been set successfully.
EFI_INVALID_PARAMETERAt least one of the CreateTime, LastAccessTime and ModificationTime fields in NewInfo represents an actual update relative to the current state of the file (expressed in Info), but does not satisfy the UEFI spec requirements on EFI_TIME.
EFI_ACCESS_DENIEDNewInfo requests changing both CreateTime and ModificationTime, but to values that differ from each other. The Virtio Filesystem device does not support this.

Definition at line 2355 of file Helpers.c.

◆ VirtioFsInit()

EFI_STATUS VirtioFsInit ( IN OUT VIRTIO_FS VirtioFs)

Configure the Virtio Filesystem device underlying VirtioFs.

Parameters
[in,out]VirtioFsThe VIRTIO_FS object for which Virtio communication should be set up. On input, the caller is responsible for VirtioFs->Virtio having been initialized. On output, synchronous Virtio Filesystem commands (primitives) may be submitted to the device.
Return values
EFI_SUCCESSVirtio machinery has been set up.
EFI_UNSUPPORTEDThe host-side configuration of the Virtio Filesystem is not supported by this driver.
Returns
Error codes from underlying functions.

Definition at line 80 of file Helpers.c.

◆ VirtioFsLookupMostSpecificParentDir()

EFI_STATUS VirtioFsLookupMostSpecificParentDir ( IN OUT VIRTIO_FS VirtioFs,
IN OUT CHAR8 *  Path,
OUT UINT64 *  DirNodeId,
OUT CHAR8 **  LastComponent 
)

For a given canonical pathname (as defined at VirtioFsAppendPath()), look up the NodeId of the most specific parent directory, plus output a pointer to the last pathname component (which is therefore a direct child of said parent directory).

The function may only be called after VirtioFsFuseInitSession() returns successfully and before VirtioFsUninit() is called.

Parameters
[in,out]VirtioFsThe Virtio Filesystem device to send FUSE_LOOKUP and FUSE_FORGET requests to. On output, the FUSE request counter "VirtioFs->RequestId" will have been incremented several times.
[in,out]PathThe canonical pathname (as defined in the description of VirtioFsAppendPath()) to split. Path is modified in-place temporarily; however, on return (successful or otherwise), Path reassumes its original contents.
[out]DirNodeIdThe NodeId of the most specific parent directory identified by Path. The caller is responsible for sending a FUSE_FORGET request to the Virtio Filesystem device for DirNodeId – unless DirNodeId equals VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID –, when DirNodeId's use ends.
[out]LastComponentA pointer into Path, pointing at the start of the last pathname component.
Return values
EFI_SUCCESSSplitting successful.
EFI_INVALID_PARAMETERPath is "/".
EFI_ACCESS_DENIEDOne of the components on Path before the last is not a directory.
Returns
Error codes propagated from VirtioFsFuseLookup() and VirtioFsFuseAttrToEfiFileInfo().

Definition at line 1701 of file Helpers.c.

◆ VirtioFsOpenVolume()

EFI_STATUS EFIAPI VirtioFsOpenVolume ( IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL This,
OUT EFI_FILE_PROTOCOL **  Root 
)

Open the root directory on the Virtio Filesystem.

Refer to EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME for the interface contract.

Definition at line 23 of file SimpleFsOpenVolume.c.

◆ VirtioFsSgListsSubmit()

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 
)

Submit a validated pair of (request buffer list, response buffer list) to the Virtio Filesystem device.

On input, the pair of VIRTIO_FS_SCATTER_GATHER_LIST objects must have been validated together, using the VirtioFsSgListsValidate() function.

On output (on successful return), the following fields will be re-initialized to zero (after temporarily setting them to different values):

  • VIRTIO_FS_IO_VECTOR.Mapped,
  • VIRTIO_FS_IO_VECTOR.MappedAddress,
  • VIRTIO_FS_IO_VECTOR.Mapping.

On output (on successful return), the following fields will be calculated:

  • VIRTIO_FS_IO_VECTOR.Transferred.

The function may only be called after VirtioFsInit() returns successfully and before VirtioFsUninit() is called.

Parameters
[in,out]VirtioFsThe Virtio Filesystem device that the request-response exchange, expressed via RequestSgList and ResponseSgList, should now be submitted to.
[in,out]RequestSgListThe scatter-gather list that describes the request part of the exchange – the buffers that should be sent to the Virtio Filesystem device in the virtio transfer.
[in,out]ResponseSgListThe scatter-gather list that describes the response part of the exchange – the buffers that the Virtio Filesystem device should populate in the virtio transfer. May be NULL if and only if NULL was passed to VirtioFsSgListsValidate() as ResponseSgList.
Return values
EFI_SUCCESSTransfer complete. The caller should investigate the VIRTIO_FS_IO_VECTOR.Transferred fields in ResponseSgList, to ensure coverage of the relevant response buffers. Subsequently, the caller should investigate the contents of those buffers.
EFI_DEVICE_ERRORThe Virtio Filesystem device reported populating more response bytes than ResponseSgList->TotalSize.
Returns
Error codes propagated from VirtioMapAllBytesInSharedBuffer(), VirtioFlush(), or VirtioFs->Virtio->UnmapSharedBuffer().

Definition at line 538 of file Helpers.c.

◆ VirtioFsSgListsValidate()

EFI_STATUS VirtioFsSgListsValidate ( IN VIRTIO_FS VirtioFs,
IN OUT VIRTIO_FS_SCATTER_GATHER_LIST RequestSgList,
IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *ResponseSgList  OPTIONAL 
)

Validate two VIRTIO_FS_SCATTER_GATHER_LIST objects – list of request buffers, list of response buffers – together.

On input, the caller is required to populate the following fields:

  • VIRTIO_FS_IO_VECTOR.Buffer,
  • VIRTIO_FS_IO_VECTOR.Size,
  • VIRTIO_FS_SCATTER_GATHER_LIST.IoVec,
  • VIRTIO_FS_SCATTER_GATHER_LIST.NumVec.

On output (on successful return), the following fields will be zero-initialized:

  • VIRTIO_FS_IO_VECTOR.Mapped,
  • VIRTIO_FS_IO_VECTOR.MappedAddress,
  • VIRTIO_FS_IO_VECTOR.Mapping,
  • VIRTIO_FS_IO_VECTOR.Transferred.

On output (on successful return), the following fields will be calculated:

  • VIRTIO_FS_SCATTER_GATHER_LIST.TotalSize.

The function may only be called after VirtioFsInit() returns successfully and before VirtioFsUninit() is called.

Parameters
[in]VirtioFsThe Virtio Filesystem device that the request-response exchange, expressed via RequestSgList and ResponseSgList, will be submitted to.
[in,out]RequestSgListThe scatter-gather list that describes the request part of the exchange – the buffers that should be sent to the Virtio Filesystem device in the virtio transfer.
[in,out]ResponseSgListThe scatter-gather list that describes the response part of the exchange – the buffers that the Virtio Filesystem device should populate in the virtio transfer. May be NULL if the exchange with the Virtio Filesystem device consists of a request only, with the response part omitted altogether.
Return values
EFI_SUCCESSRequestSgList and ResponseSgList have been validated, output fields have been set.
EFI_INVALID_PARAMETERRequestSgList is NULL.
EFI_INVALID_PARAMETEROn input, a VIRTIO_FS_SCATTER_GATHER_LIST.IoVec field is NULL, or a VIRTIO_FS_SCATTER_GATHER_LIST.NumVec field is zero.
EFI_INVALID_PARAMETEROn input, a VIRTIO_FS_IO_VECTOR.Buffer field is NULL, or a VIRTIO_FS_IO_VECTOR.Size field is zero.
EFI_UNSUPPORTED(RequestSgList->NumVec + ResponseSgList->NumVec) exceeds VirtioFs->QueueSize, meaning that the total list of buffers cannot be placed on the virtio queue in a single descriptor chain (with one descriptor per buffer).
EFI_UNSUPPORTEDOne of the VIRTIO_FS_SCATTER_GATHER_LIST.TotalSize fields would exceed MAX_UINT32.

Definition at line 398 of file Helpers.c.

◆ VirtioFsSimpleFileClose()

EFI_STATUS EFIAPI VirtioFsSimpleFileClose ( IN EFI_FILE_PROTOCOL This)

Definition at line 16 of file SimpleFsClose.c.

◆ VirtioFsSimpleFileDelete()

EFI_STATUS EFIAPI VirtioFsSimpleFileDelete ( IN EFI_FILE_PROTOCOL This)

Definition at line 16 of file SimpleFsDelete.c.

◆ VirtioFsSimpleFileFlush()

EFI_STATUS EFIAPI VirtioFsSimpleFileFlush ( IN EFI_FILE_PROTOCOL This)

Definition at line 13 of file SimpleFsFlush.c.

◆ VirtioFsSimpleFileGetInfo()

EFI_STATUS EFIAPI VirtioFsSimpleFileGetInfo ( IN EFI_FILE_PROTOCOL This,
IN EFI_GUID InformationType,
IN OUT UINTN BufferSize,
OUT VOID *  Buffer 
)

Definition at line 204 of file SimpleFsGetInfo.c.

◆ VirtioFsSimpleFileGetPosition()

EFI_STATUS EFIAPI VirtioFsSimpleFileGetPosition ( IN EFI_FILE_PROTOCOL This,
OUT UINT64 *  Position 
)

Definition at line 14 of file SimpleFsGetPosition.c.

◆ VirtioFsSimpleFileOpen()

EFI_STATUS EFIAPI VirtioFsSimpleFileOpen ( IN EFI_FILE_PROTOCOL This,
OUT EFI_FILE_PROTOCOL **  NewHandle,
IN CHAR16 *  FileName,
IN UINT64  OpenMode,
IN UINT64  Attributes 
)

Definition at line 310 of file SimpleFsOpen.c.

◆ VirtioFsSimpleFileRead()

EFI_STATUS EFIAPI VirtioFsSimpleFileRead ( IN EFI_FILE_PROTOCOL This,
IN OUT UINTN BufferSize,
OUT VOID *  Buffer 
)

Definition at line 431 of file SimpleFsRead.c.

◆ VirtioFsSimpleFileSetInfo()

EFI_STATUS EFIAPI VirtioFsSimpleFileSetInfo ( IN EFI_FILE_PROTOCOL This,
IN EFI_GUID InformationType,
IN UINTN  BufferSize,
IN VOID *  Buffer 
)

Definition at line 621 of file SimpleFsSetInfo.c.

◆ VirtioFsSimpleFileSetPosition()

EFI_STATUS EFIAPI VirtioFsSimpleFileSetPosition ( IN EFI_FILE_PROTOCOL This,
IN UINT64  Position 
)

Definition at line 16 of file SimpleFsSetPosition.c.

◆ VirtioFsSimpleFileWrite()

EFI_STATUS EFIAPI VirtioFsSimpleFileWrite ( IN EFI_FILE_PROTOCOL This,
IN OUT UINTN BufferSize,
IN VOID *  Buffer 
)

Definition at line 13 of file SimpleFsWrite.c.

◆ VirtioFsUninit()

VOID VirtioFsUninit ( IN OUT VIRTIO_FS VirtioFs)

De-configure the Virtio Filesystem device underlying VirtioFs.

Parameters
[in]VirtioFsThe VIRTIO_FS object for which Virtio communication should be torn down. On input, the caller is responsible for having called VirtioFsInit(). On output, Virtio Filesystem commands (primitives) must no longer be submitted to the device.

Definition at line 284 of file Helpers.c.