Sys::Filesystem(3pm) | User Contributed Perl Documentation | Sys::Filesystem(3pm) |
Sys::Filesystem - Retrieve list of filesystems and their properties
use strict; use Sys::Filesystem (); # Method 1 my $fs = Sys::Filesystem->new(); my @filesystems = $fs->filesystems(); for (@filesystems) { printf("%s is a %s filesystem mounted on %s\n", $fs->mount_point($_), $fs->format($_), $fs->device($_) ); } # Method 2 my $weird_fs = Sys::Filesystem->new( fstab => '/etc/weird/vfstab.conf', mtab => '/etc/active_mounts', xtab => '/etc/nfs/mounts' ); my @weird_filesystems = $weird_fs->filesystems(); # Method 3 (nice but naughty) my @filesystems = Sys::Filesystem->filesystems();
Sys::Filesystem is intended to be a portable interface to list and query filesystem names and their properties. At the time of writing there were only Solaris and Win32 modules available on CPAN to perform this kind of operation. This module hopes to provide a consistent API to list all, mounted, unmounted and special filesystems on a system, and query as many properties as possible with common aliases wherever possible.
Sys::Filesystem ISA UNIVERSAL
$Sys::Filesystem::CANONDEV is used when no key "canondev" is passed.
$Sys::Filesystem::FSTAB is used when no key "fstab" is passed.
$Sys::Filesystem::MTAB is used when no key "mtab" is passed.
None of the OS plugins use that tunable (anymore?), so now a warning is raised when it's used. The entire support will be removed not before 2015. Once that happened, using "xtab" will raise an exception.
For better understanding, please imagine the parameters like:
@fslist = $fs->filesystems( mounted => 1, special => 1 ); # results similar as SELECT mountpoint FROM filesystems WHERE mounted = 1 OR special = 1
If you need other selection choices, please take a look at DBD::Sys.
Valid values are as follows:
my $fdd_filesytem = Sys::Filesystem->filesystems(device => "/dev/fd0");
The mounted_filesystems() method is an alias for this syntax.
The unmounted_filesystems() method is an alias for this syntax.
This parameter is mutually exclusive to "regular".
The special_filesystems() method is an alias for this syntax.
This parameter is mutually exclusive to "special".
The regular_filesystems() method is an alias for this syntax.
Available filesystem properties and their names vary wildly between platforms. Common aliases have been provided wherever possible. You should check the documentation of the specific platform helper module to list all of the properties which are available for that platform. For example, read the Sys::Filesystem::Linux documentation for a list of all filesystem properties available to query under Linux.
This functionality may need to be retrofitted to some original OS specific helper modules as of Sys::Filesystem 1.12.
This functionality may need to be retrofitted to some original OS specific helper modules as of Sys::Filesystem 1.12.
The Dummy module is there to provide a default failover result to the main Sys::Filesystem module if no suitable platform specific module can be found or successfully loaded. This is the last module to be tried, in order of platform, Unix (if not on Win32), and then Dummy.
The Unix module is intended to provide a "best guess" failover result to the main Sys::Filesystem module if no suitable platform specific module can be found, and the platform is not 'MSWin32'.
This module requires additional work to improve it's guestimation abilities.
First written by Christian Renz <crenz@web42.com>.
Provides "mount_point" and "device" of mounted filesystems on Windows.
Please be aware that the AIX /etc/filesystems file has both a "type" and "vfs" field. The "type" field should not be confused with the filesystem format/type (that is stored in the "vfs" field). You may wish to use the "format" field when querying for filesystem types, since it is aliased to be more reliable accross different platforms.
Linux, Solaris, Cygwin, FreeBSD, NetBSD, HP-UX.
The following list is taken from perlport. Please refer to the original source for the most up to date version. This information should help anyone who wishes to write a helper module for a new platform. Modules should have the same name as ^O in title caps. Thus 'openbsd' becomes 'Openbsd.pm'.
Sys::Filesystem requires Perl >= 5.6 to run.
Add support for Tru64, MidnightBSD, Haiku, Minix, DragonflyBSD and OpenBSD. Please contact me if you would like to provide code for these operating systems.
You can find documentation for this module with the perldoc command.
perldoc Sys::Filesystem
You can also look for information at:
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Sys-Filesystem>
<http://annocpan.org/dist/Sys-Filesystem>
<http://cpanratings.perl.org/s/Sys-Filesystem>
<http://search.cpan.org/dist/Sys-Filesystem/>
perlport, Solaris::DeviceTree, Win32::DriveInfo, Sys::Filesystem::MountPoint
Nicola Worthington <nicolaw@cpan.org> - <http://perlgirl.org.uk>
Jens Rehsack <rehsack@cpan.org> - <http://www.rehsack.de/>
See CREDITS in the distribution tarball.
Copyright 2004,2005,2006 Nicola Worthington.
Copyright 2008-2020 Jens Rehsack.
This software is licensed under The Apache Software License, Version 2.0.
<http://www.apache.org/licenses/LICENSE-2.0>
2020-10-24 | perl v5.30.3 |