|
STATIC EFI_STATUS | VirtioFsReadConfig (IN VIRTIO_DEVICE_PROTOCOL *Virtio, OUT VIRTIO_FS_CONFIG *Config) |
|
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) |
|
STATIC VOID | ParserStripSlash (IN CHAR8 *Buffer, IN OUT UINTN *Position) |
|
STATIC VOID | ParserCopy (OUT CHAR8 *Buffer, IN OUT UINTN *Position, IN UINTN Size, IN CHAR8 Char8) |
|
STATIC VOID | ParserRewindDot (IN CHAR8 *Buffer, IN OUT UINTN *Position) |
|
STATIC VOID | ParserRewindDotDot (IN CHAR8 *Buffer, IN OUT UINTN *Position, OUT BOOLEAN *RootEscape) |
|
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) |
|
Initialization and helper routines for the Virtio Filesystem device.
Copyright (C) 2020, Red Hat, Inc.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file Helpers.c.
Rewind the last dot-dot in the parser's output buffer.
- Parameters
-
[in] | Buffer | The parser's output buffer. Only used for sanity-checking. |
[in,out] | Position | On entry, points at the next character to produce (i.e., right past the end of the output written by the parser thus far); the parser's output buffer ends with the characters ('/', '.', '.'). On return, the ('.', '.') pair is rewound unconditionally, by decrementing Position by two; a slash character resides at the new end of the parser's output buffer. |
If this slash character stands for the root directory, then RootEscape is set to TRUE.
Otherwise (i.e., if this slash character is not the one standing for the root directory), then the slash character, and the pathname component preceding it, are removed by decrementing Position further. In this case, the slash character preceding the removed pathname component will reside at the new end of the parser's output buffer.
- Parameters
-
[out] | RootEscape | Set to TRUE on output if the dot-dot component tries to escape the root directory, as described above. Otherwise, RootEscape is not modified. |
Definition at line 1308 of file Helpers.c.
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] | LhsPath8 | Identifies the base directory. The caller is responsible for ensuring that LhsPath8 conform to the above canonical pathname format on entry. |
[in] | RhsPath16 | Identifies 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] | ResultPath8 | The POSIX-style, canonical format pathname that leads to the file desired by the caller. After use, the caller is responsible for freeing ResultPath8. |
[out] | RootEscape | Set to TRUE if at least one dot-dot component in RhsPath16 attempted to escape the root directory; set to FALSE otherwise. |
- Return values
-
EFI_SUCCESS | ResultPath8 has been produced. RootEscape has been output. |
EFI_INVALID_PARAMETER | RhsPath16 is zero-length. |
EFI_INVALID_PARAMETER | RhsPath16 failed the VIRTIO_FS_MAX_PATHNAME_LENGTH check. |
EFI_OUT_OF_RESOURCES | Memory allocation failed. |
EFI_OUT_OF_RESOURCES | ResultPath8 would have failed the VIRTIO_FS_MAX_PATHNAME_LENGTH check. |
EFI_UNSUPPORTED | RhsPath16 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.
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] | LhsPath8 | The 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] | RhsPath16 | The 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] | ResultPath8 | The POSIX-style, canonical format pathname that leads to the renamed/moved file. After use, the caller is responsible for freeing ResultPath8. |
[out] | RootEscape | Set to TRUE if at least one dot-dot component in RhsPath16 attempted to escape the root directory; set to FALSE otherwise. |
- Return values
-
EFI_SUCCESS | ResultPath8 has been produced. RootEscape has been output. |
EFI_INVALID_PARAMETER | LhsPath8 is "/". |
EFI_INVALID_PARAMETER | RhsPath16 is zero-length. |
EFI_INVALID_PARAMETER | RhsPath16 failed the VIRTIO_FS_MAX_PATHNAME_LENGTH check. |
EFI_OUT_OF_RESOURCES | Memory allocation failed. |
EFI_OUT_OF_RESOURCES | ResultPath8 would have failed the VIRTIO_FS_MAX_PATHNAME_LENGTH check. |
EFI_UNSUPPORTED | RhsPath16 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.
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] | ResponseSgList | The 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] | RequestId | The request identifier to which the response is expected to belong. |
[out] | TailBufferFill | If 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_PARAMETER | TailBufferFill is not NULL (i.e., the last buffer is considered variable size), and ResponseSgList->NumVec is 1. |
EFI_INVALID_PARAMETER | The allocated size of the first buffer does not match sizeof(VIRTIO_FS_FUSE_RESPONSE). |
EFI_PROTOCOL_ERROR | The 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_SUCCESS | Verification successful. |
Definition at line 873 of file Helpers.c.
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] | VirtioFs | The Virtio Filesystem device that the request-response exchange, expressed via RequestSgList and ResponseSgList, should now be submitted to. |
[in,out] | RequestSgList | The 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] | ResponseSgList | The 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_SUCCESS | Transfer 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_ERROR | The 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.
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] | VirtioFs | The Virtio Filesystem device that the request-response exchange, expressed via RequestSgList and ResponseSgList, will be submitted to. |
[in,out] | RequestSgList | The 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] | ResponseSgList | The 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_SUCCESS | RequestSgList and ResponseSgList have been validated, output fields have been set. |
EFI_INVALID_PARAMETER | RequestSgList is NULL. |
EFI_INVALID_PARAMETER | On input, a VIRTIO_FS_SCATTER_GATHER_LIST.IoVec field is NULL, or a VIRTIO_FS_SCATTER_GATHER_LIST.NumVec field is zero. |
EFI_INVALID_PARAMETER | On 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_UNSUPPORTED | One of the VIRTIO_FS_SCATTER_GATHER_LIST.TotalSize fields would exceed MAX_UINT32. |
Definition at line 398 of file Helpers.c.