xref: /netbsd-src/lib/libc/gen/getfsent.3 (revision cda4f8f6ee55684e8d311b86c99ea59191e6b74f)
1.\" Copyright (c) 1983, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"     from: @(#)getfsent.3	6.9 (Berkeley) 4/19/91
33.\"	$Id: getfsent.3,v 1.2 1993/07/30 08:36:28 mycroft Exp $
34.\"
35.Dd April 19, 1991
36.Dt GETFSENT 3
37.Os BSD 4
38.Sh NAME
39.Nm getfsent ,
40.Nm getfsspec ,
41.Nm getfsfile ,
42.Nm setfsent ,
43.Nm endfsent
44.Nd get file system descriptor file entry
45.Sh SYNOPSIS
46.Fd #include <fstab.h>
47.Ft fstab *
48.Fn getfsent void
49.Ft struct fstab *
50.Fn getfsspec "const char *spec"
51.Ft struct fstab *
52.Fn getfsfile "const char *file"
53.Ft int
54.Fn setfsent void
55.Ft void
56.Fn endfsent void
57.Sh DESCRIPTION
58The
59.Fn getfsent ,
60.Fn getfsspec ,
61and
62.Fn getfsfile
63functions
64each return a pointer to an object with the following structure
65containing the broken-out fields of a line in the file system
66description file,
67.Aq Pa fstab.h .
68.Bd -literal -offset indent
69struct fstab {
70	char	*fs_spec;	/* block special device name */
71	char	*fs_file;	/* file system path prefix */
72	char	*fs_vfstype;	/* type of file system */
73	char	*fs_mntops;	/* comma separated mount options */
74	char	*fs_type;	/* rw, ro, sw, or xx */
75	int	fs_freq;	/* dump frequency, in days */
76	int	fs_passno;	/* pass number on parallel dump */
77};
78.Ed
79.Pp
80The fields have meanings described in
81.Xr fstab 5 .
82.Pp
83The
84.Fn setfsent
85function
86opens the file (closing any previously opened file) or rewinds it
87if it is already open.
88.Pp
89The
90.Fn endfsent
91function
92closes the file.
93.Pp
94The
95.Fn getfsspec
96and
97.Fn getfsfile
98functions
99search the entire file (opening it if necessary) for a matching special
100file name or file system file name.
101.Pp
102For programs wishing to read the entire database,
103.Fn getfsent
104reads the next entry (opening the file if necessary).
105.Pp
106All entries in the file with a type field equivalent to
107.Dv FSTAB_XX
108are ignored.
109.Sh RETURN VALUES
110The
111.Fn getfsent ,
112.Fn getfsspec ,
113and
114.Fn getfsfile
115functions
116return a null pointer (0) on
117.Dv EOF
118or error.
119The
120.Fn setfsent
121function
122returns 0 on failure, 1 on success.
123The
124.Fn endfsent
125function
126returns nothing.
127.Sh FILES
128.Bl -tag -width /etc/fstab -compact
129.It Pa /etc/fstab
130.El
131.Sh SEE ALSO
132.Xr fstab 5
133.Sh HISTORY
134The
135.Fn getfsent
136function appeared in
137.Bx 4.0 ;
138the
139.Fn endfsent ,
140.Fn getfsfile ,
141.Fn getfsspec ,
142and
143.Fn setfsent
144functions appeared in
145.Bx 4.3 .
146.Sh BUGS
147These functions use static data storage;
148if the data is needed for future use, it should be
149copied before any subsequent calls overwrite it.
150