@need 3200

@node Reserved File Descriptors and Pseudo-Descriptors
@chapter Reserved File Descriptors and Pseudo-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
(@code{0..(OPEN_MAX - 1)}).  Pseudo-descriptors are densely packed
(allocated sequentially beginning with @code{OPEN_MAX}) and are suitable
for use with the function @code{vu_set_fd_handler} (see @ref{A Virtual Unix File-System Interface}).

@sp 1
@need 1750
@noindent
@b{* Function} @code{reserv}@fuindex reserv
@*
@example
@group
int reserv (int * errn, int flags);
@end group
@group
@end group
@end example

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


(See @strong{vu_open} in @ref{The VU File-system Interface}.)

@sp 1
@need 1750
@noindent
@b{* Function} @code{reserv_pseudo}@fuindex reserv_pseudo
@*
@example
@group
int reserv_pseudo (int * errn, int flags);
@end group
@group
@end group
@end example

Reserve a pseudo file descriptor suitable for use with
@code{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 @ref{A Virtual Unix File-System Interface})

@sp 1
@need 1750
@noindent
@b{* Function} @code{reserv_pseudo_ge_n}@fuindex reserv_pseudo_ge_n
@*
@example
@group
int reserv_pseudo_ge_n (int * errn, int n, int flags);
@end group
@group
@end group
@end example

Reserve a pseudo file descriptor greater than or equal to @code{n}
suitable for use with @code{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
@ref{A Virtual Unix File-System Interface})


This function is useful for implementing @code{vu_fcntl} with a @code{cmd}
argument @code{F_DUPFD}.

@sp 1
@need 1750
@noindent
@b{* Function} @code{unreserv_pseudo}@fuindex unreserv_pseudo
@*
@example
@group
void unreserv_pseudo (int fd);
@end group
@group
@end group
@end example

Release a pseudo-descriptor previously allocated by
@code{reserved_pseudo}.




