1getfsent(3)                Library Functions Manual                getfsent(3)
2
3
4

NAME

6       getfsent,  getfsspec,  getfsfile, setfsent, endfsent - handle fstab en‐
7       tries
8

LIBRARY

10       Standard C library (libc, -lc)
11

SYNOPSIS

13       #include <fstab.h>
14
15       int setfsent(void);
16       struct fstab *getfsent(void);
17       void endfsent(void);
18
19       struct fstab *getfsfile(const char *mount_point);
20       struct fstab *getfsspec(const char *special_file);
21

DESCRIPTION

23       These functions read from the file /etc/fstab.  The struct fstab is de‐
24       fined 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
36       Here  the  field  fs_type  contains  (on a *BSD system) one of the five
37       strings "rw", "rq",  "ro",  "sw",  "xx"  (read-write,  read-write  with
38       quota, read-only, swap, ignore).
39
40       The  function  setfsent() opens the file when required and positions it
41       at the first line.
42
43       The function getfsent() parses the next line  from  the  file.   (After
44       opening it when required.)
45
46       The function endfsent() closes the file when required.
47
48       The  function  getfsspec() searches the file from the start and returns
49       the first entry found for which the  fs_spec  field  matches  the  spe‐
50       cial_file argument.
51
52       The  function  getfsfile() searches the file from the start and returns
53       the  first  entry  found  for  which  the  fs_file  field  matches  the
54       mount_point argument.
55

RETURN VALUE

57       Upon  success,  the  functions getfsent(), getfsfile(), and getfsspec()
58       return a pointer to a struct fstab, while setfsent() returns  1.   Upon
59       failure  or  end-of-file,  these  functions  return NULL and 0, respec‐
60       tively.
61

ATTRIBUTES

63       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
64       tributes(7).
65
66       ┌─────────────┬───────────────┬────────────────────────────────────────┐
67Interface    Attribute     Value                                  
68       ├─────────────┼───────────────┼────────────────────────────────────────┤
69endfsent(),  │ Thread safety │ MT-Unsafe race:fsent                   │
70setfsent()   │               │                                        │
71       ├─────────────┼───────────────┼────────────────────────────────────────┤
72getfsent(),  │ Thread safety │ MT-Unsafe race:fsent locale            │
73getfsspec(), │               │                                        │
74getfsfile()  │               │                                        │
75       └─────────────┴───────────────┴────────────────────────────────────────┘
76

VERSIONS

78       Several operating systems have  these  functions,  for  example,  *BSD,
79       SunOS,  Digital  UNIX,  AIX  (which also has a getfstype()).  HP-UX has
80       functions of the same names, that however use a  struct  checklist  in‐
81       stead of a struct fstab, and calls these functions obsolete, superseded
82       by getmntent(3).
83

STANDARDS

85       None.
86

HISTORY

88       The getfsent() function appeared in 4.0BSD; the  other  four  functions
89       appeared in 4.3BSD.
90

NOTES

92       These functions are not thread-safe.
93
94       Since  Linux  allows mounting a block special device in several places,
95       and since several devices can have the same mount point, where the last
96       device  with  a  given mount point is the interesting one, while getfs‐
97       file() and getfsspec() only return  the  first  occurrence,  these  two
98       functions are not suitable for use under Linux.
99

SEE ALSO

101       getmntent(3), fstab(5)
102
103
104
105Linux man-pages 6.04              2023-03-30                       getfsent(3)
Impressum