TianoCore EDK2 master
Loading...
Searching...
No Matches
FuseRead.c File Reference
#include "VirtioFsDxe.h"

Go to the source code of this file.

Functions

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)
 

Detailed Description

FUSE_READ / FUSE_READDIRPLUS wrapper for the Virtio Filesystem device.

Copyright (C) 2020, Red Hat, Inc.

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

Definition in file FuseRead.c.

Function Documentation

◆ 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.