The Hackerlab at `regexps.com`

## Reserved File Descriptors and Pseudo-Descriptors

up: libhackerlab next: Virtual Null File Descriptors prev: Buffered File Descriptors

The functions in this section allow programs to allocate file descriptors and pseudo-descriptors. A pseudo-descriptor is an integer outside of the range of descriptors used by the kernel (`0..(OPEN_MAX - 1)` ). Pseudo-descriptors are densely packed (allocated sequentially beginning with `OPEN_MAX` ) and are suitable for use with the function `vu_set_fd_handler` (see A Virtual Unix File-System Interface).

Function `reserv`

    int reserv (int * errn, int flags);

Allocate a file descriptor by opening `"/dev/null"` by using `vu_open` in the manner descibed by `flags` which may be one of `O_RDONLY` , `O_RDWR` etc.

(See vu_open.)

Function `reserv_pseudo`

    int reserv_pseudo (int * errn, int flags);

Reserve a pseudo file descriptor suitable for use with `vu_set_fd_handler` . A pseudo file descriptor can be used with the vu file system functions and is guaranteed not to be the same as any real file descriptor. (see A Virtual Unix File-System Interface)

Function `reserv_pseudo_ge_n`

    int reserv_pseudo_ge_n (int * errn, int n, int flags);

Reserve a pseudo file descriptor greater than or equal to `n` suitable for use with `vu_set_fd_handler` . A pseudo file descriptor can be used with the vu file system functions and is guaranteed not to be the same as any real file descriptor. (see A Virtual Unix File-System Interface)

This function is useful for implementing `vu_fcntl` with a `cmd` argument `F_DUPFD` .

Function `unreserv_pseudo`

    void unreserv_pseudo (int fd);

Release a pseudo-descriptor previously allocated by `reserved_pseudo` .

libhackerlab: The Hackerlab C Library
The Hackerlab at `regexps.com`