/[fuse-comp]/fuse-comp.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /fuse-comp.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 35 by dpavlin, Mon Jul 16 08:24:08 2007 UTC revision 39 by dpavlin, Sun Sep 2 12:03:52 2007 UTC
# Line 10  require 'syscall.ph'; # for SYS_mknod an Line 10  require 'syscall.ph'; # for SYS_mknod an
10  use PerlIO::gzip;  use PerlIO::gzip;
11  use File::Path;  use File::Path;
12  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
13  use Carp qw/confess/;  use Carp qw/confess cluck/;
14  use IO::File;  use IO::File;
15  use Getopt::Long;  use Getopt::Long;
16    
# Line 25  GetOptions( Line 25  GetOptions(
25  );  );
26    
27  my $mount = {  my $mount = {
28          from    => '/tmp/comp',          from    => shift @ARGV || '/tmp/comp',
29          to              => '/tmp/no-comp',          to              => shift @ARGV || '/tmp/no-comp',
30          tmp             => '/dev/shm/comp',          tmp             => shift @ARGV || '/dev/shm/comp',
31  };  };
32    
33    warn "mount $mount->{from} to $mount->{to} using $mount->{tmp} as cache\n";
34    
35  my $skip_extensions_regex = qr/gz|gz%|\.(?:sw[a-z]|gif|png|jpeg|jpg|avi|rar|zip|bz2|tgz|avi|mpeg|mpg|tmp|temp)$/i;  my $skip_extensions_regex = qr/gz|gz%|\.(?:sw[a-z]|gif|png|jpeg|jpg|avi|rar|zip|bz2|tgz|avi|mpeg|mpg|tmp|temp)$/i;
36    
37  # don't compress files smaller than this  # don't compress files smaller than this
# Line 47  my $pending; Line 49  my $pending;
49  sub real_name {  sub real_name {
50          my ( $dir, $name ) = @_;          my ( $dir, $name ) = @_;
51          if ( -e "$dir/${name}.gz" ) {          if ( -e "$dir/${name}.gz" ) {
52                  confess "ASSERT: unexpected $dir/$name exists" if -e "$dir/$name";                  cluck "ASSERT: unexpected $dir/$name exists" if -e "$dir/$name";
53                  return "${name}.gz";                  return "${name}.gz";
54          }          }
55          if ( $name =~ m/\.gz$/ ) {          if ( $name =~ m/\.gz$/ ) {
# Line 356  sub x_symlink { Line 358  sub x_symlink {
358          warn "# symlink( $from_path -> $to_path ) = $rv\n" if $debug;          warn "# symlink( $from_path -> $to_path ) = $rv\n" if $debug;
359    
360          my $tmp = $mount->{tmp} . '/' . $from;          my $tmp = $mount->{tmp} . '/' . $from;
361          if ( -e $tmp ) {          my $tmp_to = $mount->{tmp} . '/' . $to;
362                  my $tmp_to = $mount->{$tmp} . '/' . $to;          if ( $rv == 0 && -e $tmp_to ) {
363                  symlink( $tmp, $tmp_to ) || confess "can't symlink $tmp -> $tmp_to: $!";                  symlink( $tmp, $tmp_to ) || confess "can't symlink $tmp -> $tmp_to: $!";
364          }          }
365          return $rv;          return $rv;

Legend:
Removed from v.35  
changed lines
  Added in v.39

  ViewVC Help
Powered by ViewVC 1.1.26