Google is committed to advancing racial equity for Black communities. See how.

fuchsia.io.admin

PROTOCOLS

DirectoryAdmin

Defined in fuchsia.io.admin/directory_admin.fidl

DirectoryAdmin defines a directory which is capable of handling administrator tasks within the filesystem.

AddInotifyFilter

Adds a new inotify filter for an object relative to this directory object.

  • 'filter` is a mask of different inotify events that need to be watched by the server for a specific file/directory.

  • path may contain multiple segments, separated by "/" characters, and should never be empty; i.e., "" is an invalid path. Paths should not contain a leading "/".

+watch_descriptor is client assigned value to identify a filter. Server shouldn't trust the client-assigned watch_descriptor. They should just send it back to the client in the socket. This value is not used by server, but it is returned back as part of InotifyEvent, to help the client correlate filter with events on this filter.

  • socket is shared between different filter objects i.e every new filter will have a different server end of the socket and there will be a single client end per inotify instance on inotify init.

Request

NameType
path fuchsia.io2/Path
filter fuchsia.io2/InotifyWatchMask
watch_descriptor uint32
socket handle<socket>

Response

<EMPTY>

AdvisoryLock

Acquires an advisory lock on the underlying file.

The lock lasts until either this connection is closed or this method is called with |AdvisoryLockType.UNLOCK| to release the lock explicitly.

Advisory locks are purely advisory. They do not prevent actual read or write operations from occurring on the file, either through this connection or through other connections.

This method requires the following rights:

Errors

  • ZX_ERR_BAD_STATE The specified type of lock cannot be acquired. For example, another connection might hold a conflicting lock type.
  • ZX_ERR_NOT_SUPPORTED This file does not support advisory locking.
  • ZX_ERR_ACCESS_DENIED This connection does not have sufficient rights to acquire the given type of lock.

Request

NameType
request fuchsia.io2/AdvisoryLockRequest

Response

NameType
result fuchsia.io2/AdvisoryLocking_AdvisoryLock_Result

Clone

Create another connection to the same remote object.

flags may be any of:

  • OPEN_RIGHT_*
  • OPEN_FLAG_APPEND
  • OPEN_FLAG_NO_REMOTE
  • OPEN_FLAG_DESCRIBE
  • CLONE_FLAG_SAME_RIGHTS

All other flags are ignored.

The OPEN_RIGHT_* bits in flags request corresponding rights over the resulting cloned object. The cloned object must have rights less than or equal to the original object, otherwise returns ZX_ERR_ACCESS_DENIED. Alternatively, pass CLONE_FLAG_SAME_RIGHTS to inherit the rights on the source connection. It is invalid to pass any of the OPEN_RIGHT_* flags together with CLONE_FLAG_SAME_RIGHTS.

Request

NameType
flags uint32
object request<fuchsia.io/Node>

Close

Terminates connection with object.

This method does not require any rights.

Request

<EMPTY>

Response

NameType
s zx/status

Close2

Terminates connection with object.

This method does not require any rights.

Request

<EMPTY>

Response

NameType
result fuchsia.io/Node_Close2_Result

Describe

Returns extra information about the type of the object. If the Describe operation fails, the connection is closed.

This method does not require any rights.

Request

<EMPTY>

Response

NameType
info fuchsia.io/NodeInfo

Describe2

Returns extra connection information and auxiliary handles.

  • query specifies the fields in ConnectionInfo that the caller is interested in.

When all known bits in query are set, the return value matches the one from OnConnectionInfo, as if the caller requested that event using ConnectionFlags.GET_CONNECTION_INFO.

If the Describe operation fails, the connection is closed with the associated error.

This method does not require any rights.

Request

NameType
query fuchsia.io/ConnectionInfoQuery

Response

NameType
info fuchsia.io/ConnectionInfo

GetAttr

Acquires information about the node.

This method does not require any rights.

Request

<EMPTY>

Response

NameType
s zx/status
attributes fuchsia.io/NodeAttributes

GetAttributes

Acquires information about the node.

The attributes of a node should be stable, independent of the specific protocol used to access it.

  • query a bit-mask specifying which attributes to fetch. The server should not return more than necessary.
  • attributes the returned attributes.

