man Filesys::Df () - Perl extension for obtaining file system stats.

NAME

Filesys::Df - Perl extension for obtaining file system stats.

SYNOPSIS

  use Filesys::Df;
  $ref = df("/tmp", 512); #Display output in 512 byte blocks
                          #Default is 1024 byte blocks.
  print"Percent Full:               $ref->{per}\n";
  print"Superuser Blocks:           $ref->{blocks}\n";
  print"Superuser Blocks Available: $ref->{bfree}\n";
  print"User Blocks:                $ref->{user_blocks}\n";
  print"User Blocks Available:      $ref->{bavail}\n";
  print"Blocks Used:                $ref->{used}\n";

DESCRIPTION

This module will produce information on the amount disk space available to the normal user and the superuser for any given filesystem.

It contains one function df(), which takes a directory as the first argument and an optional second argument which will let you specify the block size for the output. Note that the inode values are not changed by the block size argument.

The return value of df() is a refrence to a hash. The main keys of interest in this hash are:

{per} Percent of disk space used. This is based on what the non-superuser will have used. (In other words, if the filesystem has 10% of its space reserved for the superuser, then the percent used can go up to 110%.)

{blocks} Total number of blocks on the file system.

{used} Total number of blocks used.

{bavail} Total number of blocks available.

{fper} Percent of inodes used. This is based on what the non-superuser will have used.

{files} Total inodes on the file system.

{fused} Total number of inodes used.

{favail} Inodes available.

Most filesystems have a certain amount of space reserved that only the superuser can access.

If you wish to differentiate between the amount of space that the normal user can access, and the amount of space the superuser can access, you can use these keys:

{su_blocks} or {blocks} Total number of blocks on the file system.

{user_blocks} Total number of blocks on the filesystem for the non-superuser.

{su_bavail} or {bfree} Total number of blocks available to the superuser.

{user_bavail} or {bavail} Total number of blocks available to the non-superuser.

{su_files} or {files} Total inodes on the file system.

{user_files} Total number of inodes on the filesystem for the non-superuser.

{su_favail} or {ffree} Inodes available in file system.

{user_favail} or {favail} Inodes available to non-superuser.

Most 'df' applications will print out the 'blocks' or 'user_blocks', 'bavail', 'used', and the percent full values. So you will probably end up using these values the most.

If the file system does not contain a diffrential in space for the superuser, then the user_ keys will contain the same values as the su_ keys.

If there was an error, df() will return undef and $! will have been set.

If the blocks field returned from statvfs() is 0 then df() returns undef. This may occur if you stat a directory such as /proc.

Requirements: Your system must contain statvfs() or statfs(). You must be running perl.5003 or higher.

Note: The way the percent full is measured is based on what the HP-UX application 'bdf' returns. The 'bdf' application seems to round a bit different than most 'df' apps do, but I like 'bdf', so that is what I based the percentages on.

AUTHOR

Ian Guthrie IGuthrie@aol.com

Copyright (c) 1998 Ian Guthrie. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

statvfs(2), df(1), bdf(1)

perl(1).