class VmoFile

Defined at line 32 of file ../../src/storage/lib/vfs/cpp/vmo_file.h

A file node backed by a range of bytes in a VMO.

The file has a fixed size specified at creating time; it does not grow or shrink even when

written into.

This class is thread-safe.

Public Methods

fuchsia_io::NodeProtocolKinds GetProtocols ()

|Vnode| implementation:

Defined at line 37 of file ../../src/storage/lib/vfs/cpp/vmo_file.cc

bool ValidateRights (fuchsia_io::Rights rights)

Defined at line 41 of file ../../src/storage/lib/vfs/cpp/vmo_file.cc

zx::result<fs::VnodeAttributes> GetAttributes ()

Defined at line 54 of file ../../src/storage/lib/vfs/cpp/vmo_file.cc

zx_status_t Read (void * data, size_t length, size_t offset, size_t * out_actual)

Defined at line 61 of file ../../src/storage/lib/vfs/cpp/vmo_file.cc

const zx::vmo & vmo ()

The underlying VMO handle.

Defined at line 70 of file ../../src/storage/lib/vfs/cpp/vmo_file.h

size_t length ()

The length of the file in bytes.

Defined at line 73 of file ../../src/storage/lib/vfs/cpp/vmo_file.h

bool is_writable ()

True if the file is writable.

If false, attempts to open the file for write will fail.

Defined at line 77 of file ../../src/storage/lib/vfs/cpp/vmo_file.h

zx_status_t Write (const void * data, size_t length, size_t offset, size_t * out_actual)

Defined at line 77 of file ../../src/storage/lib/vfs/cpp/vmo_file.cc

zx_status_t GetVmo (fuchsia_io::wire::VmoFlags flags, zx::vmo * out_vmo)

Defined at line 95 of file ../../src/storage/lib/vfs/cpp/vmo_file.cc

Protected Methods

void VmoFile (zx::vmo vmo, size_t length, bool writable, DefaultSharingMode vmo_sharing)

Creates a file node backed by a VMO.

Defined at line 30 of file ../../src/storage/lib/vfs/cpp/vmo_file.cc

void ~VmoFile ()

Defined at line 35 of file ../../src/storage/lib/vfs/cpp/vmo_file.cc

Enumerations

enum class DefaultSharingMode : uint8_t
Name Value Comments
kNone 0

NOT_SUPPORTED will be returned, unless a sharing mode is specified in the request.

kDuplicate 1

The VMO handle is duplicated for each client.

This is appropriate when it is okay for clients to access the entire
contents of the VMO, possibly extending beyond the pages spanned by the
file.

This mode is significantly more efficient than |CLONE_COW| and should be
preferred when file spans the whole VMO or when the VMO's entire content
is safe for clients to read.

As size changes are currently untracked, all handles given out in this
mode will lack ZX_RIGHT_WRITE and ZX_RIGHT_SET_PROPERTY.

kCloneCow 2

The VMO range spanned by the file is cloned on demand, using
copy-on-write semantics to isolate modifications of clients which open
the file in a writable mode.

This is appropriate when clients need to be restricted from accessing
portions of the VMO outside of the range of the file and when file
modifications by clients should not be visible to each other.

Specifies the default behavior when a client asks for the file's underlying VMO, but does not

specify if a duplicate handle or copy-on-write clone is required.

*NOTE*: This does not affect the behavior of requests that specify the required sharing mode,

those requests will still be fulfilled.

Defined at line 41 of file ../../src/storage/lib/vfs/cpp/vmo_file.h

Friends

class RefPtr
class MakeRefCountedHelper