Filesys-Statvfs-0.82/0040755000000000000000000000000010447422160013213 5ustar rootrootFilesys-Statvfs-0.82/Statvfs.xs0100644000000000000000000000335410433246363015227 0ustar rootroot#ifdef __cplusplus extern "C" { #endif #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include #ifdef __cplusplus } #endif typedef struct statvfs Statvfs; MODULE = Filesys::Statvfs PACKAGE = Filesys::Statvfs void statvfs(dir) char *dir PREINIT: Statvfs st; PPCODE: EXTEND(sp, 10); if(statvfs(dir, &st) == 0) { /* Push values as doubles because we don't know size */ PUSHs(sv_2mortal(newSVnv((double)st.f_bsize))); PUSHs(sv_2mortal(newSVnv((double)st.f_frsize))); PUSHs(sv_2mortal(newSVnv((double)st.f_blocks))); PUSHs(sv_2mortal(newSVnv((double)st.f_bfree))); PUSHs(sv_2mortal(newSVnv((double)st.f_bavail))); PUSHs(sv_2mortal(newSVnv((double)st.f_files))); PUSHs(sv_2mortal(newSVnv((double)st.f_ffree))); PUSHs(sv_2mortal(newSVnv((double)st.f_favail))); PUSHs(sv_2mortal(newSVnv((double)st.f_flag))); PUSHs(sv_2mortal(newSVnv((double)st.f_namemax))); } else { /* undef */ } void fstatvfs(fd) int fd; PREINIT: Statvfs st; PPCODE: EXTEND(sp, 10); if(fstatvfs(fd, &st) == 0) { /* Push values as doubles because we don't know size */ PUSHs(sv_2mortal(newSVnv((double)st.f_bsize))); PUSHs(sv_2mortal(newSVnv((double)st.f_frsize))); PUSHs(sv_2mortal(newSVnv((double)st.f_blocks))); PUSHs(sv_2mortal(newSVnv((double)st.f_bfree))); PUSHs(sv_2mortal(newSVnv((double)st.f_bavail))); PUSHs(sv_2mortal(newSVnv((double)st.f_files))); PUSHs(sv_2mortal(newSVnv((double)st.f_ffree))); PUSHs(sv_2mortal(newSVnv((double)st.f_favail))); PUSHs(sv_2mortal(newSVnv((double)st.f_flag))); PUSHs(sv_2mortal(newSVnv((double)st.f_namemax))); } else { /* undef */ } Filesys-Statvfs-0.82/MANIFEST0100644000000000000000000000024210433251554014341 0ustar rootrootMakefile.PL MANIFEST README Statvfs.pm Statvfs.xs test.pl typemap Changes META.yml Module meta-data (added by MakeMaker) Filesys-Statvfs-0.82/typemap0100644000000000000000000000004010433236354014607 0ustar rootrootTYPEMAP Statvfs T_PTRREF Filesys-Statvfs-0.82/META.yml0100644000000000000000000000045610447422160014466 0ustar rootroot# http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: Filesys-Statvfs version: 0.82 version_from: Statvfs.pm installdirs: site requires: distribution_type: module generated_by: ExtUtils::MakeMaker version 6.30 Filesys-Statvfs-0.82/test.pl0100644000000000000000000000335510433251451014530 0ustar rootroot# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### We start with some black magic to print on failure. # Change 1..1 below to 1..last_test_to_print . # (It may become useful if the test is moved to ./t subdirectory.) BEGIN { $| = 1; print "1..2\n"; } END {print "not ok 1\n" unless $loaded;} use Config qw(%Config); use Filesys::Statvfs; $loaded = 1; print "ok 1\n"; ######################### End of black magic. my $dir = "/"; my($bsize, $frsize, $blocks, $bfree, $bavail, $files, $ffree, $favail, $flag, $namemax) = Filesys::Statvfs::statvfs($dir); defined($bsize) and print"ok 2\n" or die "not ok 2\nstatvfs\(\) call failed for \"$dir\" $!\n"; print"Results for statvfs on \"$dir\"\n"; print "bsize: $bsize\n"; print "frsize: $frsize\n"; print "blocks: $blocks\n"; print "bfree: $bfree\n"; print "bavail: $bavail\n"; print "files: $files\n"; print "ffree: $ffree\n"; print "favail: $favail\n"; print "flag: $flag\n"; print "namemax: $namemax\n"; open(FILE, "./test.pl") or die "$! ./test.pl\n"; ($bsize, $frsize, $blocks, $bfree, $bavail, $files, $ffree, $favail, $flag, $namemax) = Filesys::Statvfs::fstatvfs(fileno(FILE)); close(FILE); defined($bsize) and print"\nok 3\n\n" or die "not ok 3\nfstatvfs\(\) call failed for \"test.pl\" $!\n"; print"Results for fstatvfs:\n"; print "bsize: $bsize\n"; print "frsize: $frsize\n"; print "blocks: $blocks\n"; print "bfree: $bfree\n"; print "bavail: $bavail\n"; print "files: $files\n"; print "ffree: $ffree\n"; print "favail: $favail\n"; print "flag: $flag\n"; print "namemax: $namemax\n"; print"All tests successful!\n\n"; Filesys-Statvfs-0.82/Statvfs.pm0100644000000000000000000000357110447416606015216 0ustar rootrootpackage Filesys::Statvfs; use strict; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); require Exporter; require DynaLoader; @ISA = qw(Exporter DynaLoader); @EXPORT = qw(statvfs fstatvfs); $VERSION = '0.82'; bootstrap Filesys::Statvfs $VERSION; 1; __END__ =head1 NAME Filesys::Statvfs - Perl extension for statvfs() and fstatvfs() =head1 SYNOPSIS use Filesys::Statvfs; my($bsize, $frsize, $blocks, $bfree, $bavail, $files, $ffree, $favail, $flag, $namemax) = statvfs("/tmp"); #### Pass an open filehandle. Verify that fileno() returns a defined #### value. If you pass undef to fstatvfs you will get unexpected results my $fd = fileno(FILE_HANDLE); if(defined($fd)) { ($bsize, $frsize, $blocks, $bfree, $bavail, $files, $ffree, $favail, $flag, $namemax) = fstatvfs($fd); } =head1 DESCRIPTION Interface for statvfs() and fstatvfs() Unless you need access to the bsize, flag, and namemax values, you should probably look at using Filesys::DfPortable or Filesys::Df instead. They will generally provide you with more functionality and portability. The module should work with all flavors of Unix that implement the C and C calls. This would include Linux, *BSD, HP-UX, AIX, Solaris, Mac OS X, Irix, Cygwin, etc ... The C and C functions will return a list of values, or will return C and set C<$!> if there was an error. The values returned are described in the statvfs/fstatvfs header or the C man page. The module assumes that if you have C, C will also be available. =head1 AUTHOR Ian Guthrie IGuthrie@aol.com Copyright (c) 2006 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. =head1 SEE ALSO statvfs(2), fstatvfs(2), Filesys::DfPortable, Filesys::Df =cut Filesys-Statvfs-0.82/Changes0100644000000000000000000000040010447421571014502 0ustar rootrootRevision history for Perl extension Filesys::Df 0.80 Thu May 18 23:00:11 2006 - Packaged Filesys::Statvfs in its own package since it is no longer packaged with Filesys::Df. 0.82 Sat Jun 24 23:47:11 2006 - Updated documentation. No code changes. Filesys-Statvfs-0.82/README0100644000000000000000000000734010447422036014076 0ustar rootrootINSTALL TO INSTALL RUN: perl Makefile.PL make make test make install During the 'make test', test.pl will try to test with '/' and then open test.pl in the current directory and use that for the filehandle test. Once installed, run 'perldoc Filesys::Statvfs' for more information. If you have any problems or questions please email me at IGuthrie@aol.com with "Filesys::Statvfs" in the subject line. If you run into a build problem, please include the output of the install commands, the version of Perl you are using (perl -v), and what operating system you are using. Module Documentation: Filesys::Statvfs - Perl extension for statvfs() and fstatvfs() SYNOPSIS use Filesys::Statvfs; my($bsize, $frsize, $blocks, $bfree, $bavail, $files, $ffree, $favail, $flag, $namemax) = statvfs("/tmp"); #### Pass an open filehandle. Verify that fileno() returns a defined #### value. If you pass undef to fstatvfs you will get unexpected results my $fd = fileno(FILE_HANDLE); if(defined($fd)) { ($bsize, $frsize, $blocks, $bfree, $bavail, $files, $ffree, $favail, $flag, $namemax) = fstatvfs($fd); } DESCRIPTION Interface for statvfs() and fstatvfs() Unless you need access to the bsize, flag, and namemax values, you should probably look at using Filesys::DfPortable or Filesys::Df instead. They will generally provide you with more functionality and portability. The module should work with all flavors of Unix that implement the statvfs() and fstatvfs() calls. This would include Linux, *BSD, HP-UX, AIX, Solaris, Mac OS X, Irix, Cygwin, etc ... The statvfs() and fstatvfs() functions will return a list of values, or will return undef and set $! if there was an error. The values returned are described in the statvfs/fstatvfs header or the statvfs()/fstatvfs() man page. The module assumes that if you have statvfs(), fstatvfs() will also be available. Copyright (c) 2006 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. Filesys-Statvfs-0.82/Makefile.PL0100644000000000000000000000454710433236312015171 0ustar rootrootuse ExtUtils::MakeMaker; use Config qw(%Config); #### Build information my $statvfs_header = "sys/statvfs.h"; my $statvfs_symbol = "d_statvfs"; my $statvfs_header_def = "i_sysstatvfs"; my $define = ""; print "OS = $Config{osname}\n"; #### Windows if($Config{osname} =~ /^MSWin/i) { print "This module does not support Windows.\n"; die "You might try Filesys::DfPortable instead.\n"; } #### Check for the existance of statvfs if(check_statvfs()) { print "Building with statvfs ....\n"; } else { print "Config module or include search could not find statvfs."; die "We could not find statvfs on this system.\n"; } sub check_statvfs { print "Checking for statvfs .....\n"; if(exists $Config{$statvfs_symbol} && defined $Config{$statvfs_symbol}) { print "$statvfs_symbol is defined.\n"; if(exists $Config{$statvfs_header_def} && defined $Config{$statvfs_header_def}) { print "$statvfs_header_def is defined.\n"; return(1); } else { print "Weird, $statvfs_header_def is not defined.\n"; #### Have never seen a system with statvfs and no sys/statvfs.h header #### Lets see if we can find one if(look_for_header($statvfs_header)) { return(1); } else { #### no idea what header would be print "Cannot find a $statvfs_header file\n"; print "We will not try to build with statvfs\n"; return(0); } } } else { print "$statvfs_symbol is not defined\n"; if(look_for_header($statvfs_header)) { return(1); } else { #### don't use statvfs print "Cannot find a $statvfs_header file\n"; print "We will not try to build with statvfs\n"; return(0); } } return(0); } sub look_for_header { my $header = shift; my @header_inc = split(/\s+/, join(" ", $Config{usrinc}, $Config{locincpth})); #my @header_inc = split(/\s+/, join(" ", $Config{usrinc})); foreach $header_path (@header_inc) { if(-f $header_path . '/' . $header) { print "Header found:" , $header_path . '/' . $header, "\n"; return(1); } } return(0); } WriteMakefile( 'NAME' => 'Filesys::Statvfs', 'VERSION_FROM' => 'Statvfs.pm', # finds $VERSION 'LIBS' => [''], # e.g., '-lm' 'DEFINE' => $define, # e.g., '-DHAVE_SOMETHING' 'INC' => '', # e.g., '-I/usr/include/other' 'XSPROTOARG' => '-prototypes' );