xref: /freebsd/lib/libc/gen/getfsent.3 (revision 380a989b3223d455375b4fae70fd0b9bdd43bafb)
1.\" Copyright (c) 1983, 1991, 1993
2.\"	The Regents of the University of California.  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.\"     @(#)getfsent.3	8.1 (Berkeley) 6/4/93
33.\"
34.Dd June 4, 1993
35.Dt GETFSENT 3
36.Os BSD 4
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
63each return a pointer to an object with the following structure
64containing the broken-out fields of a line in the file system
65description file,
66.Aq Pa fstab.h .
67.Bd -literal -offset indent
68struct fstab {
69	char	*fs_spec;	/* block special device name */
70	char	*fs_file;	/* file system path prefix */
71	char	*fs_vfstype;	/* File system type, ufs, nfs */
72	char	*fs_mntops;	/* Mount options ala -o */
73	char	*fs_type;	/* FSTAB_* from fs_mntops */
74	int	fs_freq;	/* dump frequency, in days */
75	int	fs_passno;	/* pass number on parallel fsck */
76};
77.Ed
78.Pp
79The fields have meanings described in
80.Xr fstab 5 .
81.Pp
82The
83.Fn setfsent
84function
85opens the file (closing any previously opened file) or rewinds it
86if it is already open.
87.Pp
88The
89.Fn endfsent
90function
91closes the file.
92.Pp
93The
94.Fn getfsspec
95and
96.Fn getfsfile
97functions
98search the entire file (opening it if necessary) for a matching special
99file name or file system file name.
100.Pp
101For programs wishing to read the entire database,
102.Fn getfsent
103reads the next entry (opening the file if necessary).
104.Pp
105All entries in the file with a type field equivalent to
106.Dv FSTAB_XX
107are ignored.
108.Sh RETURN VALUES
109The
110.Fn getfsent ,
111.Fn getfsspec ,
112and
113.Fn getfsfile
114functions
115return a
116.Dv NULL
117pointer on
118.Dv EOF
119or error.
120The
121.Fn setfsent
122function
123returns 0 on failure, 1 on success.
124The
125.Fn endfsent
126function
127returns nothing.
128.Sh FILES
129.Bl -tag -width /etc/fstab -compact
130.It Pa /etc/fstab
131.El
132.Sh SEE ALSO
133.Xr fstab 5
134.Sh HISTORY
135The
136.Fn getfsent
137function appeared in
138.Bx 4.0 ;
139the
140.Fn endfsent ,
141.Fn getfsfile ,
142.Fn getfsspec ,
143and
144.Fn setfsent
145functions appeared in
146.Bx 4.3 .
147.Sh BUGS
148These functions use static data storage;
149if the data is needed for future use, it should be
150copied before any subsequent calls overwrite it.
151