Debian Codegraph @

upstream/debian-trixie/man3/getfsent.3

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