xref: /freebsd/lib/libc/gen/getfsent.3 (revision 6829dae12bb055451fa467da4589c43bd03b1e64)
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. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\"     @(#)getfsent.3	8.1 (Berkeley) 6/4/93
29.\" $FreeBSD$
30.\"
31.Dd April 7, 2003
32.Dt GETFSENT 3
33.Os
34.Sh NAME
35.Nm getfsent ,
36.Nm getfsspec ,
37.Nm getfsfile ,
38.Nm setfsent ,
39.Nm endfsent
40.Nd get file system descriptor file entry
41.Sh LIBRARY
42.Lb libc
43.Sh SYNOPSIS
44.In fstab.h
45.Ft "struct fstab *"
46.Fn getfsent void
47.Ft "struct fstab *"
48.Fn getfsspec "const char *spec"
49.Ft "struct fstab *"
50.Fn getfsfile "const char *file"
51.Ft int
52.Fn setfsent void
53.Ft void
54.Fn endfsent void
55.Ft void
56.Fn setfstab "const char *file"
57.Ft "const char *"
58.Fn getfstab void
59.Sh DESCRIPTION
60The
61.Fn getfsent ,
62.Fn getfsspec ,
63and
64.Fn getfsfile
65functions
66each return a pointer to an object with the following structure
67containing the broken-out fields of a line in the file system
68description file,
69.In fstab.h .
70.Bd -literal -offset indent
71struct fstab {
72	char	*fs_spec;	/* block special device name */
73	char	*fs_file;	/* file system path prefix */
74	char	*fs_vfstype;	/* File system type, ufs, nfs */
75	char	*fs_mntops;	/* Mount options ala -o */
76	char	*fs_type;	/* FSTAB_* from fs_mntops */
77	int	fs_freq;	/* dump frequency, in days */
78	int	fs_passno;	/* pass number on parallel fsck */
79};
80.Ed
81.Pp
82The fields have meanings described in
83.Xr fstab 5 .
84.Pp
85The
86.Fn setfsent
87function
88opens the file (closing any previously opened file) or rewinds it
89if it is already open.
90.Pp
91The
92.Fn endfsent
93function
94closes the file.
95.Pp
96The
97.Fn setfstab
98function sets the file to be used by subsequent operations.
99The value set by
100.Fn setfstab
101does not persist across calls to
102.Fn endfsent .
103.Pp
104The
105.Fn getfstab
106function returns the name of the file that will be used.
107.Pp
108The
109.Fn getfsspec
110and
111.Fn getfsfile
112functions
113search the entire file (opening it if necessary) for a matching special
114file name or file system file name.
115.Pp
116For programs wishing to read the entire database,
117.Fn getfsent
118reads the next entry (opening the file if necessary).
119.Pp
120All entries in the file with a type field equivalent to
121.Dv FSTAB_XX
122are ignored.
123.Sh RETURN VALUES
124The
125.Fn getfsent ,
126.Fn getfsspec ,
127and
128.Fn getfsfile
129functions
130return a
131.Dv NULL
132pointer on
133.Dv EOF
134or error.
135The
136.Fn setfsent
137function
138returns 0 on failure, 1 on success.
139The
140.Fn endfsent
141function
142returns nothing.
143.Sh ENVIRONMENT
144.Bl -tag -width ".Ev PATH_FSTAB"
145.It Ev PATH_FSTAB
146If the environment variable
147.Ev PATH_FSTAB
148is set, all operations are performed against the specified file.
149.Ev PATH_FSTAB
150will not be honored if the process environment or memory address space is
151considered
152.Dq tainted .
153(See
154.Xr issetugid 2
155for more information.)
156.El
157.Sh FILES
158.Bl -tag -width /etc/fstab -compact
159.It Pa /etc/fstab
160.El
161.Sh SEE ALSO
162.Xr fstab 5
163.Sh HISTORY
164The
165.Fn getfsent
166function appeared in
167.Bx 4.0 ;
168the
169.Fn endfsent ,
170.Fn getfsfile ,
171.Fn getfsspec ,
172and
173.Fn setfsent
174functions appeared in
175.Bx 4.3 ;
176the
177.Fn setfstab
178and
179.Fn getfstab
180functions appeared in
181.Fx 5.1 .
182.Sh BUGS
183These functions use static data storage;
184if the data is needed for future use, it should be
185copied before any subsequent calls overwrite it.
186