Sys::Filesystem(3pm)
π¦ Sys::Filesystem π¦
okay so you know how Sys::Filesystem(3pm) lives in the User Contributed Perl Documentation corner of your friendly neighbourhood man pages? yeah. that's this. it's giving "let me tell you everything about every filesystem on your box" and honestly? we're obsessed. π
β¨ NAME β¨
Sys::Filesystem β bestie, it retrieves the list of filesystems and all their lil properties. that's the whole job. π
πΈ SYNOPSIS πΈ
like, here's how you'd actually use it. three whole methods, pick your fighter:
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();
Method 3 is literally labeled "nice but naughty" in the source and you KNOW that's the one everybody runs first. π
π DESCRIPTION π
so Sys::Filesystem is meant to be a portable interface for listing and querying filesystem names and their properties. at the time of writing, there were only Solaris and Win32 modules on CPAN doing this kind of thing, which is, like, so limiting.
this module hopes (it's a hopeful lil module π«Ά) to hand you a consistent API so you can list all, mounted, unmounted and special filesystems on a system, and query as many properties as possible β with common aliases wherever possible. consistency is the vibe. β¨
π INHERITANCE π
Sys::Filesystem
ISA UNIVERSAL
no cap, that's the whole ancestry chart. UNIVERSAL is everybody's grandparent. periodt.
π METHODS π
new
creates a brand new Sys::Filesystem object. slay. new accepts the following optional key/value pairs to help out β or straight up force β where mount info gets gathered from.
heads up bestie: these values are not otherwise defaulted by the main Sys::Filesystem object. they're left to the platform-specific helper modules to figure out as an exercise of common sense. so like, the vibes are delegated. π
canondevβ specify whether device paths shall be resolved when they're a symbolic link. when no keycanondevis passed,$Sys::Filesystem::CANONDEVis used. π«fstabβ specify the full path and filename of the filesystem table (or fstab for short). not all platforms have such a file, so this option may be ignored on some systems. when no keyfstabis passed,$Sys::Filesystem::FSTABis used. ποΈmtabβ specify the full path and filename of the mounted filesystem table (or mtab for short). not all platforms have such a file, so this option may be ignored on some systems. when no keymtabis passed,$Sys::Filesystem::MTABis used. πxtabβ DEPRECIATED. specify the full path and filename of the mounted NFS filesystem table (or xtab for short). this is usually only pertinent to Unix-based systems. not all helper modules will query NFS mounts as a separate exercise, and therefore this option may be ignored on some systems.
π¨ okay this is important: 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 has happened, using xtab will raise an exception. so like, it's on life support. rip bozo. π
aliasesβ overrides the internal aliasing table used to match queries against the OS plugin. this should be used only when dealing with closed source platform helper module(s). you've been warned, don't be messy with it.
supported
returns true if the operating system is supported by Sys::Filesystem. unsupported operating systems may get less information β like, the mount state couldn't be determined, or which file system type is special isn't known. π they're doing their best but the info just isn't there.
π¦ Listing Filesystems π¦
filesystems()
returns a list of all filesystem. (yes, all filesystem, singular-ish, we don't gatekeep grammar here π )
may accept an optional list of key/value pairs to filter/restrict the results returned. and here's the cute part: the restrictions are evaluated to match as much as possible, so if you ask for regular and special file system β or mounted and special file systems β you'll get all of them. it's inclusive. it's an ally. π
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:
device => "string"β returns only filesystems that are mounted using the device of"string". for example:
my $fdd_filesytem = Sys::Filesystem->filesystems(device => "/dev/fd0");
mounted => 1β returns only filesystems which can be confirmed as actively mounted. (filesystems which are mounted.) themounted_filesystems()method is an alias for this syntax. βunmounted => 1β returns only filesystems which cannot be confirmed as actively mounted. (filesystems which are not mounted.) theunmounted_filesystems()method is an alias for this syntax. π«special => 1β returns only filesystems which are regarded as special in some way. a filesystem is marked as special by the operating specific helper module. for example, atmpfstype filesystem on one operating system might be regarded as a special filesystem, but not on others. consult the documentation of the operating system specific helper module for further information about your system. (Sys::Filesystem::Linuxfor Linux orSys::Filesystem::Solarisfor Solaris etc).
this parameter is mutually exclusive to regular. pick a lane bestie, you can't have both.
the special_filesystems() method is an alias for this syntax. β
regular => 1β returns only fileystems which are not regarded as special. (normal filesystems.) this parameter is mutually exclusive tospecial. theregular_filesystems()method is an alias for this syntax. π
mounted_filesystems()
returns a list of all filesystems which can be verified as currently being mounted. π
unmounted_filesystems()
returns a list of all filesystems which cannot be verified as currently being mounted. they're in their off-duty era. π€
special_filesystems()
returns a list of all fileystems which are considered special. this will usually contain meta and swap partitions like /proc and /dev/shm on Linux. β¨
regular_filesystems()
returns a list of all filesystems which are not considered to be special. just vibing. πΈ
π Filesystem Properties π
available filesystem properties and their names vary wildly between platforms. common aliases have been provided wherever possible, because we care. π«Ά
you should check the documentation of the specific platform helper module to list all of the properties available for that platform. for example, read the Sys::Filesystem::Linux documentation for a list of all filesystem properties available to query under Linux. iykyk. π
mount_point()orfilesystem()β returns the friendly name of the filesystem. this will usually be the same name as appears in the list returned by thefilesystems()method. πmounted()β returns boolean true if the filesystem is mounted. βlabel()β returns the fileystem label.
this functionality may need to be retrofitted to some original OS specific helper modules as of Sys::Filesystem 1.12. so like, check before you @ me. π
volume()β returns the volume that the filesystem belongs to or is mounted on.
same disclaimer bestie: this functionality may need to be retrofitted to some original OS specific helper modules as of Sys::Filesystem 1.12. π«
device()β returns the physical device that the filesystem is connected to. πspecial()β returns boolean true if the filesystem type is considered"special". βtype()orformat()β returns the type of filesystem format.fat32,ntfs,ufs,hpfs,ext3,xfsetc. the whole alphabet soup. πoptions()β returns the options that the filesystem was mounted with. this may commonly contain information such as read-write, user and group settings and permissions. πmount_order()β returns the order in which this filesystem should be mounted on boot. 1οΈβ£2οΈβ£3οΈβ£check_order()β returns the order in which this filesystem should be consistency checked on boot. πcheck_frequency()β returns how often this filesystem is checked for consistency. β°
π OS SPECIFIC HELPER MODULES π
π§ Dummy
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. it's the last module to be tried, in order of platform, Unix (if not on Win32), and then Dummy. it's the backup dancer. π
πΈ Unix
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. it's doing its best okay π
π Darwin
first written by Christian Renz <crenz@web42.com>. give credit where credit is due. π«Ά
πͺ Win32
provides mount_point and device of mounted filesystems on Windows. two properties, but they're the useful ones. π
π AIX
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. learn from other people's confusion, bestie.
π¦ Other
Linux, Solaris, Cygwin, FreeBSD, NetBSD, HP-UX. the whole squad. π₯
π OS Identifiers π
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'. π§ β¨
β REQUIREMENTS β
Sys::Filesystem requires Perl >= 5.6 to run. ancient. vintage. iconic. π
π₯ TODO π₯
add support for Tru64, MidnightBSD, Haiku, Minix, DragonflyBSD and OpenBSD. please contact me if you would like to provide code for these operating systems. volunteering is very main character energy, just saying. π
π«Ά SUPPORT π«Ά
you can find documentation for this module with the perldoc command.
perldoc Sys::Filesystem
you can also look for information at:
- RT: CPAN's request tracker β
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Sys-Filesystem> - AnnoCPAN: Annotated CPAN documentation β
<http://annocpan.org/dist/Sys-Filesystem> - CPAN Ratings β
<http://cpanratings.perl.org/s/Sys-Filesystem> - Search CPAN β
<http://search.cpan.org/dist/Sys-Filesystem/>
π SEE ALSO π
perlport, Solaris::DeviceTree, Win32::DriveInfo, Sys::Filesystem::MountPoint
π AUTHOR π
Nicola Worthington <nicolaw@cpan.org> - <http://perlgirl.org.uk>
Jens Rehsack <rehsack@cpan.org> - <http://www.rehsack.de/>
legends, both of them. π«‘
π ACKNOWLEDGEMENTS π
see CREDITS in the distribution tarball. β¨
π COPYRIGHT π
okay so legal era, bestie β gotta give credit where credit is due π
- Copyright 2004,2005,2006 β that's Nicola Worthington π
- Copyright 2008-2020 β and that's Jens Rehske π¦
This software is licensed under The Apache Software License, Version 2.0 β¨
<http://www.apache.org/licenses/LICENSE-2.0>
fr fr, if you're gonna use this, respect the license β it's the bare minimum and it's giving main character integrity π
and that's a wrap on the whole page, bestie π«Ά This one came to you from perl v5.30.3, dated 2020-10-24, filed under Sys::Filesystem(3pm) β go mount something responsibly, ily, bye π
πΈ
π¦ where this page comes from
- debian bookworm: libsys-filesystem-perl 1.408-1 Β· Apache-2.0
- debian trixie: libsys-filesystem-perl 1.408-1 Β· Apache-2.0
- ubuntu jammy: libsys-filesystem-perl 1.408-1 Β· Apache-2.0
- ubuntu noble: libsys-filesystem-perl 1.408-1 Β· Apache-2.0
- ubuntu resolute: libsys-filesystem-perl 1.408-1 Β· Apache-2.0
- ubuntu stonking: libsys-filesystem-perl 1.408-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms