Debian Codegraph @

README

raw
1 INSTALL
2 TO INSTALL RUN:
3
4 perl Makefile.PL
5 make
6 make test
7 make install
8
9
10 During the build process, the makefile will try to figure out which
11 system calls to use to obtain filesystem information. It will look
12 for statvfs() first via the Config module and a include directory
13 search. If it locates statvfs(), it will assume the system also has
14 fstatvfs(). If it cannot find statvfs(), it will then begin the same
15 search for statfs(). If statfs() is found it will assume fstatfs()
16 is also available.
17
18 During the 'make test', test.pl will try to test with '/' and then
19 open test.pl in the current directory and use that for a filehandle
20 test.
21
22 Once installed, run 'perldoc Filesys::Df' for more information.
23
24 If you have any problems or questions please email me at [email protected]
25 with "Filesys::Df" in the subject line. If you run into a build problem,
26 please include the output of the install commands, the version of Perl
27 you are using (perl -v), and what operating system you are using.
28
29
30 Module Documentation:
31 This distribution contains the module Filesys::Df
32
33 Filesys::Df - Perl extension for filesystem disk space information.
34
35 SYNOPSIS
36
37 use Filesys::Df;
38
39 #### Get information by passing a scalar directory/filename value
40 my $ref = df("/tmp"); # Default output is 1K blocks
41 if(defined($ref)) {
42 print "Total 1k blocks: $ref->{blocks}\n";
43 print "Total 1k blocks free: $ref->{bfree}\n";
44 print "Total 1k blocks avail to me: $ref->{bavail}\n";
45 print "Total 1k blocks used: $ref->{used}\n";
46 print "Percent full: $ref->{per}\n";
47
48 if(exists($ref->{files})) {
49 print "Total inodes: $ref->{files}\n";
50 print "Total inodes free: $ref->{ffree}\n";
51 print "Inode percent full: $ref->{fper}\n";
52 }
53 }
54
55 #### Get information by passing a filehandle
56 open(FILE, "some_file"); # Get information for filesystem at "some_file"
57 my $ref = df(\*FILE);
58 #### or
59 my $ref = df(*FILE);
60 #### or
61 my $fhref = \*FILE;
62 my $ref = df($fhref);
63
64 #### Get information in other than 1k blocks
65 my $ref = df("/tmp", 8192); # output is 8K blocks
66 my $ref = df("/tmp", 1); # output is bytes
67
68
69 DESCRIPTION
70
71 This module provides a way to obtain filesystem disk space
72 information. This is a Unix only distribution. If you want to
73 gather this information for Unix and Windows, use Filesys::DfPortable.
74 The only major benefit of using Filesys::Df over Filesys::DfPortable,
75 is that Filesys::Df supports the use of open filehandles as arguments.
76
77 The module should work with all flavors of Unix that implement the
78 statvfs() and fstatvfs() calls, or the statfs() and fstatfs() calls.
79 This would include Linux, *BSD, HP-UX, AIX, Solaris, Mac OS X, Irix,
80 Cygwin, etc ...
81
82 df() requires a argument that represents the filesystem you want to
83 query. The argument can be either a scalar directory/file name or a
84 open filehandle. There is also an optional block size argument so
85 you can tailor the size of the values returned. The default block
86 size is 1024. This will cause the function to return the values in 1k
87 blocks. If you want bytes, set the block size to 1.
88
89 df() returns a reference to a hash. The keys available in
90 the hash are as follows:
91
92 {blocks} = Total blocks on the filesystem.
93
94 {bfree} = Total blocks free on the filesystem.
95
96 {bavail} = Total blocks available to the user executing the Perl
97 application. This can be different than bfree if you have per-user
98 quotas on the filesystem, or if the super user has a reserved amount.
99 {bavail} can also be a negative value because of this. For instance
100 if there is more space being used then you have available to you.
101
102 {used} = Total blocks used on the filesystem.
103
104 {per} = Percent of disk space used. This is based on the disk space
105 available to the user executing the application. In other words, if
106 the filesystem has 10% of its space reserved for the superuser, then
107 the percent used can go up to 110%.
108
109 You can obtain inode information through the module as well. But you
110 must call exists() on the {files} key to make sure the information is
111 available:
112 if(exists($ref->{files})) {
113 #### Inode info is available
114 }
115 Some filesystems may not return inode information, for
116 example some NFS filesystems.
117
118 Here are the available inode keys:
119
120 {files} = Total inodes on the filesystem.
121
122 {ffree} = Total inodes free on the filesystem.
123
124 {favail} = Total inodes available to the user executing the application.
125 See the rules for the {bavail} key.
126
127 {fused} = Total inodes used on the filesystem.
128
129 {fper} = Percent of inodes used on the filesystem. See rules for the {per}
130 key.
131
132 There are some undocumented keys that are defined to maintain backwards
133 compatibility: {su_blocks}, {user_blocks}, etc ...
134
135 If the df() call fails for any reason, it will return
136 undef. This will probably happen if you do anything crazy like try
137 to get information for /proc, or if you pass an invalid filesystem name,
138 or if there is an internal error. df() will croak() if you pass
139 it a undefined value.
140
141
142 Requirements:
143 Your system must contain statvfs() and fstatvfs(), or statfs() and fstatfs()
144 You must be running Perl 5.6 or higher.
145
146 Copyright (c) 2006 Ian Guthrie. All rights reserved.
147 This program is free software; you can redistribute it and/or
148 modify it under the same terms as Perl itself.
149