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