1GETFSENT(3)                Linux Programmer's Manual               GETFSENT(3)
2
3
4

NAME

6       getfsent,  getfsspec,  getfsfile,  setfsent,  endfsent  -  handle fstab
7       entries
8

SYNOPSIS

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

DESCRIPTION

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;    /* file-system 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
64       attributes(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       └─────────────┴───────────────┴─────────────────────────────┘

CONFORMING TO

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

NOTES

84       These functions are not thread-safe.
85
86       Since  Linux  allows mounting a block special device in several places,
87       and since several devices can have the same mount point, where the last
88       device  with  a  given mount point is the interesting one, while getfs‐
89       file() and getfsspec() only return  the  first  occurrence,  these  two
90       functions are not suitable for use under Linux.
91

SEE ALSO

93       getmntent(3), fstab(5)
94

COLOPHON

96       This  page  is  part of release 5.04 of the Linux man-pages project.  A
97       description of the project, information about reporting bugs,  and  the
98       latest     version     of     this    page,    can    be    found    at
99       https://www.kernel.org/doc/man-pages/.
100
101
102
103GNU                               2017-09-15                       GETFSENT(3)
Impressum