Debian Codegraph @

upstream/debian-unstable/man3/getfsent.3

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