/[42-fs]/42.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 /42.pl

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

revision 4 by dpavlin, Sun Jul 19 13:08:33 2009 UTC revision 5 by dpavlin, Sun Jul 19 13:33:51 2009 UTC
# Line 11  use Data::Dump qw/dump/; Line 11  use Data::Dump qw/dump/;
11  my $dev = '/dev/sdb';  my $dev = '/dev/sdb';
12  my $mnt = '/mnt/42';  my $mnt = '/mnt/42';
13    
14  my ( $verbose, $init, $debug ) = ( 1 );  my ( $verbose, $skip, $init, $debug ) = ( 0, 1 );
15    
16  GetOptions(  GetOptions(
17          'init!' => \$init,          'verbose!' => \$verbose,
18          'debug!' => \$debug,          'skip!'    => \$skip,
19            'init!'    => \$init,
20            'debug!'   => \$debug,
21  ) or die "unknown options: $!";  ) or die "unknown options: $!";
22    
23    
# Line 59  sub mount_42 { Line 61  sub mount_42 {
61                          sleep 1;                          sleep 1;
62                  }                  }
63          }          }
64          warn "+ mount $node $mnt";          warn " ready\n+ mount $node $mnt\n";
65          system("mount $node $mnt") == 0 or die "can't mount: $!";          system("mount $node $mnt") == 0 or die "can't mount: $!";
66  }  }
67    
# Line 106  my $fs = "$mnt/fs/$dir"; Line 108  my $fs = "$mnt/fs/$dir";
108  mkpath $fs unless -e $fs;  mkpath $fs unless -e $fs;
109    
110  $fs .= '/' . $file;  $fs .= '/' . $file;
111  die "$fs exists!" if -e $fs;  if ( -e $fs ) {
112            if ( $skip ) {
113                    warn "SKIP $fs\n";
114                    exit 0;
115            } else {
116                    die "$fs exists! re-run with --skip\n";
117            }
118    }
119    
120  my @stat = stat($path);  my @stat = stat($path);
121  die "can't stat $path: $!" unless @stat;  die "can't stat $path: $!" unless @stat;
122  warn "# $path ",$stat[7],$/;  warn "# $path ",$stat[7],$/;
123    
124  my $size_mb = int( $stat[7] / 1000 / 1000 ) + 1; # FIXME correctly round to something?  my $size_mb = $stat[7] / 1000 / 1000; # FIXME correctly round to something?
125  my ( $free_start, undef, $free_size ) = @{$part[0]};  my ( $free_start, undef, $free_size ) = @{$part[0]};
126    
127  my $part_end = $free_start + $size_mb;  my $part_end = int( $free_start + $size_mb + 1 );
128    
129  my $last_part = $#part;  my $last_part = $#part;
130    

Legend:
Removed from v.4  
changed lines
  Added in v.5

  ViewVC Help
Powered by ViewVC 1.1.26