Changes: Ready for 5.13
[man-pages.git] / man3 / getfsent.3
blob34ae547d93e6a8df47a54be10ee46f482e1dd98d
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 2021-03-22 "GNU" "Linux Programmer's Manual"
28 .SH NAME
29 getfsent, getfsspec, getfsfile, setfsent, endfsent \- handle fstab entries
30 .SH SYNOPSIS
31 .nf
32 .B #include <fstab.h>
33 .PP
34 .B "int setfsent(void);"
35 .B "struct fstab *getfsent(void);"
36 .B "void endfsent(void);"
37 .PP
38 .BI "struct fstab *getfsfile(const char *" mount_point );
39 .BI "struct fstab *getfsspec(const char *" special_file );
40 .fi
41 .SH DESCRIPTION
42 These functions read from the file
43 .IR /etc/fstab .
44 The
45 .IR "struct fstab"
46 is defined by:
47 .PP
48 .in +4n
49 .EX
50 struct fstab {
51     char       *fs_spec;       /* block device name */
52     char       *fs_file;       /* mount point */
53     char       *fs_vfstype;    /* filesystem type */
54     char       *fs_mntops;     /* mount options */
55     const char *fs_type;       /* rw/rq/ro/sw/xx option */
56     int         fs_freq;       /* dump frequency, in days */
57     int         fs_passno;     /* pass number on parallel dump */
59 .EE
60 .in
61 .PP
62 Here the field
63 .I fs_type
64 contains (on a *BSD system)
65 one of the five strings "rw", "rq", "ro", "sw", "xx"
66 (read-write, read-write with quota, read-only, swap, ignore).
67 .PP
68 The function
69 .BR setfsent ()
70 opens the file when required and positions it at the first line.
71 .PP
72 The function
73 .BR getfsent ()
74 parses the next line from the file.
75 (After opening it when required.)
76 .PP
77 The function
78 .BR endfsent ()
79 closes the file when required.
80 .PP
81 The function
82 .BR getfsspec ()
83 searches the file from the start and returns the first entry found
84 for which the
85 .I fs_spec
86 field matches the
87 .I special_file
88 argument.
89 .PP
90 The function
91 .BR getfsfile ()
92 searches the file from the start and returns the first entry found
93 for which the
94 .I fs_file
95 field matches the
96 .I mount_point
97 argument.
98 .SH RETURN VALUE
99 Upon success, the functions
100 .BR getfsent (),
101 .BR getfsfile (),
103 .BR getfsspec ()
104 return a pointer to a
105 .IR "struct fstab" ,
106 while
107 .BR setfsent ()
108 returns 1.
109 Upon failure or end-of-file, these functions return NULL and 0, respectively.
110 .\" .SH HISTORY
111 .\" The
112 .\" .BR getfsent ()
113 .\" function appeared in 4.0BSD; the other four functions appeared in 4.3BSD.
114 .SH ATTRIBUTES
115 For an explanation of the terms used in this section, see
116 .BR attributes (7).
117 .ad l
120 allbox;
121 lb lb lbx
122 l l l.
123 Interface       Attribute       Value
125 .BR endfsent (),
126 .BR setfsent ()
127 T}      Thread safety   T{
128 MT-Unsafe race:fsent
131 .BR getfsent (),
132 .BR getfsspec (),
133 .BR getfsfile ()
134 T}      Thread safety   T{
135 MT-Unsafe race:fsent locale
140 .sp 1
141 .SH CONFORMING TO
142 These functions are not in POSIX.1.
143 Several operating systems have them, for example,
144 *BSD, SunOS, Digital UNIX, AIX (which also has a
145 .BR getfstype ()).
146 HP-UX has functions of the same names,
147 that however use a
148 .IR "struct checklist"
149 instead of a
150 .IR "struct fstab" ,
151 and calls these functions obsolete, superseded by
152 .BR getmntent (3).
153 .SH NOTES
154 These functions are not thread-safe.
156 Since Linux allows mounting a block special device in several places,
157 and since several devices can have the same mount point, where the
158 last device with a given mount point is the interesting one,
159 while
160 .BR getfsfile ()
162 .BR getfsspec ()
163 only return the first occurrence, these two functions are not suitable
164 for use under Linux.
165 .SH SEE ALSO
166 .BR getmntent (3),
167 .BR fstab (5)