]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man/man3/getfsent.3
man/, share/mk/: Move man*/ to man/
[thirdparty/man-pages.git] / man / man3 / getfsent.3
CommitLineData
a1eaacb1 1'\" t
fea681da
MK
2.\" Copyright (C) 2002 Andries Brouwer (aeb@cwi.nl)
3.\"
5fbde956 4.\" SPDX-License-Identifier: Linux-man-pages-copyleft
fea681da
MK
5.\"
6.\" Inspired by a page written by Walter Harms.
7.\"
4c1c5274 8.TH getfsent 3 (date) "Linux man-pages (unreleased)"
fea681da
MK
9.SH NAME
10getfsent, getfsspec, getfsfile, setfsent, endfsent \- handle fstab entries
42009080
AC
11.SH LIBRARY
12Standard C library
13.RI ( libc ", " \-lc )
fea681da 14.SH SYNOPSIS
15d65653 15.nf
fea681da 16.B #include <fstab.h>
c6d039a3 17.P
15d65653 18.B "int setfsent(void);"
0daa9e92 19.B "struct fstab *getfsent(void);"
15d65653 20.B "void endfsent(void);"
c6d039a3 21.P
fea681da 22.BI "struct fstab *getfsfile(const char *" mount_point );
fea681da 23.BI "struct fstab *getfsspec(const char *" special_file );
15d65653 24.fi
fea681da
MK
25.SH DESCRIPTION
26These functions read from the file
27.IR /etc/fstab .
c9942389 28The
1ae6b2c7 29.I struct fstab
c9942389 30is defined by:
c6d039a3 31.P
088a639b 32.in +4n
b8302363 33.EX
fea681da 34struct fstab {
296d592b
MK
35 char *fs_spec; /* block device name */
36 char *fs_file; /* mount point */
feaef5f2 37 char *fs_vfstype; /* filesystem type */
296d592b
MK
38 char *fs_mntops; /* mount options */
39 const char *fs_type; /* rw/rq/ro/sw/xx option */
40 int fs_freq; /* dump frequency, in days */
41 int fs_passno; /* pass number on parallel dump */
fea681da 42};
b8302363 43.EE
296d592b 44.in
c6d039a3 45.P
fea681da
MK
46Here the field
47.I fs_type
48contains (on a *BSD system)
49one of the five strings "rw", "rq", "ro", "sw", "xx"
50(read-write, read-write with quota, read-only, swap, ignore).
c6d039a3 51.P
fea681da 52The function
63aa9df0 53.BR setfsent ()
fea681da 54opens the file when required and positions it at the first line.
c6d039a3 55.P
fea681da 56The function
63aa9df0 57.BR getfsent ()
fea681da
MK
58parses the next line from the file.
59(After opening it when required.)
c6d039a3 60.P
fea681da 61The function
63aa9df0 62.BR endfsent ()
fea681da 63closes the file when required.
c6d039a3 64.P
fea681da 65The function
63aa9df0 66.BR getfsspec ()
fea681da
MK
67searches the file from the start and returns the first entry found
68for which the
69.I fs_spec
70field matches the
71.I special_file
72argument.
c6d039a3 73.P
fea681da 74The function
63aa9df0 75.BR getfsfile ()
fea681da
MK
76searches the file from the start and returns the first entry found
77for which the
78.I fs_file
79field matches the
80.I mount_point
81argument.
47297adb 82.SH RETURN VALUE
fea681da 83Upon success, the functions
63aa9df0
MK
84.BR getfsent (),
85.BR getfsfile (),
fea681da 86and
63aa9df0 87.BR getfsspec ()
c9942389
MK
88return a pointer to a
89.IR "struct fstab" ,
90while
63aa9df0 91.BR setfsent ()
fea681da
MK
92returns 1.
93Upon failure or end-of-file, these functions return NULL and 0, respectively.
a93d3fc0
PH
94.SH ATTRIBUTES
95For an explanation of the terms used in this section, see
96.BR attributes (7).
97.TS
98allbox;
b32feea5 99lb lb lbx
a93d3fc0
PH
100l l l.
101Interface Attribute Value
102T{
9e54434e
BR
103.na
104.nh
a93d3fc0 105.BR endfsent (),
3b399480 106.BR setfsent ()
b32feea5 107T} Thread safety T{
9e54434e
BR
108.na
109.nh
b32feea5
MK
110MT-Unsafe race:fsent
111T}
3b399480 112T{
9e54434e
BR
113.na
114.nh
3b399480 115.BR getfsent (),
a93d3fc0
PH
116.BR getfsspec (),
117.BR getfsfile ()
b32feea5 118T} Thread safety T{
9e54434e
BR
119.na
120.nh
b32feea5
MK
121MT-Unsafe race:fsent locale
122T}
a93d3fc0 123.TE
4131356c
AC
124.SH VERSIONS
125Several operating systems have these functions, for example,
10850212 126*BSD, SunOS, Digital UNIX, AIX (which also has a
31e9a9ec 127.BR getfstype ()).
0c2ec4f1 128HP-UX has functions of the same names,
c9942389 129that however use a
1ae6b2c7 130.I struct checklist
c9942389
MK
131instead of a
132.IR "struct fstab" ,
0c2ec4f1 133and calls these functions obsolete, superseded by
fea681da 134.BR getmntent (3).
4131356c
AC
135.SH STANDARDS
136None.
137.SH HISTORY
138The
139.BR getfsent ()
140function appeared in 4.0BSD; the other four functions appeared in 4.3BSD.
fea681da
MK
141.SH NOTES
142These functions are not thread-safe.
c6d039a3 143.P
fea681da
MK
144Since Linux allows mounting a block special device in several places,
145and since several devices can have the same mount point, where the
146last device with a given mount point is the interesting one,
147while
63aa9df0 148.BR getfsfile ()
fea681da 149and
63aa9df0 150.BR getfsspec ()
fea681da
MK
151only return the first occurrence, these two functions are not suitable
152for use under Linux.
47297adb 153.SH SEE ALSO
fea681da
MK
154.BR getmntent (3),
155.BR fstab (5)