]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/getfsent.3
proc.5: Note kernel version for /proc/PID/smaps VmFlags "wf" flag
[thirdparty/man-pages.git] / man3 / getfsent.3
1 .\" Copyright (C) 2002 Andries Brouwer (aeb@cwi.nl)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" Inspired by a page written by Walter Harms.
26 .\"
27 .TH GETFSENT 3 2017-09-15 "GNU" "Linux Programmer's Manual"
28 .SH NAME
29 getfsent, getfsspec, getfsfile, setfsent, endfsent \- handle fstab entries
30 .SH SYNOPSIS
31 .B #include <fstab.h>
32 .PP
33 .B "void endfsent(void);"
34 .PP
35 .B "struct fstab *getfsent(void);"
36 .PP
37 .BI "struct fstab *getfsfile(const char *" mount_point );
38 .PP
39 .BI "struct fstab *getfsspec(const char *" special_file );
40 .PP
41 .B "int setfsent(void);"
42 .SH DESCRIPTION
43 These functions read from the file
44 .IR /etc/fstab .
45 The
46 .IR "struct fstab"
47 is defined by:
48 .PP
49 .in +4n
50 .EX
51 struct fstab {
52 char *fs_spec; /* block device name */
53 char *fs_file; /* mount point */
54 char *fs_vfstype; /* file-system type */
55 char *fs_mntops; /* mount options */
56 const char *fs_type; /* rw/rq/ro/sw/xx option */
57 int fs_freq; /* dump frequency, in days */
58 int fs_passno; /* pass number on parallel dump */
59 };
60 .EE
61 .in
62 .PP
63 Here the field
64 .I fs_type
65 contains (on a *BSD system)
66 one of the five strings "rw", "rq", "ro", "sw", "xx"
67 (read-write, read-write with quota, read-only, swap, ignore).
68 .PP
69 The function
70 .BR setfsent ()
71 opens the file when required and positions it at the first line.
72 .PP
73 The function
74 .BR getfsent ()
75 parses the next line from the file.
76 (After opening it when required.)
77 .PP
78 The function
79 .BR endfsent ()
80 closes the file when required.
81 .PP
82 The function
83 .BR getfsspec ()
84 searches the file from the start and returns the first entry found
85 for which the
86 .I fs_spec
87 field matches the
88 .I special_file
89 argument.
90 .PP
91 The function
92 .BR getfsfile ()
93 searches the file from the start and returns the first entry found
94 for which the
95 .I fs_file
96 field matches the
97 .I mount_point
98 argument.
99 .SH RETURN VALUE
100 Upon success, the functions
101 .BR getfsent (),
102 .BR getfsfile (),
103 and
104 .BR getfsspec ()
105 return a pointer to a
106 .IR "struct fstab" ,
107 while
108 .BR setfsent ()
109 returns 1.
110 Upon failure or end-of-file, these functions return NULL and 0, respectively.
111 .\" .SH HISTORY
112 .\" The
113 .\" .BR getfsent ()
114 .\" function appeared in 4.0BSD; the other four functions appeared in 4.3BSD.
115 .SH ATTRIBUTES
116 For an explanation of the terms used in this section, see
117 .BR attributes (7).
118 .TS
119 allbox;
120 lb lb lbw24
121 l l l.
122 Interface Attribute Value
123 T{
124 .BR endfsent (),
125 .br
126 .BR setfsent ()
127 T} Thread safety MT-Unsafe race:fsent
128 T{
129 .BR getfsent (),
130 .br
131 .BR getfsspec (),
132 .br
133 .BR getfsfile ()
134 T} Thread safety MT-Unsafe race:fsent locale
135 .TE
136 .SH CONFORMING TO
137 These functions are not in POSIX.1.
138 Several operating systems have them, for example,
139 *BSD, SunOS, Digital UNIX, AIX (which also has a
140 .BR getfstype ()).
141 HP-UX has functions of the same names,
142 that however use a
143 .IR "struct checklist"
144 instead of a
145 .IR "struct fstab" ,
146 and calls these functions obsolete, superseded by
147 .BR getmntent (3).
148 .SH NOTES
149 These functions are not thread-safe.
150 .PP
151 Since Linux allows mounting a block special device in several places,
152 and since several devices can have the same mount point, where the
153 last device with a given mount point is the interesting one,
154 while
155 .BR getfsfile ()
156 and
157 .BR getfsspec ()
158 only return the first occurrence, these two functions are not suitable
159 for use under Linux.
160 .SH SEE ALSO
161 .BR getmntent (3),
162 .BR fstab (5)