1Df(3)                 User Contributed Perl Documentation                Df(3)
2
3
4

NAME

6       Filesys::Df - Perl extension for filesystem disk space information.
7

SYNOPSIS

9         use Filesys::Df;
10
11         #### Get information by passing a scalar directory/filename value
12         my $ref = df("/tmp");  # Default output is 1K blocks
13         if(defined($ref)) {
14            print "Total 1k blocks: $ref->{blocks}\n";
15            print "Total 1k blocks free: $ref->{bfree}\n";
16            print "Total 1k blocks avail to me: $ref->{bavail}\n";
17            print "Total 1k blocks used: $ref->{used}\n";
18            print "Percent full: $ref->{per}\n";
19
20            if(exists($ref->{files})) {
21               print "Total inodes: $ref->{files}\n";
22               print "Total inodes free: $ref->{ffree}\n";
23               print "Inode percent full: $ref->{fper}\n";
24            }
25         }
26
27         #### Get information by passing a filehandle
28         open(FILE, "some_file");  # Get information for filesystem at "some_file"
29         my $ref = df(\*FILE);
30         #### or
31         my $ref = df(*FILE);
32         #### or
33         my $fhref = \*FILE;
34         my $ref = df($fhref);
35
36         #### Get information in other than 1k blocks
37         my $ref = df("/tmp", 8192);  # output is 8K blocks
38         my $ref = df("/tmp", 1);     # output is bytes
39

DESCRIPTION

41       This module provides a way to obtain filesystem disk space information.
42       This is a Unix only distribution. If you want to gather this
43       information for Unix and Windows, use "Filesys::DfPortable".  The only
44       major benefit of using "Filesys::Df" over "Filesys::DfPortable", is
45       that "Filesys::Df" supports the use of open filehandles as arguments.
46
47       The module should work with all flavors of Unix that implement the
48       "statvfs()" and "fstatvfs()" calls, or the "statfs()" and "fstatfs()"
49       calls.  This would include Linux, *BSD, HP-UX, AIX, Solaris, Mac OS X,
50       Irix, Cygwin, etc ...
51
52       "df()" requires a argument that represents the filesystem you want to
53       query. The argument can be either a scalar directory/file name or a
54       open filehandle. There is also an optional block size argument so you
55       can tailor the size of the values returned. The default block size is
56       1024. This will cause the function to return the values in 1k blocks.
57       If you want bytes, set the block size to 1.
58
59       "df()" returns a reference to a hash. The keys available in the hash
60       are as follows:
61
62       "{blocks}" = Total blocks on the filesystem.
63
64       "{bfree}" = Total blocks free on the filesystem.
65
66       "{bavail}" = Total blocks available to the user executing the Perl
67       application. This can be different than "{bfree}" if you have per-user
68       quotas on the filesystem, or if the super user has a reserved amount.
69       "{bavail}" can also be a negative value because of this. For instance
70       if there is more space being used then you have available to you.
71
72       "{used}" = Total blocks used on the filesystem.
73
74       "{per}" = Percent of disk space used. This is based on the disk space
75       available to the user executing the application. In other words, if the
76       filesystem has 10% of its space reserved for the superuser, then the
77       percent used can go up to 110%.
78
79       You can obtain inode information through the module as well, but you
80       must call "exists()" on the "{files}" key first, to make sure the
81       information is available. Some filesystems may not return inode
82       information, for example some NFS filesystems.
83
84       Here are the available inode keys:
85
86       "{files}" = Total inodes on the filesystem.
87
88       "{ffree}" = Total inodes free on the filesystem.
89
90       "{favail}" = Total inodes available to the user executing the
91       application.  See the rules for the "{bavail}" key.
92
93       "{fused}" = Total inodes used on the filesystem.
94
95       "{fper}" = Percent of inodes used on the filesystem. See rules for the
96       "{per}" key.
97
98       There are some undocumented keys that are defined to maintain backwards
99       compatibilty: "{su_blocks}", "{user_blocks}", etc ...
100
101       If the "df()" call fails for any reason, it will return undef. This
102       will probably happen if you do anything crazy like try to get
103       information for /proc, or if you pass an invalid filesystem name, or if
104       there is an internal error. "df()" will "croak()" if you pass it a
105       undefined value.
106
107       Requirements: Your system must contain "statvfs()" and "fstatvfs()", or
108       "statfs()" and "fstatfs()" You must be running Perl 5.6 or higher.
109

AUTHOR

111       Ian Guthrie IGuthrie@aol.com
112
113       Copyright (c) 2006 Ian Guthrie. All rights reserved.
114                      This program is free software; you can redistribute it
115       and/or
116                      modify it under the same terms as Perl itself.
117

SEE ALSO

119       statvfs(2), fstatvfs(2), statfs(2), fstatfs(2), df(1),
120       Filesys::DfPortable
121
122       perl(1).
123
124
125
126perl v5.32.0                      2020-07-28                             Df(3)
Impressum