• Home
  • History
  • Annotate
  • only in this directory
NameDateSize

..11-Apr-2013244

ChangesH A D20-Feb-2013280

Df.pmH A D20-Feb-201311.1 KiB

Makefile.PLH A D20-Feb-20134.5 KiB

MANIFESTH A D20-Feb-2013168

META.ymlH A D20-Feb-2013292

READMEH A D20-Feb-20135.9 KiB

test.plH A D20-Feb-20131.7 KiB

typemapH A D20-Feb-201354

XS_statfsH A D20-Feb-20132.1 KiB

XS_statvfsH A D20-Feb-20131.8 KiB

README

1INSTALL
2TO INSTALL RUN:
3                                                                                                                     
4        perl Makefile.PL
5        make
6        make test
7        make install
8
9
10During the build process, the makefile will try to figure out which
11system calls to use to obtain filesystem information. It will look
12for statvfs() first via the Config module and a include directory
13search. If it locates statvfs(), it will assume the system also has
14fstatvfs(). If it cannot find statvfs(), it will then begin the same
15search for statfs(). If statfs() is found it will assume fstatfs()
16is also available.
17
18During the 'make test', test.pl will try to test with '/' and then
19open test.pl in the current directory and use that for a filehandle
20test.
21
22Once installed, run 'perldoc Filesys::Df' for more information.
23
24If you have any problems or questions please email me at IGuthrie@aol.com
25with "Filesys::Df" in the subject line. If you run into a build problem,
26please include the output of the install commands, the version of Perl
27you are using (perl -v), and what operating system you are using.
28
29
30Module Documentation:
31This distribution contains the module Filesys::Df
32
33Filesys::Df - Perl extension for filesystem disk space information.
34
35SYNOPSIS
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
69DESCRIPTION
70
71This module provides a way to obtain filesystem disk space
72information. This is a Unix only distribution. If you want to
73gather this information for Unix and Windows, use Filesys::DfPortable.
74The only major benefit of using Filesys::Df over Filesys::DfPortable,
75is that Filesys::Df supports the use of open filehandles as arguments.
76                                                                                                                       
77The module should work with all flavors of Unix that implement the
78statvfs() and fstatvfs() calls, or the statfs() and fstatfs() calls.
79This would include Linux, *BSD, HP-UX, AIX, Solaris, Mac OS X, Irix,
80Cygwin, etc ...
81                                                                                                                       
82df() requires a argument that represents the filesystem you want to
83query. The argument can be either a scalar directory/file name or a
84open filehandle. There is also an optional block size argument so
85you can tailor the size of the values returned. The default block
86size is 1024. This will cause the function to return the values in 1k
87blocks. If you want bytes, set the block size to 1.
88
89df() returns a reference to a hash. The keys available in 
90the 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 
97application. This can be different than bfree if you have per-user 
98quotas 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
100if 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
105available to the user executing the application. In other words, if
106the filesystem has 10% of its space reserved for the superuser, then
107the percent used can go up to 110%.
108
109You can obtain inode information through the module as well. But you
110must call exists() on the {files} key to make sure the information is
111available:
112if(exists($ref->{files})) {
113        #### Inode info is available
114}
115Some filesystems may not return inode information, for
116example some NFS filesystems.
117
118Here 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.
125See 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}
130key.
131
132There are some undocumented keys that are defined to maintain backwards
133compatibility: {su_blocks}, {user_blocks}, etc ...
134
135If the df() call fails for any reason, it will return
136undef. This will probably happen if you do anything crazy like try
137to get information for /proc, or if you pass an invalid filesystem name,
138or if there is an internal error. df() will croak() if you pass
139it a undefined value.
140
141
142Requirements:
143Your system must contain statvfs() and fstatvfs(), or statfs() and fstatfs()
144You must be running Perl 5.6 or higher.
145                                                                                                                     
146Copyright (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                                                                        
150