]>
Commit | Line | Data |
---|---|---|
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 |
10 | getfsent, getfsspec, getfsfile, setfsent, endfsent \- handle fstab entries | |
42009080 AC |
11 | .SH LIBRARY |
12 | Standard 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 |
26 | These functions read from the file | |
27 | .IR /etc/fstab . | |
c9942389 | 28 | The |
1ae6b2c7 | 29 | .I struct fstab |
c9942389 | 30 | is defined by: |
c6d039a3 | 31 | .P |
088a639b | 32 | .in +4n |
b8302363 | 33 | .EX |
fea681da | 34 | struct 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 |
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). | |
c6d039a3 | 51 | .P |
fea681da | 52 | The function |
63aa9df0 | 53 | .BR setfsent () |
fea681da | 54 | opens the file when required and positions it at the first line. |
c6d039a3 | 55 | .P |
fea681da | 56 | The function |
63aa9df0 | 57 | .BR getfsent () |
fea681da MK |
58 | parses the next line from the file. |
59 | (After opening it when required.) | |
c6d039a3 | 60 | .P |
fea681da | 61 | The function |
63aa9df0 | 62 | .BR endfsent () |
fea681da | 63 | closes the file when required. |
c6d039a3 | 64 | .P |
fea681da | 65 | The function |
63aa9df0 | 66 | .BR getfsspec () |
fea681da MK |
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. | |
c6d039a3 | 73 | .P |
fea681da | 74 | The function |
63aa9df0 | 75 | .BR getfsfile () |
fea681da MK |
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. | |
47297adb | 82 | .SH RETURN VALUE |
fea681da | 83 | Upon success, the functions |
63aa9df0 MK |
84 | .BR getfsent (), |
85 | .BR getfsfile (), | |
fea681da | 86 | and |
63aa9df0 | 87 | .BR getfsspec () |
c9942389 MK |
88 | return a pointer to a |
89 | .IR "struct fstab" , | |
90 | while | |
63aa9df0 | 91 | .BR setfsent () |
fea681da MK |
92 | returns 1. |
93 | Upon failure or end-of-file, these functions return NULL and 0, respectively. | |
a93d3fc0 PH |
94 | .SH ATTRIBUTES |
95 | For an explanation of the terms used in this section, see | |
96 | .BR attributes (7). | |
97 | .TS | |
98 | allbox; | |
b32feea5 | 99 | lb lb lbx |
a93d3fc0 PH |
100 | l l l. |
101 | Interface Attribute Value | |
102 | T{ | |
9e54434e BR |
103 | .na |
104 | .nh | |
a93d3fc0 | 105 | .BR endfsent (), |
3b399480 | 106 | .BR setfsent () |
b32feea5 | 107 | T} Thread safety T{ |
9e54434e BR |
108 | .na |
109 | .nh | |
b32feea5 MK |
110 | MT-Unsafe race:fsent |
111 | T} | |
3b399480 | 112 | T{ |
9e54434e BR |
113 | .na |
114 | .nh | |
3b399480 | 115 | .BR getfsent (), |
a93d3fc0 PH |
116 | .BR getfsspec (), |
117 | .BR getfsfile () | |
b32feea5 | 118 | T} Thread safety T{ |
9e54434e BR |
119 | .na |
120 | .nh | |
b32feea5 MK |
121 | MT-Unsafe race:fsent locale |
122 | T} | |
a93d3fc0 | 123 | .TE |
4131356c AC |
124 | .SH VERSIONS |
125 | Several operating systems have these functions, for example, | |
10850212 | 126 | *BSD, SunOS, Digital UNIX, AIX (which also has a |
31e9a9ec | 127 | .BR getfstype ()). |
0c2ec4f1 | 128 | HP-UX has functions of the same names, |
c9942389 | 129 | that however use a |
1ae6b2c7 | 130 | .I struct checklist |
c9942389 MK |
131 | instead of a |
132 | .IR "struct fstab" , | |
0c2ec4f1 | 133 | and calls these functions obsolete, superseded by |
fea681da | 134 | .BR getmntent (3). |
4131356c AC |
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. | |
fea681da MK |
141 | .SH NOTES |
142 | These functions are not thread-safe. | |
c6d039a3 | 143 | .P |
fea681da MK |
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 | |
63aa9df0 | 148 | .BR getfsfile () |
fea681da | 149 | and |
63aa9df0 | 150 | .BR getfsspec () |
fea681da MK |
151 | only return the first occurrence, these two functions are not suitable |
152 | for use under Linux. | |
47297adb | 153 | .SH SEE ALSO |
fea681da MK |
154 | .BR getmntent (3), |
155 | .BR fstab (5) |