xref: /netbsd-src/lib/libc/gen/getfsent.3 (revision 9dbf303bcbfb6c4577590e249a7cb55f24341edc)
1.\"	$NetBSD: getfsent.3,v 1.12 2012/04/07 03:47:30 christos Exp $
2.\"
3.\" Copyright (c) 1983, 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\"     @(#)getfsent.3	8.1 (Berkeley) 6/4/93
31.\"
32.Dd March 6, 2012
33.Dt GETFSENT 3
34.Os
35.Sh NAME
36.Nm getfsent ,
37.Nm getfsspec ,
38.Nm getfsfile ,
39.Nm setfsent ,
40.Nm endfsent
41.Nd get file system descriptor file entry
42.Sh LIBRARY
43.Lb libc
44.Sh SYNOPSIS
45.In fstab.h
46.Ft struct 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.In 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 getfsspecname 3 ,
132.Xr fstab 5
133.Sh HISTORY
134The
135.Fn getfsent
136function appeared in
137.Bx 4.0 ;
138the
139.Fn endfsent ,
140.Fn getfsfile ,
141.Fn getfsspec ,
142and
143.Fn setfsent
144functions appeared in
145.Bx 4.3 .
146.Sh BUGS
147These functions use static data storage;
148if the data is needed for future use, it should be
149copied before any subsequent calls overwrite it.
150