This method requires the Rights.GET_ATTRIBUTES right.

Request

NameType
query fuchsia.io/NodeAttributesQuery

Response

NameType
result fuchsia.io/Node_GetAttributes_Result

GetDevicePath

Acquire the path to the device backing this filesystem, if there is one.

Request

<EMPTY>

Response

NameType
s zx/status
path string[4096]?

GetToken

Acquires a token to a Directory which can be used to identify access to it at a later point in time.

This method requires following rights: OPEN_RIGHT_WRITABLE, otherwise returns ZX_ERR_BAD_HANDLE.

Request

<EMPTY>

Response

NameType
s zx/status
token handle<handle>?

IoToIo2Placeholder

This message should never be sent or received.

This declaration exists to let keep the Rust bindings compiling as we add and remove transitional elements from the fuchsia.io protocols. Without this declaration, the users of the Rust bindings fail to compile when there aren't any transitional protocol elements.

DEPRECATED

Request

<EMPTY>

Creates a link to an object named src by the name dst, within a directory represented by token.

src must be a resolved object name. Including "/" in the string will return ZX_ERR_INVALID_ARGS.

dst must be a resolved object name. Including "/" in the string will return ZX_ERR_INVALID_ARGS.

This method requires following rights: OPEN_RIGHT_WRITABLE, otherwise returns ZX_ERR_BAD_HANDLE.

NameType
src string[255]
dst_parent_token handle<handle>
dst string[255]
NameType
s zx/status

Mount

Mount a channel representing a remote filesystem onto this directory. All future requests to this node will be forwarded to the remote filesystem. To re-open a node without forwarding to the remote target, the node should be opened with OPEN_FLAG_NO_REMOTE.

Request

NameType
remote fuchsia.io/Directory

Response

NameType
s zx/status

MountAndCreate

Atomically create a directory with a provided path, and mount the remote handle to the newly created directory.

Request

NameType
remote fuchsia.io/Directory
name string[255]
flags uint32

Response

NameType
s zx/status

NodeGetFlags

Acquires the Directory.Open rights and flags used to access this file.

This method does not require any rights. This method has the same functionality as GetFlags for File and is meant as an in-progress replacement.

Request

<EMPTY>

Response

NameType
s zx/status
flags uint32

NodeSetFlags

Changes the Directory.Open flags used to access the file. Supported flags which can be turned on / off:

  • OPEN_FLAG_APPEND

This method does not require any rights. This method has the same functionality as SetFlags for File and is meant as an in-progress replacement.

Request

NameType
flags uint32

Response

NameType
s zx/status

OnConnectionInfo

An event produced eagerly by the server if requested by ConnectionFlags.GET_CONNECTION_INFO. This event will be the first message from the server, and is sent exactly once.

Different from fuchsia.io/OnOpen, an error during open/reopen is always manifested as an epitaph.

Response

NameType
info fuchsia.io/ConnectionInfo

OnOpen

An event produced eagerly by a FIDL server if requested by OPEN_FLAG_DESCRIBE.

Indicates the success or failure of the open operation, and optionally describes the object. If the status is ZX_OK, info contains descriptive information about the object (the same as would be returned by Describe).

Response

NameType
s zx/status
info fuchsia.io/NodeInfo?

Open

Opens a new object relative to this directory object.

