/[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 1 by dpavlin, Sat Jul 18 17:31:53 2009 UTC revision 2 by dpavlin, Sat Jul 18 18:05:37 2009 UTC
# Line 17  GetOptions( Line 17  GetOptions(
17          'commit!'   => \$commit,          'commit!'   => \$commit,
18  ) or die "unknown options: $!";  ) or die "unknown options: $!";
19    
20  map { mkdir $_ unless -e $_ } map { "$mnt/$_" } ( 'log', 'ps' );  map { mkdir $_ unless -e $_ } map { "$mnt/$_" } ( 'log', 'fs' );
21    
22  my $path = shift @ARGV;  my $path = shift @ARGV || die "usage: $0 /path/to/file\n";
23    
24  my ($dir,$file) = ($1,$2) if $path =~ m{^(?:(.+)/)?([^/]+)};  my ($dir,$file) = ($1,$2) if $path =~ m{^(?:(.+)/)?([^/]+)};
25    
# Line 36  if ( -e "$mnt/last" ) { Line 36  if ( -e "$mnt/last" ) {
36          warn "# seq: $seq start: $opos\n";          warn "# seq: $seq start: $opos\n";
37    
38  } else {  } else {
39          $seq = scalar(glob("$mnt/log/*"));          $seq = $#{ glob("$mnt/log/*") } + 1;
40          warn "# $mnt/last not found, recover seq: $seq\n";          warn "# $mnt/last not found, recover seq: $seq\n";
41  }  }
42    
# Line 58  if ( -e $log ) { Line 58  if ( -e $log ) {
58          }          }
59  }  }
60    
 my $cmd = "dd_rescue -l $log -S $opos $path $dev && ln -s $log $mnt/last";  
 print "+ $cmd\n";  
 system($cmd) == 0 or die $?;  
   
61  my $fs = "$mnt/fs/$dir";  my $fs = "$mnt/fs/$dir";
62  mkdir $fs unless -e $fs;  mkpath $fs unless -e $fs;
63    
64  $fs .= '/' . $file;  $fs .= '/' . $file;
 symlink $fs,$log || die "can't create $fs: $!";  
65    
66    die "$fs exists!" if -e $fs;
67    
68    my $cmd = "dd_rescue -l $log -S $opos $path $dev";
69    print "+ $cmd\n";
70    system($cmd) == 0 or warn "# exit code: $?";
71    
72    unlink("$mnt/last") && symlink($log,"$mnt/last") || die "can't commit log $log -> $mnt/last";
73    
74    symlink($log,$fs) || die "can't create $fs: $!";
75    
76    print "OK $fs -> $log\n";

Legend:
Removed from v.1  
changed lines
  Added in v.2

  ViewVC Help
Powered by ViewVC 1.1.26