bind9/doc/man/dir.man
2000-06-01 03:19:06 +00:00

155 lines
3.9 KiB
Groff

.\"
.\" Copyright (C) 2000 Internet Software Consortium.
.\"
.\" Copyright (C) 2000 Internet Software Consortium.
.\"
.\" Permission to use, copy, modify, and distribute this document for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
.\" DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
.\" INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
.\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
.\" FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
.\" NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
.\" WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.\" $Id: dir.man,v 1.1 2000/06/01 03:19:06 jim Exp $
.\"
.Dd Jun 30, 2000
.Dt FSDIR 3
.Os BIND9 9
.ds vT BIND9 Programmer's Manual
.Sh NAME
.Nm isc_dir_init ,
.Nm isc_dir_open ,
.Nm isc_dir_read ,
.Nm isc_dir_close ,
.Nm isc_dir_reset ,
.Nm isc_dir_chdir
.Nd file system directory operations
.Sh SYNOPSIS
.Fd #include <config.h>
.Fd #include <errno.h>
.Fd #include <unistd.h>
.Fd #include <isc/dir.h>
.Fd #include <isc/magic.h>
.Fd #include <isc/string.h>
.Fd #include <isc/util.h>
.Fd #include \*qerrno2result.h\*q
.Ft void
.Fn isc_dir_init "isc_dir_t *dir"
.Ft isc_result_t
.Fn isc_dir_open "isc_dir_t *dir, const char *dirname"
.Ft isc_result_t
.Fn isc_dir_read "isc_dir_t *dir"
.Ft isc_result_t
.Fn isc_dir_close "isc_dir_t *dir"
.Ft isc_result_t
.Fn isc_dir_chdir "const char *dirname"
.Sh DESCRIPTION
These functions define the operations performed on the file system's
directories by the name server.
They are intended to isolate BIND9 from the semantics of the underlying
directory access routines provided by the operating system,
BIND9 uses an internal structure of type
.Fa isc_dir_t
to reference a directory.
The contents of this structure are OS-specific.
.Fn isc_dir_init
initialises the directory structure pointed at
.Fa dir .
All functions taking a
.Fa dir
argument must ensure that
this parameter points at a valid
.Fa isc_dir_t
structure.
.Pp
.Fn isc_dir_open
opens the directory named by
.Fa dirname .
.Pp
.Fn isc_dir_read
retrieves the next entry from the file descriptor associated with directory
.Fa dir .
The name of that entry and the length of its name are copied to
.Fa dir .
A successful initial call to
.Fn isc_dir_read
on a directory will populate the
.Fa isc_dir_t
with details of the first valid directory entry.
Subsequent calls fetch the next entries.
.Pp
The
.Fn isc_dir_close
function
closes the file descriptor associated with
.Fa dir .
.Pp
.Fn isc_dir_reset
repositions
.Fa dir
to the start of the directory.
.Pp
The name server's current directory is changed to
.Fa dirname
by
.Fn isc_dir_chdir .
.Pp
.Sh RETURN VALUES
Successful calls to
.Fn isc_dir_open ,
.Fn isc_dir_read ,
.Fn isc_dir_reset ,
.Fn isc_dir_read
and
.Fn isc_dir_chdir
return
.Er ISC_R_SUCCESS .
.Fn isc_dir_read
returns
.Er ISC_R_NOMORE
when there are no more entries in the directory.
.Er ISC_R_UNEXPECTED
is returned if the name of the next directory entry is too big
to fit in the
.Fa isc_dir_t
structure.
If
.Fn isc_dir_chdir
fails,
.Er ISC_R_INVALIDFILE
is returned if
.Fa dirname
is not a directory, or
.Er ISC_R_NOPERM
if access permission is denied or
.Er ISC_R_IOERROR
if an I/O error occurs.
The WinNT version of
.Fn isc_dir_chdir
returns
.Er ISC_R_NOTIMPLEMENTED
when the operating system reports an error that cannot be defined by
either a return value of
.Er ISC_R_NOTFOUND
or
.Er ISC_R_UNEXPECTED .
An error of
.Er ISC_R_FAILURE
can be returned in the WinNT versions of
.Fn isc_dir_open
and
.Fn isc_dir_reset
.Sh SEE ALSO
.Xr opendir 3 ,
.Xr readdir 3 ,
.Xr closedir 3 ,
.Xr rewinddir 3 ,
.Xr chdir 2