path may contain multiple segments, separated by "/" characters, and should never be empty; i.e. "" is an invalid path. A trailing slash implies OPEN_FLAG_DIRECTORY. Components must not be empty (i.e. "foo//bar" is invalid). ".." is disallowed anywhere in the path. "." is only allowed if the path is exactly ".", but not otherwise. A leading '/' is allowed (and is treated the same way as if not present, i.e. "/foo/bar' and "foo/bar" are the same).

flags may be any of the OPEN_FLAG_* and OPEN_RIGHT_* values, bitwise ORed together. The OPEN_FLAG_DESCRIBE flag may cause an OnOpen event to be transmitted on the object handle, indicating the type of object opened.

If an unknown value is sent for flags the connection should be closed.

OPEN_RIGHT_* flags provided in flags will restrict access rights on the object channel which will be connected to the opened entity.

Rights are never increased. When you open a nested entity within a directory, you may only request the same rights as what the directory connection already has, or a subset of those. Exceeding those rights causes an access denied error to be transmitted in the OnOpen event if applicable, and the object connection closed.

The caller must specify either one or more of the OPEN_RIGHT_* flags, or the OPEN_FLAG_NODE_REFERENCE flag.

mode is only used if an object is created and indicates the type of object to be created. An unsupported mode will cause the connection to be closed. The mode type, if set, must always be consistent with the OPEN_FLAG_DIRECTORY and OPEN_FLAG_NOT_DIRECTORY flags, even if an object is not being created. If an object is not being created, mode is otherwise ignored. If an object is being created and the mode type is not set, a directory will be created if OPEN_FLAG_DIRECTORY is set (explicitly or implicitly), or otherwise a server chosen object type.

Request

NameType
flags uint32
mode uint32
path string[4096]
object request<fuchsia.io/Node>

Open2

Opens or creates a new node relative to this directory node.

  • path identifies the node to open. If path contains multiple segments, then the directory is traversed, one segment at a time, relative to the directory represented by this connection. See fuchsia.io2/Path for what constitutes a valid path. To open another connection to the current directory, use fuchsia.io2/Node.Reopen instead.
  • mode controls whether to open existing/create new etc.
  • options additional options applicable to both Open and Reopen, including negotiating protocol and restricting rights. See fuchsia.io2/ConnectionOptions.
  • object_request is the server end of a channel created for the new connection. The caller may proceed to send messages on the corresponding client end right away.

This method requires the following rights on the current connection:

Errors are presented as an epitaph on the object_request channel.

  • error ZX_ERR_ACCESS_DENIED if the requested rights exceeds what is allowed.
  • error ZX_ERR_BAD_PATH if path is invalid.

Request

NameType
path fuchsia.io/Path
mode fuchsia.io/OpenMode
options fuchsia.io/ConnectionOptions
object_request handle<channel>

QueryFilesystem

Query the filesystem for filesystem-specific information.

Request

<EMPTY>

Response

NameType
s zx/status
info FilesystemInfo?

ReadDirents

Reads a collection of variably sized dirents into a buffer. The number of dirents in a directory may be very large: akin to calling read multiple times on a file, directories have a seek offset which is updated on subsequent calls to ReadDirents. Each call to ReadDirents will only return whole dirent structures, they will not get split across ReadDirent calls.

These dirents are of the form:

struct dirent {
  // Describes the inode of the entry.
  uint64 ino;
  // Describes the length of the dirent name in bytes.
  uint8 size;
  // Describes the type of the entry. Aligned with the
  // POSIX d_type values. Use `DIRENT_TYPE_*` constants.
  uint8 type;
  // Unterminated name of entry.
  char name[0];
}

This method does not require any rights, since one could always probe for directory contents by triggering name conflicts during file creation.

Request

NameType
max_bytes uint64

Response

NameType
s zx/status
dirents vector<uint8>[8192]

Rename2

Renames a node named src to the name dst, in a directory represented by dst_parent_token.

src and dst must be valid node names. See fuchsia.io2/Name for what constitutes a valid name.

This method requires the following rights on both the current connection, and the connection identified by dst_parent_token:

Request

NameType
src fuchsia.io2/Name
dst_parent_token fuchsia.io2/Token
dst fuchsia.io2/Name

Response

NameType
result fuchsia.io/Directory_Rename2_Result

Reopen

Creates another connection to the same node.

  • options options applicable to both Open and Reopen, including negotiating protocol and restricting rights. See fuchsia.io2/ConnectionOptions.
  • object_request is the server end of a channel created for the new connection. The caller may proceed to send messages on the corresponding client end right away.

For files, the cloned connection and the original connection have independent seek offsets.

Request

NameType
options fuchsia.io/ConnectionOptions
object_request handle<channel>

Rewind

Resets the directory seek offset.

This method does not require any rights, similar to ReadDirents.

Request

<EMPTY>

Response

NameType
s zx/status

SetAttr

Updates information about the node. flags may be any of NODE_ATTRIBUTE_FLAG_*.

This method requires following rights: OPEN_RIGHT_WRITABLE, otherwise returns ZX_ERR_BAD_HANDLE.

Request

NameType
flags uint32
attributes fuchsia.io/NodeAttributes

Response

NameType
s zx/status

Sync

Synchronizes updates to the node to the underlying media, if it exists.

This method does not require any rights.

Request

<EMPTY>

Response

NameType
s zx/status

Sync2

Synchronizes updates to the node to the underlying media, if it exists.

This method will return when the filesystem server has flushed the relevant updates to the underlying media, but does not guarantee the underlying media has persisted the information, nor that any information is committed to hardware. Clients may use Sync to ensure ordering between operations.

This method does not require any rights.

Request

<EMPTY>

Response

NameType
result fuchsia.io/Node_Sync2_Result

Removes a child node from the this directory's list of entries.

Note: this does not guarantee that the underlying object is destroyed. Although the link will be removed from the containing directory, objects with multiple references (such as files which are still open) will not actually be destroyed until all references are closed.

  • error ZX_ERR_ACCESS_DENIED if the connection does not have Rights.WRITE_BYTES.
  • error ZX_ERR_NOT_SUPPORTED if the underlying filesystem does not support writing.
  • error ZX_ERR_BAD_PATH if name is invalid.
  • error ZX_ERR_NOT_EMPTY if name refers to a non-empty directory.
  • error ZX_ERR_UNAVAILABLE if name refers to a mount point, containing a remote channel.
  • error ZX_ERR_NOT_DIR if the options requested a directory but something other than a directory was found.

Other errors may be returned for filesystem-specific reasons.

This method requires the following rights:

NameType
name fuchsia.io2/Name
options fuchsia.io2/UnlinkOptions
NameType
result fuchsia.io/Directory_Unlink_Result

Unmount

Unmount this filesystem. After this function returns successfully, all connections to the filesystem will be terminated.

Request

<EMPTY>

Response

NameType
s zx/status

UnmountNode

Detach a node which was previously attached to this directory with Mount.

Request

<EMPTY>

Response

NameType
s zx/status
remote fuchsia.io/Directory?

UpdateAttributes

Updates information about the node.

  • attributes the presence of a table field in attributes indicates the intent to update the corresponding attribute.

This method requires the Rights.UPDATE_ATTRIBUTES right.

Request

NameType
attributes fuchsia.io/NodeAttributes2

Response

NameType
result fuchsia.io/Node_UpdateAttributes_Result

Watch

Watches a directory, receiving events of added messages on the watcher request channel.

The watcher handle will send messages of the form:

struct {
  uint8 event;
  uint8 len;
  char name[];
};

Where names are NOT null-terminated.

This API is unstable; in the future, watcher will be a DirectoryWatcher client.

Mask specifies a bitmask of events to observe. Options must be zero; it is reserved.

This method does not require any rights, similar to ReadDirents.

Request

NameType
mask uint32
options uint32
watcher handle<channel>

Response

NameType
s zx/status

STRUCTS

FilesystemInfo

Defined in fuchsia.io.admin/directory_admin.fidl

FieldTypeDescriptionDefault
total_bytes uint64

The number of data bytes which may be stored in a filesystem.

No default
used_bytes uint64

The number of data bytes which are in use by the filesystem.

No default
total_nodes uint64

The number of nodes which may be stored in the filesystem.

No default
used_nodes uint64

The number of nodes used by the filesystem.

No default
free_shared_pool_bytes uint64

The amount of space which may be allocated from the underlying volume manager. If unsupported, this will be zero.

No default
fs_id uint64

A unique identifier for this filesystem instance. Will not be preserved across reboots.

No default
block_size uint32

The size of a single filesystem block.

No default
max_filename_size uint32

The maximum length of a filesystem name.

No default
fs_type uint32

A unique identifier for the type of the underlying filesystem.

No default
padding uint32 No default
name int8[32] No default

CONSTANTS

NameValueTypeDescription
MAX_FS_NAME_BUFFER 32 uint64
MOUNT_CREATE_FLAG_REPLACE 1 uint32