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