Salvador Fandiño García > Linux-Proc-Mounts-0.02 > Linux::Proc::Mounts



Annotate this POD


Open  0
View/Report Bugs
Module Version: 0.02   Source  


Linux::Proc::Mounts - Parser for Linux /proc/mounts


  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);


Linux::Proc::Mounts parses the mount points information provided by the Linux kernel at /proc/mounts.


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:

mnt => $proc

Overrides the default mount point for the procfs at /proc.

pid => $pid

Reads /proc/$pid/mounts instead of /proc/mounts.

file => $filename

Reads the file with the given name.


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 (/).


Returns a new object containing the list of file systems mounted at or under the given path.


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:


Returns the fs_spec field describing the block special device or remote filesystem mounted.


Returns the fs_file field describing the mount point for the filesystem.


Returns the fs_vfstype field describing the type of the filesystem.


Returns the fs_mntopts field describing the mount options associated with the filesystem.


Returns the fs_mntopts field as a hash.


Returns a true value when the filesystem has been mounted as read only.


Returns a true value when the filesystem has been mounted as read/write.


Returns the line number of the entry inside the /proc/mounts file.


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.


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.


Salvador Fandiño (


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.

syntax highlighting: