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