Changeset c2480c644c31c432e11af1860ba53d4908de3844

Show
Ignore:
Timestamp:
03/02/07 06:35:41 (7 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1172817341 +0000
git-parent:

[0b2d8d710d93bbf77957e066f0c0ac7bae57c998]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1172817341 +0000
Message:

This dups the backupfile onto stdout of the a child process and exec's ssh.
This means that the data doesn't have to pass through perl.

closes #7

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • zetaback

    r5afffac rc2480c6  
    390390  open(LBACKUP, ">$store/.$dumpfile") || die "zfs_full_backup: cannot create dump\n"; 
    391391  eval { 
    392     open(RBACKUP, "ssh $host $agent -z $fs -$type $point |") || die "zfs_full_backup: cannot perform send\n"; 
    393     my $buffer; 
    394     while(my $len = sysread(RBACKUP, $buffer, $BLOCKSIZE)) { 
    395       if(syswrite(LBACKUP, $buffer, $len) != $len) { 
    396         die "$!"; 
    397       } 
    398     } 
    399     close(LBACKUP); 
    400     close(RBACKUP); 
     392    if(my $pid = fork()) { 
     393      close(LBACKUP); 
     394      waitpid($pid, 0); 
     395      die "error: $?" if($?); 
     396    } 
     397    else { 
     398      my @cmd = ('ssh', $host, $agent, '-z', $fs, "-$type", $point); 
     399      open STDIN, "/dev/null" || exit(-1); 
     400      open STDOUT, ">&LBACKUP" || exit(-1); 
     401      exec { $cmd[0] } @cmd; 
     402      print STDERR "$cmd[0] failed: $?\n"; 
     403      exit($?); 
     404    } 
    401405    die "dump failed (zero bytes)\n" if(-z "$store/.$dumpfile"); 
    402406    rename("$store/.$dumpfile", "$store/$dumpfile") || die "cannot rename dump\n";