getmntent - Linux
Overview
getmntent
reads a file containing entries describing mounted filesystems and returns an entry for each mounted filesystem. The file containing the entries can be specified, if not then /etc/mtab
is read.
Syntax
getmntent [FILE]
Options/Flags
- -a: Access time of the mounted filesystem.
- -b: Block size for the mounted filesystem.
- -f: Full path to the file containing the entries.
- -h: Display usage information.
- -i: Inode number of the mounted filesystem.
- -n: Filesystem name.
- -o: Options string for the mounted filesystem.
- -p: Physical path of the mounted filesystem.
- -r: Read the entries from STDIN.
- -s: Size of the mounted filesystem.
- -t: Filesystem type.
Examples
To list all mounted filesystems:
getmntent
To list the mount point and type of all mounted filesystems:
getmntent -nf /
To read the entries from a specific file:
getmntent -f /path/to/file
Common Issues
- Error opening file: Ensure that the specified file has the correct permissions and is accessible.
- Invalid entry: If an entry in the file is invalid,
getmntent
may skip it or terminate with an error.
Integration
getmntent
can be used in shell scripts or programs to obtain information about mounted filesystems. For example, it can be used to:
- Display a list of mounted filesystems.
- Determine the mount point of a specific filesystem.
- Check the availability of a filesystem.
Related Commands
mount
umount
fstab