For some programs it is desirable and necessary to access information about whether a certain filesystem is mounted and, if it is, where, or simply to get lists of all the available filesystems. The GNU libc provides some functions to retrieve this information portably.
Traditionally Unix systems have a file named `/etc/fstab' which
describes all possibly mounted filesystems. The mount
program
uses this file to mount at startup time of the system all the necessary
filesystems. The information about all the filesystems actually mounted
is normally kept in a file named `/etc/mtab'. Both files share
the same syntax and it is crucial that this syntax is followed all the
time. Therefore it is best to never directly write the files. The
functions described in this section can do this and they also provide
the functionality to convert the external textual representation to the
internal representation.
Note that the `fstab' and `mtab' files are maintained on a system by convention. It is possible for the files not to exist or not to be consistent with what is really mounted or available to mount, if the system's administration policy allows it. But programs that mount and unmount filesystems typically maintain and use these files as described herein.
The filenames given above should never be used directly. The portable
way to handle these file is to use the macros _PATH_FSTAB
,
defined in `fstab.h' and _PATH_MNTTAB
, defined in
`mntent.h', respectively. There are also two alternate macro names
FSTAB
and _PATH_MOUNTED
defined but both names are
deprecated and kept only for backward compatibility. The two former
names should always be used.
Go to the first, previous, next, last section, table of contents.