blob: 839865b983f9f639b078e288571efad24c57381e [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library fuchsia.io2;
/// The common members definition behind [`Rights`] and [`Abilities`].
/// Note that Directory operations are distinct from File operations, with the
/// exception of some common operations (e.g. `GET_ATTRIBUTES`) defined on the
/// underlying [`fuchsia.io2/Node`].
bits Operations : uint64 {
/// Connecting to a service.
CONNECT = 0x01;
/// Reading from the byte contents of a node.
READ_BYTES = 0x02;
/// Writing to the byte contents of a node.
WRITE_BYTES = 0x04;
/// Execute the byte contents of a node.
EXECUTE = 0x08;
/// Reading the attributes of a node.
GET_ATTRIBUTES = 0x10;
/// Updating the attributes of a node.
UPDATE_ATTRIBUTES = 0x20;
/// Reading the list of entries in a directory.
ENUMERATE = 0x40;
/// Opening a node from a directory.
///
/// When used in `ConnectionOptions.rights`, it must be specified together
/// with [`Rights.ENUMERATE`], since one can always probe the directory
/// contents by opening children.
TRAVERSE = 0x80;
/// Modifying the list of entries in a directory.
/// For example: node creation, renaming, linking, unlinking, etc.
///
/// When used in `ConnectionOptions.rights`, it must be specified together
/// with [`Rights.ENUMERATE`], since one can always probe the directory
/// contents by triggering name conflicts during node creation.
MODIFY_DIRECTORY = 0x100;
// TODO(fxbug.dev/36541)
// Temporary operation ported from fuchsia.io to allow OPEN_RIGHT_ADMIN.
ADMIN = 0x100000000000000;
};
/// Right Aliases - Useful constants for commonly used collections of
/// rights. Currently FIDL doesn't support expressions on assignment so
/// these cannot be defined. They are left here as documentation.
/// Alias for directory permission alias r*
/// CONNECT | ENUMERATE | TRAVERSE | READ_BYTES | GET_ATTRIBUTES
const uint64 R_STAR_DIR = 0xD3;
/// Alias for directory permission alias rw*
/// CONNECT | ENUMERATE | TRAVERSE | READ_BYTES | WRITE_BYTES |
/// MODIFY_DIRECTORY | GET_ATTRIBUTES | UPDATE_ATTRIBUTES
const uint64 RW_STAR_DIR = 0x1F7;
/// Alias for directory permission alias rx*
/// CONNECT | ENUMERATE | TRAVERSE | READ_BYTES | GET_ATTRIBUTES | EXECUTE
const uint64 RX_STAR_DIR = 0xDB;
/// Alias for directory permission alias w*
/// CONNECT | ENUMERATE | TRAVERSE | WRITE_BYTES | MODIFY_DIRECTORY |
/// UPDATE_ATTRIBUTES
const uint64 W_STAR_DIR = 0x1E5;
/// Alias for directory permission alias x*
/// CONNECT | ENUMERATE | TRAVERSE | EXECUTE
const uint64 X_STAR_DIR = 0xC9;
/// Rights are properties specific to a connection. They limit which operations
/// are allowed on a connection.
///
/// Invoking an operation without the corresponding right results in a
/// `ZX_ERR_ACCESS_DENIED` error.
using Rights = Operations;
/// Abilities are properties intrinsic to a node. They specify which operations
/// are supported by it.
///
/// Invoking an operation without corresponding support in the node results in a
/// `ZX_ERR_NOT_SUPPORTED` error.
/// Note that if both the access denied and the not supported error conditions
/// apply, the access denied case takes precedence.
using Abilities = Operations;