xref: /freebsd/lib/libc/gen/getfsent.3 (revision 17ee9d00bc1ae1e598c38f25826f861e4bc6c3ce)
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 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;	/* type of file system */
72	char	*fs_mntops;	/* comma separated mount options */
73	char	*fs_type;	/* rw, ro, sw, or xx */
74	int	fs_freq;	/* dump frequency, in days */
75	int	fs_passno;	/* pass number on parallel dump */
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 null pointer (0) on
116.Dv EOF
117or error.
118The
119.Fn setfsent
120function
121returns 0 on failure, 1 on success.
122The
123.Fn endfsent
124function
125returns nothing.
126.Sh FILES
127.Bl -tag -width /etc/fstab -compact
128.It Pa /etc/fstab
129.El
130.Sh SEE ALSO
131.Xr fstab 5
132.Sh HISTORY
133The
134.Fn getfsent
135function appeared in
136.Bx 4.0 ;
137the
138.Fn endfsent ,
139.Fn getfsfile ,
140.Fn getfsspec ,
141and
142.Fn setfsent
143functions appeared in
144.Bx 4.3 .
145.Sh BUGS
146These functions use static data storage;
147if the data is needed for future use, it should be
148copied before any subsequent calls overwrite it.
149