1GETFSENT(3) Linux Programmer's Manual GETFSENT(3)
2
3
4
6 getfsent, getfsspec, getfsfile, setfsent, endfsent - handle fstab
7 entries
8
10 #include <fstab.h>
11
12 void endfsent(void);
13
14 struct fstab *getfsent(void);
15
16 struct fstab *getfsfile(const char *mount_point);
17
18 struct fstab *getfsspec(const char *special_file);
19
20 int setfsent(void);
21
23 These functions read from the file /etc/fstab. The struct fstab is
24 defined by
25
26 struct fstab {
27 char *fs_spec; /* block device name */
28 char *fs_file; /* mount point */
29 char *fs_vfstype; /* filesystem type */
30 char *fs_mntops; /* mount options */
31 const char *fs_type; /* rw/rq/ro/sw/xx option */
32 int fs_freq; /* dump frequency, in days */
33 int fs_passno; /* pass number on parallel dump */
34 };
35 Here the field fs_type contains (on a *BSD system) one of the five
36 strings "rw", "rq", "ro", "sw", "xx" (read-write, read-write with
37 quota, read-only, swap, ignore).
38
39 The function setfsent() opens the file when required and positions it
40 at the first line.
41
42 The function getfsent() parses the next line from the file. (After
43 opening it when required.)
44
45 The function endfsent() closes the file when required.
46
47 The function getfsspec() searches the file from the start and returns
48 the first entry found for which the fs_spec field matches the spe‐
49 cial_file argument.
50
51 The function getfsfile() searches the file from the start and returns
52 the first entry found for which the fs_file field matches the
53 mount_point argument.
54
56 Upon success, the functions getfsent(), getfsfile(), and getfsspec()
57 return a pointer to a struct fstab, while setfsent() returns 1. Upon
58 failure or end-of-file, these functions return NULL and 0, respec‐
59 tively.
60
62 The getfsent() function appeared in 4.0BSD; the other four functions
63 appeared in 4.3BSD.
64
66 These functions are not in POSIX.1-2001. Several operating systems
67 have them, e.g., *BSD, SunOS, Digital Unix, AIX (which also has a getf‐
68 stype()). HP-UX has functions of the same names, that however use a
69 struct checklist instead of a struct fstab, and calls these functions
70 obsolete, superseded by getmntent(3).
71
73 These functions are not thread-safe.
74
75 Since Linux allows mounting a block special device in several places,
76 and since several devices can have the same mount point, where the last
77 device with a given mount point is the interesting one, while getfs‐
78 file() and getfsspec() only return the first occurrence, these two
79 functions are not suitable for use under Linux.
80
82 getmntent(3), fstab(5)
83
84
85
86Linux 2.5 2002-02-28 GETFSENT(3)