xref: /freebsd/lib/libc/gen/getfsent.3 (revision daf1cffce2e07931f27c6c6998652e90df6ba87e)
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.\" $FreeBSD$
34.\"
35.Dd June 4, 1993
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 struct 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;	/* File system type, ufs, nfs */
73	char	*fs_mntops;	/* Mount options ala -o */
74	char	*fs_type;	/* FSTAB_* from fs_mntops */
75	int	fs_freq;	/* dump frequency, in days */
76	int	fs_passno;	/* pass number on parallel fsck */
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
117.Dv NULL
118pointer on
119.Dv EOF
120or error.
121The
122.Fn setfsent
123function
124returns 0 on failure, 1 on success.
125The
126.Fn endfsent
127function
128returns nothing.
129.Sh FILES
130.Bl -tag -width /etc/fstab -compact
131.It Pa /etc/fstab
132.El
133.Sh SEE ALSO
134.Xr fstab 5
135.Sh HISTORY
136The
137.Fn getfsent
138function appeared in
139.Bx 4.0 ;
140the
141.Fn endfsent ,
142.Fn getfsfile ,
143.Fn getfsspec ,
144and
145.Fn setfsent
146functions appeared in
147.Bx 4.3 .
148.Sh BUGS
149These functions use static data storage;
150if the data is needed for future use, it should be
151copied before any subsequent calls overwrite it.
152