xref: /freebsd/lib/libc/gen/getfsent.3 (revision 7660b554bc59a07be0431c17e0e33815818baa69)
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 April 7, 2003
36.Dt GETFSENT 3
37.Os
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 LIBRARY
46.Lb libc
47.Sh SYNOPSIS
48.In fstab.h
49.Ft "struct fstab *"
50.Fn getfsent void
51.Ft "struct fstab *"
52.Fn getfsspec "const char *spec"
53.Ft "struct fstab *"
54.Fn getfsfile "const char *file"
55.Ft int
56.Fn setfsent void
57.Ft void
58.Fn endfsent void
59.Ft void
60.Fn setfstab "const char *file"
61.Ft "const char *"
62.Fn getfstab void
63.Sh DESCRIPTION
64The
65.Fn getfsent ,
66.Fn getfsspec ,
67and
68.Fn getfsfile
69functions
70each return a pointer to an object with the following structure
71containing the broken-out fields of a line in the file system
72description file,
73.In fstab.h .
74.Bd -literal -offset indent
75struct fstab {
76	char	*fs_spec;	/* block special device name */
77	char	*fs_file;	/* file system path prefix */
78	char	*fs_vfstype;	/* File system type, ufs, nfs */
79	char	*fs_mntops;	/* Mount options ala -o */
80	char	*fs_type;	/* FSTAB_* from fs_mntops */
81	int	fs_freq;	/* dump frequency, in days */
82	int	fs_passno;	/* pass number on parallel fsck */
83};
84.Ed
85.Pp
86The fields have meanings described in
87.Xr fstab 5 .
88.Pp
89The
90.Fn setfsent
91function
92opens the file (closing any previously opened file) or rewinds it
93if it is already open.
94.Pp
95The
96.Fn endfsent
97function
98closes the file.
99.Pp
100The
101.Fn setfstab
102function sets the file to be used by subsequent operations.
103The value set by
104.Fn setfstab
105does not persist across calls to
106.Fn endfsent .
107.Pp
108The
109.Fn getfstab
110function returns the name of the file that will be used.
111.Pp
112The
113.Fn getfsspec
114and
115.Fn getfsfile
116functions
117search the entire file (opening it if necessary) for a matching special
118file name or file system file name.
119.Pp
120For programs wishing to read the entire database,
121.Fn getfsent
122reads the next entry (opening the file if necessary).
123.Pp
124All entries in the file with a type field equivalent to
125.Dv FSTAB_XX
126are ignored.
127.Sh RETURN VALUES
128The
129.Fn getfsent ,
130.Fn getfsspec ,
131and
132.Fn getfsfile
133functions
134return a
135.Dv NULL
136pointer on
137.Dv EOF
138or error.
139The
140.Fn setfsent
141function
142returns 0 on failure, 1 on success.
143The
144.Fn endfsent
145function
146returns nothing.
147.Sh ENVIRONMENT
148.Bl -tag -width ".Ev PATH_FSTAB"
149.It Ev PATH_FSTAB
150If the environment variable
151.Ev PATH_FSTAB
152is set, all operations are performed against the specified file.
153.Ev PATH_FSTAB
154will not be honored if the process environment or memory address space is
155considred
156.Dq tainted .
157(See
158.Xr issetugid 2
159for more information.)
160.El
161.Sh FILES
162.Bl -tag -width /etc/fstab -compact
163.It Pa /etc/fstab
164.El
165.Sh SEE ALSO
166.Xr fstab 5
167.Sh HISTORY
168The
169.Fn getfsent
170function appeared in
171.Bx 4.0 ;
172the
173.Fn endfsent ,
174.Fn getfsfile ,
175.Fn getfsspec ,
176and
177.Fn setfsent
178functions appeared in
179.Bx 4.3 ;
180the
181.Fn setfstab
182and
183.Fn getfstab
184functions appeared in
185.Fx 5.1 .
186.Sh BUGS
187These functions use static data storage;
188if the data is needed for future use, it should be
189copied before any subsequent calls overwrite it.
190