| # \<lib/fdio/unsafe.h\> in fdio |
| |
| [Header source code](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/fdio/include/lib/fdio/unsafe.h) |
| |
| ## fdio_unsafe_borrow_channel(…) {:#fdio_unsafe_borrow_channel} |
| |
| [Declaration source code](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/fdio/include/lib/fdio/unsafe.h#31) |
| |
| <pre class="devsite-disable-click-to-copy"> |
| <span class="typ">zx_handle_t</span> <b>fdio_unsafe_borrow_channel</b>(<span class="typ">fdio_t *</span> io); |
| </pre> |
| |
| Returns the handle corresponding to the underlying fdio, if there is one. Returns |
| ZX_HANDLE_INVALID otherwise. |
| |
| Since this handle is borrowed from the underlying fdio_t, it is unsafe to close it or use it |
| after fdio_unsafe_release is called. |
| |
| |
| ## fdio_unsafe_fd_to_io(…) {:#fdio_unsafe_fd_to_io} |
| |
| [Declaration source code](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/fdio/include/lib/fdio/unsafe.h#24) |
| |
| <pre class="devsite-disable-click-to-copy"> |
| <span class="typ">fdio_t *</span> <b>fdio_unsafe_fd_to_io</b>(<span class="typ">int</span> fd); |
| </pre> |
| |
| This looks up a file descriptor, and if it exists, upreferences the fdio_t under it and returns |
| that. fdio_unsafe_release() must be called later to release the reference. |
| |
| If the fd does not exist, it returns NULL |
| |
| |
| ## fdio_unsafe_release(…) {:#fdio_unsafe_release} |
| |
| [Declaration source code](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/fdio/include/lib/fdio/unsafe.h#35) |
| |
| <pre class="devsite-disable-click-to-copy"> |
| <span class="typ">void</span> <b>fdio_unsafe_release</b>(<span class="typ">fdio_t *</span> io); |
| </pre> |
| |
| Releases a reference on a fdio_t. Used to "return" a fdio_t obtained from fdio_unsafe_fd_to_io() |
| when you're done with it. |
| |
| |
| ## fdio_unsafe_wait_begin(…) {:#fdio_unsafe_wait_begin} |
| |
| [Declaration source code](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/fdio/include/lib/fdio/unsafe.h#48) |
| |
| <pre class="devsite-disable-click-to-copy"> |
| <span class="typ">void</span> <b>fdio_unsafe_wait_begin</b>(<span class="typ">fdio_t *</span> io, |
| <span class="typ">uint32_t</span> events, |
| <span class="typ">zx_handle_t *</span> handle_out, |
| <span class="typ">zx_signals_t *</span> signals_out); |
| </pre> |
| |
| This given a fdio_t, and a bitmask of posix-style events (EPOLLIN, EPOLLOUT, EPOLLERR), this |
| returns a handle that may be waited upon and a bitmask of which signals to wait on for the |
| desired events. |
| |
| The handle belongs to the fdio_t, is not duplicated, and may be closed() by the fdio library but |
| MUST NOT be closed by the caller. |
| |
| If waiting is not supported by this fdio_t, the returned handle is ZX_HANDLE_INVALID. |
| |
| This function is only safe to call on a fdio_t you hold a reference to. It is not required that |
| `fdio_unsafe_wait_end()` be called after this. |
| |
| |
| ## fdio_unsafe_wait_end(…) {:#fdio_unsafe_wait_end} |
| |
| [Declaration source code](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/fdio/include/lib/fdio/unsafe.h#55) |
| |
| <pre class="devsite-disable-click-to-copy"> |
| <span class="typ">void</span> <b>fdio_unsafe_wait_end</b>(<span class="typ">fdio_t *</span> io, |
| <span class="typ">zx_signals_t</span> signals, |
| <span class="typ">uint32_t *</span> events_out); |
| </pre> |
| |
| This given a set of signals observed on a handle obtained from fdio_unsafe_wait_begin() returns a |
| set of posix-style events that are indicated. |
| |
| This function is only safe to call on a fdio_t you hold a reference to. |
| |
| |