An opaque structure that represents the object to which a file descriptor refers.
WARNING: These interfaces exist to allow integration of fdio file descriptors with handle-centric message loops. If used incorrectly they can seriously mess up the state of fdio, fds, etc.
Access the zxio_t
field within an fdio_t
.
Storage for a ZXIO object.
See lib/zxio/ops.h
for more information.
Install an fdio_t
in the file descriptor table for this process.
If fd >= 0, request a specific fd, and starting_fd is ignored.
If fd < 0, request the first available fd >= starting_fd.
Upon success, returns the allocated file descriptor. Returns -1 on failure.
Always takes ownership of the given reference to the fdio_t
. Upon success, that reference is owned by the file descriptor table. Upon failure, the reference is released.
Creates an fdio_t
from a zx_handle_t
.
The handle
must be to a channel, socket, vmo, or debuglog object. The handle is always consumed by this function.
If the zx_handle_t
is a channel, then the channel must implement the fuchsia.unknown/Queryable
protocol.
ZX_ERR_BAD_HANDLE
: The input handle
is invalid.
ZX_ERR_ACCESS_DENIED
: Then input handle
does not have the necessary rights.
ZX_ERR_NO_MEMORY
: Memory allocation failed.
ZX_ERR_NOT_SUPPORTED
: The kernel object type is not valid for an FD.
Creates an fdio_t
that does nothing.
Creates a file descriptor that does nothing.
Returns -1 and sets errno if the function is unable to create the file descriptor (e.g., if the file descriptor table is full).
Returns a handle to the channel backing a file descriptor.
Upon success, a handle to the backing channel is returned in out
, and the caller receives ownership of that handle.
Always removes the file descriptor from the file descriptor table for this process.
ZX_ERR_INVALID_ARGS
: fd
is not a valid file descriptor.
ZX_ERR_NOT_SUPPORTED
: fd
is not backed by a channel.
ZX_ERR_UNAVAILABLE
: fd
is busy or has been dup'ed and therefore is referenced by multiple entries in the file descriptor table.
Creates an fdio_t
that acts as /dev/null
.
Removes a file descriptor from the file descriptor table for this process.
Upon success, the fdio_t
underlying the file descriptor is returned in io_out
, and the caller receives ownership of one reference to fdio_t
. Specifically, the caller is responsible for calling fdio_unsafe_release
upon success.
ZX_ERR_INVALID_ARGS
: fd
is not a valid file descriptor.
ZX_ERR_UNAVAILABLE
: fd
is busy or has been dup'ed and therefore is referenced by multiple entries in the file descriptor table.
Creates an fdio_t
that is backed by a zxio_t
.
The zxio_t
is initialized with a null ops table. The zxio_storage_t
for the zxio_t
is returned via out_storage
. The client can re-initialize the zxio_storage_t
to customize the behavior of the zxio_t
.
The returned zxio_storage_t
is valid for the lifetime of the returned fdio_t
.
To bind the fdio_t
to a file descriptor, use fdio_bind_to_fd
.
Upon success, the caller receives ownership of one reference to fdio_t
. Specifically, the caller is responsible for calling fdio_unsafe_release()
upon success.
Upon failure, returns NULL.