NAME
Linux::Proc::Mounts - Parser for Linux /proc/mounts
SYNOPSIS
use Linux::Proc::Mounts;
my $m = Linux::Proc::Mounts->read;
my $at = $m->at('/');
say $_->spec . ' is mounted at /' for (@$at);
my $under = $m->under('/sys');
say $_->spec . ' is under /sys as ' . $_->file for (@$under);
DESCRIPTION
Linux::Proc::Mounts parses the mount points information provided by the Linux kernel at /proc/mounts
.
API
The Linux::Proc::Mounts class
The internal representation of the class is an array whose entries can be accessed directly unreferencing it. For instance:
my $mnts = Linux::Proc::Mount->read;
for my $e (@$mnts) {
say $e->spec . " is mounted at " . $e->file . " as " . $e->fstype;
}
The methods accepted by the class are as follows:
- $mnts = Linux::Proc::Mounts->read
- $mnts = Linux::Proc::Mounts->read(%opts)
-
Reads
/proc/mounts
and returns a new object representing the data there.The currently supported options are as follows:
- $mnts->at($path)
-
Returns a new object containing the list of file systems mounted at the given path.
If no file system is mounted at the given point an object containing an empty list will be returned. For instance:
my $at = $mnts->at('/foo'); say "no file systems are mounted at /foo" unless @$at;
Note than, more than one file system can be mounted in the same place. For instance, this happens frequently for the root filesystem (
/
). - $mnts->under($path)
-
Returns a new object containing the list of file systems mounted at or under the given path.
- $mnts->visible
-
Filter out the mount points that are hidden below later mounts.
The Linux::Proc::Mounts::Entry class
This is the class used to represent single mount points.
The methods provided are as follows:
- $e->spec
-
Returns the fs_spec field describing the block special device or remote filesystem mounted.
- $e->file
-
Returns the fs_file field describing the mount point for the filesystem.
- $e->fstype
-
Returns the fs_vfstype field describing the type of the filesystem.
- $e->opts
-
Returns the fs_mntopts field describing the mount options associated with the filesystem.
- $e->opts_hash
-
Returns the fs_mntopts field as a hash.
- $e->is_ro
-
Returns a true value when the filesystem has been mounted as read only.
- $e->is_rw
-
Returns a true value when the filesystem has been mounted as read/write.
- $e->ix
-
Returns the line number of the entry inside the /proc/mounts file.
- $e->shadower
-
When the filesystem is hiden behind a later mount performed at the same path. This method returns the entry of the filesystem shadowing it.
Note that some mount may also be hidden by a latter mount performed over some parent directory, but the information available from /proc/mounts does not allow to detect that condition.
Note that there are no methods to get the fs_freq and fs_passno fields as the kernel those not store then internally and the corresponding entries in /proc/mounts are always 0 and so, useless.
SEE ALSO
fstab(5) describes the format of the /proc/mounts file.
mount(8) describes the filesystems and the options accepted.
Linux::Proc::Mountinfo. The information offered by the Linux kernel through /proc/$pid/mountinfo
is more detailed so you should probably use that module instead of Linux::Proc::Mounts.
Sys::Filesystem provides similar functionality to this module and support most common operating systems.
AUTHOR
Salvador Fandiño (sfandino@yahoo.com)
COPYRIGHT AND LICENSE
Copyright (C) 2012 by Qindel Formación y Servicios S.L.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 279:
Non-ASCII character seen before =encoding in 'Formación'. Assuming UTF-8