The File_Fstab_Entry class represents all the information available about a particular entry in a Fstab file.
The entry has a number of properties which represent the information in the fstab file.
This is the path to the block device for this entry. $device, $uuid, and $label are mutually exclusive; only one of the three may be set.
The UUID of the device.
The label for this device.
The directory this device is mounted on.
The type of filesystem on $device.
Array of mount options for this device.
How often / if this filesystem should be backed up by dump.
Order of / if this device should be checked by fsck when the system boots.
You may want to read fstab(5) for more information about what these fields mean.
There are a number of ways of finding a specific entry from the fstab. You may find based on device, mountpoint, filesystem label, or UUID.
To find by device, you want to use the getEntryForDevice() function. The single argument this function accepts is the path to the block device for an entry.
Example 43-1. Get entry by device
You may want to find a device based on the path it is mounted on; for example, you may want to get the entry for /cdrom, without caring if the CD device is /dev/hdb, /dev/cdrom, or some other device. To do this, use the getEntryForPath() function.
Example 43-2. Get entry by path
Some systems use a filesystem UUID to specify the device to mount. A UUID may look like this: b46ad2ee-01f3-4041-96ca-91d35d059417. The getEntryForUUID() function handles this.
Example 43-3. Get entry by UUID
Some filesystems allow you to specify a textual label to a filesystem. For example, you may label your root device rootdev, the device you mount on /home could be named homedirs and so forth. File_Fstab supports getting entries based on the device label. This is accomplished by using the getEntryForLabel() function.
Example 43-4. Get entry by label
In addition to reading fstab files, you may modify them as well.
Example 43-5. Add an entry for a floppy disk