class VmoFile
Defined at line 24 of file ../../sdk/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
void VmoFile (zx::vmovmo,size_tlength,WriteModewrite_option,DefaultSharingModevmo_sharing)
Creates a file node backed by a VMO.
Defined at line 65 of file ../../sdk/lib/vfs/cpp/vmo_file.h
zx_status_t Serve (fuchsia_io::Flagsflags,fidl::ServerEnd<fuchsia_io::File>server_end,async_dispatcher_t *dispatcher)
Serve a new connection to this VMO-file on `server_end` using specified `flags`.
This method must only be used with a single-threaded asynchronous dispatcher. If `dispatcher`
is `nullptr`, the current thread's default dispatcher will be used via
`async_get_default_dispatcher`. The same `dispatcher` must be used if multiple connections are
served for the same node, otherwise `ZX_ERR_INVALID_ARGS` will be returned.
Defined at line 75 of file ../../sdk/lib/vfs/cpp/vmo_file.h
zx::unowned_vmo vmo ()
Returns a borrowed handle to the VMO backing this file.
Defined at line 85 of file ../../sdk/lib/vfs/cpp/vmo_file.h
Enumerations
enum class WriteMode : vfs_internal_write_mode_t
| Name | Value | Comments |
|---|---|---|
| kReadOnly | VFS_INTERNAL_WRITE_MODE_READ_ONLY |
The VmoFile is read only. |
| kWritable | VFS_INTERNAL_WRITE_MODE_WRITABLE |
The VmoFile will be writable. |
Specifies the desired behavior of writes.
Defined at line 27 of file ../../sdk/lib/vfs/cpp/vmo_file.h
enum class DefaultSharingMode : vfs_internal_sharing_mode_t
| Name | Value | Comments |
|---|---|---|
| kNone | VFS_INTERNAL_SHARING_MODE_NONE |
Will return `ZX_ERR_NOT_SUPPORTED` if a sharing mode was not specified in the request. |
| kDuplicate | VFS_INTERNAL_SHARING_MODE_DUPLICATE |
The VMO handle is duplicated for each client.
This is appropriate when it is okay for clients to access the entire
This mode is significantly more efficient than |CLONE_COW| and should be |
| kCloneCow | VFS_INTERNAL_SHARING_MODE_COW |
The VMO range spanned by the file is cloned on demand, using
This is appropriate when clients need to be restricted from accessing |
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.
Requests for a specific sharing mode will be fulfilled as requested.
Defined at line 39 of file ../../sdk/lib/vfs/cpp/vmo_file.h