Changeset 104cbd0bdf995f9b00c86968d4833c4a5447b762

Show
Ignore:
Timestamp:
11/01/07 04:05:13 (7 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1193889913 +0000
git-parent:

[049f37c082f06620ed811faa55226c24d2e82e50]

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

Try to get this working on Mac OS X.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • configure.in

    r049f37c r104cbd0  
    11AC_INIT(zetaback.in) 
    2 AC_PATH_PROG(PERL,perl, ,/usr/perl5/bin) 
    3 AC_PATH_PROG(POD2MAN,pod2man, ,/usr/perl5/bin) 
     2AC_PATH_PROG(PERL,perl, ,/usr/bin /usr/perl5/bin) 
     3AC_PATH_PROG(POD2MAN,pod2man, ,/usr/bin /usr/perl5/bin) 
    44AC_SUBST(PERL) 
    55AC_SUBST(POD2MAN) 
  • zetaback_agent.in

    r23dd315 r104cbd0  
    77use strict; 
    88use Getopt::Long; 
     9use POSIX qw/mkfifo/; 
    910use Data::Dumper; 
    1011 
    1112use vars qw/%conf $version_string 
    1213            $PREFIX $CONF $LIST $FULL $SNAP $ZFS $BASE $RESTORE $VERSION 
    13             $BUG_6343779/; 
     14            $BUG_6343779 $NEEDSFD/; 
    1415$version_string = '0.1'; 
    1516$PREFIX = q^__PREFIX__^; 
    1617$CONF = qq^$PREFIX/etc/zetaback_agent.conf^; 
     18$NEEDSFD = ($^O eq 'darwin') ? 1 : 0; 
    1719 
    1820=pod 
     
    179181  `/usr/sbin/zfs snapshot $target`; 
    180182  my @cmd = ("/usr/sbin/zfs", "send", $target); 
    181   exec { $cmd[0] } @cmd; 
     183  if($NEEDSFD) { 
     184    fifo_exec(@cmd); 
     185  } else { 
     186    exec { $cmd[0] } @cmd; 
     187  } 
    182188  exit; 
    183189} 
     
    191197  `/usr/sbin/zfs snapshot $target`; 
    192198  my @cmd = ("/usr/sbin/zfs", "send", "-i", $base, $target); 
    193   exec { $cmd[0] } @cmd; 
     199  if($NEEDSFD) { 
     200    fifo_exec(@cmd); 
     201  } else { 
     202    exec { $cmd[0] } @cmd; 
     203  } 
    194204  exit; 
    195205} 
     
    234244} 
    235245 
     246sub fifo_exec { 
     247  my @cmd = @_; 
     248  my $rv = -1; 
     249  my $fifo = "zetaback_${$}_${FULL}${BASE}.fifo"; 
     250  mkfifo($fifo, 0600) || die "Could not create fifo: $!"; 
     251  my $pid = fork(); 
     252  if($pid == 0) { 
     253    close(STDOUT); 
     254    open(STDOUT, ">$fifo") || die "Could not open fifo: $!"; 
     255    exec { $cmd[0] } @cmd; 
     256    exit; 
     257  } 
     258  open(FIFO, "<$fifo"); 
     259  unlink($fifo); 
     260  my $buf; 
     261  while(my $len = sysread(FIFO, $buf, 1024*64)) { 
     262    syswrite(STDOUT, $buf, $len); 
     263  } 
     264  waitpid($pid, 0); 
     265} 
     266 
    236267if($LIST) { zfs_agent_list(); exit; } 
    237268if($ZFS && $SNAP) { zfs_agent_remove_snap(); exit; }