Next Five Minute Lightning Talk: Perl's syscall Function #8            

Yet another example: statfs

    my $buf = "\0"x64;
    my $path = "/etc/motd";

    syscall(&SYS_statfs, $path, $buf) == 0 or die;
    
    my ($bsize, $blocks, $bfree, $bavail, $files, $ffree, $namelen)
        = unpack  "x4 L6 x8 L", $buf;
    
    print <<EOT;
           Optimal transfer block size: $bsize
                 Blocks in file system: $blocks
                           Blocks free: $bfree (${\(int $bfree/$blocks*100)}%)
                 User blocks available: $bavail (${\(int $bavail/$blocks*100)}%)
                                Inodes: $files 
                           Free inodes: $ffree (${\(int $ffree/$files*100)}%)
               Maximum filename length: $namelen
    EOT
       Optimal transfer block size: 4096
             Blocks in file system: 2203843
                       Blocks free: 1112349 (50%)
             User blocks available: 1000397 (45%)
                            Inodes: 1121664
                       Free inodes: 982182 (87%)
           Maximum filename length: 255