1NAME
2 Sys::Filesystem - Retrieve list of filesystems and their properties
3
4SYNOPSIS
5 use strict;
6 use Sys::Filesystem ();
7
8 # Method 1
9 my $fs = Sys::Filesystem->new();
10 my @filesystems = $fs->filesystems();
11 for (@filesystems)
12 {
13 printf("%s is a %s filesystem mounted on %s\n",
14 $fs->mount_point($_),
15 $fs->format($_),
16 $fs->device($_)
17 );
18 }
19
20 # Method 2
21 my $weird_fs = Sys::Filesystem->new(
22 fstab => '/etc/weird/vfstab.conf',
23 mtab => '/etc/active_mounts',
24 xtab => '/etc/nfs/mounts'
25 );
26 my @weird_filesystems = $weird_fs->filesystems();
27
28 # Method 3 (nice but naughty)
29 my @filesystems = Sys::Filesystem->filesystems();
30
31DESCRIPTION
32 Sys::Filesystem is intended to be a portable interface to list and query
33 filesystem names and their properties. At the time of writing there were
34 only Solaris and Win32 modules available on CPAN to perform this kind of
35 operation. This module hopes to provide a consistent API to list all,
36 mounted, unmounted and special filesystems on a system, and query as
37 many properties as possible with common aliases wherever possible.
38
39INHERITANCE
40 Sys::Filesystem
41 ISA UNIVERSAL
42
43METHODS
44 new Creates a new Sys::Filesystem object. new() accepts 3 optional key
45 pair values to help or force where mount information is gathered
46 from. These values are not otherwise defaulted by the main
47 Sys::Filesystem object, but left to the platform specific helper
48 modules to determine as an exercise of common sense.
49
50 fstab
51 Specify the full path and filename of the filesystem table (or
52 fstab for short).
53
54 mtab
55 Specify the full path and filename of the mounted filesystem
56 table (or mtab for short). Not all platforms have such a file
57 and so this option may be ignored on some systems.
58
59 xtab
60 Specify the full path and filename of the mounted NFS filesystem
61 table (or xtab for short). This is usually only pertinant to
62 Unix bases systems. Not all helper modules will query NFS mounts
63 as a separate exercise, and therefore this option may be ignored
64 on some systems.
65
66 supported
67 Returns true if the operating system is supported by
68 Sys::Filesystem. Unsupported operating systems may get less
69 information, e.g. the mount state couldn't determined or which file
70 system type is special ins't known.
71
72 Listing Filesystems
73 filesystems()
74 Returns a list of all filesystem. May accept an optional list of key
75 pair values in order to filter/restrict the results which are
76 returned. The restrictions are evaluated to match as much as
77 possible, so asking for regular and special file system (or mounted
78 and special file systems), you'll get all.
79
80 For better understanding, please imagine the parameters like:
81
82 @fslist = $fs->filesystems( mounted => 1, special => 1 );
83 # results similar as
84 SELECT mountpoint FROM filesystems WHERE mounted = 1 OR special = 1
85
86 If you need other selection choices, please take a look at DBD::Sys.
87
88 Valid values are as follows:
89
90 device => "string"
91 Returns only filesystems that are mounted using the device of
92 "string". For example:
93
94 my $fdd_filesytem = Sys::Filesystem->filesystems(device => "/dev/fd0");
95
96 mounted => 1
97 Returns only filesystems which can be confirmed as actively
98 mounted. (Filesystems which are mounted).
99
100 The mounted_filesystems() method is an alias for this syntax.
101
102 unmounted => 1
103 Returns only filesystems which cannot be confirmed as actively
104 mounted. (Filesystems which are not mounted).
105
106 The unmounted_filesystems() method is an alias for this syntax.
107
108 special => 1
109 Returns only filesystems which are regarded as special in some
110 way. A filesystem is marked as special by the operating specific
111 helper module. For example, a tmpfs type filesystem on one
112 operating system might be regarded as a special filesystem, but
113 not on others. Consult the documentation of the operating system
114 specific helper module for further information about your
115 system. (Sys::Filesystem::Linux for Linux or
116 Sys::Filesystem::Solaris for Solaris etc).
117
118 This parameter is mutually exclusive to "regular".
119
120 The special_filesystems() method is an alias for this syntax.
121
122 regular => 1
123 Returns only fileystems which are not regarded as special.
124 (Normal filesystems).
125
126 This parameter is mutually exclusive to "special".
127
128 The regular_filesystems() method is an alias for this syntax.
129
130 mounted_filesystems()
131 Returns a list of all filesystems which can be verified as currently
132 being mounted.
133
134 unmounted_filesystems()
135 Returns a list of all filesystems which cannot be verified as
136 currently being mounted.
137
138 special_filesystems()
139 Returns a list of all fileystems which are considered special. This
140 will usually contain meta and swap partitions like /proc and
141 /dev/shm on Linux.
142
143 regular_filesystems()
144 Returns a list of all filesystems which are not considered to be
145 special.
146
147 Filesystem Properties
148 Available filesystem properties and their names vary wildly between
149 platforms. Common aliases have been provided wherever possible. You
150 should check the documentation of the specific platform helper module to
151 list all of the properties which are available for that platform. For
152 example, read the Sys::Filesystem::Linux documentation for a list of all
153 filesystem properties available to query under Linux.
154
155 mount_point() or filesystem()
156 Returns the friendly name of the filesystem. This will usually be
157 the same name as appears in the list returned by the filesystems()
158 method.
159
160 mounted()
161 Returns boolean true if the filesystem is mounted.
162
163 label()
164 Returns the fileystem label.
165
166 This functionality may need to be retrofitted to some original OS
167 specific helper modules as of Sys::Filesystem 1.12.
168
169 volume()
170 Returns the volume that the filesystem belongs to or is mounted on.
171
172 This functionality may need to be retrofitted to some original OS
173 specific helper modules as of Sys::Filesystem 1.12.
174
175 device()
176 Returns the physical device that the filesystem is connected to.
177
178 special()
179 Returns boolean true if the filesystem type is considered "special".
180
181 type() or format()
182 Returns the type of filesystem format. fat32, ntfs, ufs, hpfs, ext3,
183 xfs etc.
184
185 options()
186 Returns the options that the filesystem was mounted with. This may
187 commonly contain information such as read-write, user and group
188 settings and permissions.
189
190 mount_order()
191 Returns the order in which this filesystem should be mounted on
192 boot.
193
194 check_order()
195 Returns the order in which this filesystem should be consistency
196 checked on boot.
197
198 check_frequency()
199 Returns how often this filesystem is checked for consistency.
200
201OS SPECIFIC HELPER MODULES
202 Dummy
203 The Dummy module is there to provide a default failover result to the
204 main Sys::Filesystem module if no suitable platform specific module can
205 be found or successfully loaded. This is the last module to be tried, in
206 order of platform, Unix (if not on Win32), and then Dummy.
207
208 Unix
209 The Unix module is intended to provide a "best guess" failover result to
210 the main Sys::Filesystem module if no suitable platform specific module
211 can be found, and the platform is not 'MSWin32'.
212
213 This module requires additional work to improve it's guestimation
214 abilities.
215
216 Darwin
217 First written by Christian Renz <crenz@web42.com>.
218
219 Win32
220 Provides "mount_point" and "device" of mounted filesystems on Windows.
221
222 AIX
223 Please be aware that the AIX /etc/filesystems file has both a "type" and
224 "vfs" field. The "type" field should not be confused with the filesystem
225 format/type (that is stored in the "vfs" field). You may wish to use the
226 "format" field when querying for filesystem types, since it is aliased
227 to be more reliable accross different platforms.
228
229 Other
230 Linux, Solaris, Cygwin, FreeBSD, NetBSD, HP-UX.
231
232 OS Identifiers
233 The following list is taken from perlport. Please refer to the original
234 source for the most up to date version. This information should help
235 anyone who wishes to write a helper module for a new platform. Modules
236 should have the same name as ^O in title caps. Thus 'openbsd' becomes
237 'Openbsd.pm'.
238
239REQUIREMENTS
240 Sys::Filesystem requires Perl >= 5.6 to run.
241
242TODO
243 Add support for Tru64, MidnightBSD, Haiku, Minix, DragonflyBSD and
244 OpenBSD. Please contact me if you would like to provide code for these
245 operating systems.
246
247SUPPORT
248 You can find documentation for this module with the perldoc command.
249
250 perldoc Sys::Filesystem
251
252 You can also look for information at:
253
254 * RT: CPAN's request tracker
255
256 <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Sys-Filesystem>
257
258 * AnnoCPAN: Annotated CPAN documentation
259
260 <http://annocpan.org/dist/Sys-Filesystem>
261
262 * CPAN Ratings
263
264 <http://cpanratings.perl.org/s/Sys-Filesystem>
265
266 * Search CPAN
267
268 <http://search.cpan.org/dist/Sys-Filesystem/>
269
270SEE ALSO
271 perlport, Solaris::DeviceTree, Win32::DriveInfo
272
273VERSION
274 $Id$
275
276AUTHOR
277 Nicola Worthington <nicolaw@cpan.org> - <http://perlgirl.org.uk>
278
279 Jens Rehsack <rehsack@cpan.org> - <http://www.rehsack.de/>
280
281ACKNOWLEDGEMENTS
282 See CREDITS in the distribution tarball.
283
284COPYRIGHT
285 Copyright 2004,2005,2006 Nicola Worthington.
286
287 Copyright 2008-2013 Jens Rehsack.
288
289 This software is licensed under The Apache Software License, Version
290 2.0.
291
292 <http://www.apache.org/licenses/LICENSE-2.0>
293
294