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

NAME

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

SYNOPSIS

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

DESCRIPTION

20       These functions read from the file /etc/fstab.  The struct fstab is de‐
21       fined by:
22
23           struct fstab {
24               char       *fs_spec;       /* block device name */
25               char       *fs_file;       /* mount point */
26               char       *fs_vfstype;    /* filesystem type */
27               char       *fs_mntops;     /* mount options */
28               const char *fs_type;       /* rw/rq/ro/sw/xx option */
29               int         fs_freq;       /* dump frequency, in days */
30               int         fs_passno;     /* pass number on parallel dump */
31           };
32
33       Here  the  field  fs_type  contains  (on a *BSD system) one of the five
34       strings "rw", "rq",  "ro",  "sw",  "xx"  (read-write,  read-write  with
35       quota, read-only, swap, ignore).
36
37       The  function  setfsent() opens the file when required and positions it
38       at the first line.
39
40       The function getfsent() parses the next line  from  the  file.   (After
41       opening it when required.)
42
43       The function endfsent() closes the file when required.
44
45       The  function  getfsspec() searches the file from the start and returns
46       the first entry found for which the  fs_spec  field  matches  the  spe‐
47       cial_file argument.
48
49       The  function  getfsfile() searches the file from the start and returns
50       the  first  entry  found  for  which  the  fs_file  field  matches  the
51       mount_point argument.
52

RETURN VALUE

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

ATTRIBUTES

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

CONFORMING TO

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

NOTES

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

SEE ALSO

91       getmntent(3), fstab(5)
92

COLOPHON

94       This page is part of release 5.12 of the Linux  man-pages  project.   A
95       description  of  the project, information about reporting bugs, and the
96       latest    version    of    this    page,    can     be     found     at
97       https://www.kernel.org/doc/man-pages/.
98
99
100
101GNU                               2021-03-22                       GETFSENT(3)
Impressum