blob: 3df932b3d34a08bbc6365ccf31b6c5cd3368fef4 [file] [log] [blame] [view]
# \<lib/fdio/directory.h\> in fdio
[Header source code](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/fdio/include/lib/fdio/directory.h)
## fdio_open(…) {:#fdio_open}
[Declaration source code](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/fdio/include/lib/fdio/directory.h#58)
<pre class="devsite-disable-click-to-copy">
<span class="typ">zx_status_t</span> <b>fdio_open</b>(<span class="typ">const char *</span> path,
<span class="typ">uint32_t</span> flags,
<span class="typ">zx_handle_t</span> request);
</pre>
Opens an object at `path` relative to the root of the namespace for the current process with
`flags` asynchronously.
`flags` is a `fuchsia.io/OpenFlags`.
Always consumes `request`.
See `fdio_ns_open` for details.
## fdio_open_at(…) {:#fdio_open_at}
[Declaration source code](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/fdio/include/lib/fdio/directory.h#74)
<pre class="devsite-disable-click-to-copy">
<span class="typ">zx_status_t</span> <b>fdio_open_at</b>(<span class="typ">zx_handle_t</span> directory,
<span class="typ">const char *</span> path,
<span class="typ">uint32_t</span> flags,
<span class="typ">zx_handle_t</span> request);
</pre>
Opens an object at `path` relative to `directory` with `flags` asynchronously.
Upon success, `request` is handed off to the remote party. The operation completes
asynchronously, which means a ZX_OK result does not ensure that the requested service actually
exists.
`directory` must be a channel that implements the `fuchsia.io/Directory` protocol.
`request` must be a channel which will always be consumed by this function.
### Errors
ZX_ERR_INVALID_ARGS: `directory` or `path` is invalid.
## fdio_open_fd(…) {:#fdio_open_fd}
[Declaration source code](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/fdio/include/lib/fdio/directory.h#87)
<pre class="devsite-disable-click-to-copy">
<span class="typ">zx_status_t</span> <b>fdio_open_fd</b>(<span class="typ">const char *</span> path,
<span class="typ">uint32_t</span> flags,
<span class="typ">int *</span> out_fd);
</pre>
Opens an object at `path` relative to the root of the namespace for the current process with
`flags` synchronously, and on success, binds that channel to a file descriptor, returned via
`out_fd`.
Note that unlike `fdio_open`, this function is synchronous. This is because it produces a file
descriptor, which requires synchronously waiting for the open to complete.
`flags` is a `fuchsia.io/OpenFlags`.
See `fdio_open` for details.
## fdio_open_fd_at(…) {:#fdio_open_fd_at}
[Declaration source code](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/fdio/include/lib/fdio/directory.h#98)
<pre class="devsite-disable-click-to-copy">
<span class="typ">zx_status_t</span> <b>fdio_open_fd_at</b>(<span class="typ">int</span> dir_fd,
<span class="typ">const char *</span> path,
<span class="typ">uint32_t</span> flags,
<span class="typ">int *</span> out_fd);
</pre>
Opens an object at `path` relative to `dir_fd` with `flags` synchronously, and on success, binds
that channel to a file descriptor, returned via `out_fd`.
Note that unlike fdio_open, this function is synchronous. This is because it produces a file
descriptor, which requires synchronously waiting for the open to complete.
`flags` is a `fuchsia.io/OpenFlags`.
See `fdio_open_at` fort details.
## fdio_service_clone(…) {:#fdio_service_clone}
[Declaration source code](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/fdio/include/lib/fdio/directory.h#111)
<pre class="devsite-disable-click-to-copy">
<span class="typ">zx_handle_t</span> <b>fdio_service_clone</b>(<span class="typ">zx_handle_t</span> node);
</pre>
Clone the given `node` asynchronously.
`node` must be a channel that implements the `fuchsia.io/Node` protocol.
Upon success, returns a handle to a newly created channel whose remote endpoint has been sent to
`node` as a request for a clone.
The `node` is cloned as readable and writable.
Upon failure, returns `ZX_HANDLE_INVALID`.
## fdio_service_clone_to(…) {:#fdio_service_clone_to}
[Declaration source code](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/fdio/include/lib/fdio/directory.h#130)
<pre class="devsite-disable-click-to-copy">
<span class="typ">zx_status_t</span> <b>fdio_service_clone_to</b>(<span class="typ">zx_handle_t</span> node,
<span class="typ">zx_handle_t</span> request);
</pre>
Requests that `request` be connected to a clone of the given `node` asynchronously.
`node` must be a channel that implements the `fuchsia.io/Node` protocol.
`request` must be a channel.
Upon success, `request` has been sent to `node` as a request for a clone. The `node` is cloned as
readable and writable.
### Errors
* `ZX_ERR_INVALID_ARGS`: `node` or `request` is invalid.
Returns transport- and application-level errors associated with
`fuchsia.io/Node.Clone`.
## fdio_service_connect(…) {:#fdio_service_connect}
[Declaration source code](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/fdio/include/lib/fdio/directory.h#27)
<pre class="devsite-disable-click-to-copy">
<span class="typ">zx_status_t</span> <b>fdio_service_connect</b>(<span class="typ">const char *</span> path,
<span class="typ">zx_handle_t</span> request);
</pre>
Connects to a service at `path` relative to the root of the namespace for the current process
asynchronously.
`request` must be a channel.
Always consumes `request`.
See `fdio_ns_service_connect` for details.
## fdio_service_connect_at(…) {:#fdio_service_connect_at}
[Declaration source code](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/fdio/include/lib/fdio/directory.h#43)
<pre class="devsite-disable-click-to-copy">
<span class="typ">zx_status_t</span> <b>fdio_service_connect_at</b>(<span class="typ">zx_handle_t</span> directory,
<span class="typ">const char *</span> path,
<span class="typ">zx_handle_t</span> request);
</pre>
Connects to a service at the given `path` relative to the given `directory` asynchronously.
Upon success, the `request` is handed off to the remote party. The operation completes
asynchronously, which means a ZX_OK result does not ensure that the requested service actually
exists.
`directory` must be a channel that implements the `fuchsia.io/Directory` protocol.
`request` must be a channel. It will always be consumed by this function.
### Errors
ZX_ERR_INVALID_ARGS: `directory` or `path` is invalid.
## fdio_service_connect_by_name(…) {:#fdio_service_connect_by_name}
[Declaration source code](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/fdio/include/lib/fdio/directory.h#47)
<pre class="devsite-disable-click-to-copy">
<span class="typ">zx_status_t</span> <b>fdio_service_connect_by_name</b>(<span class="typ">const char *</span> name,
<span class="typ">zx_handle_t</span> request);
</pre>
Connect to a service named `name` in /svc.