|
|
@ -3257,24 +3257,6 @@ sub hooklistener {
|
|
|
|
if ($? != 0) {
|
|
|
|
if ($? != 0) {
|
|
|
|
error "tar failed";
|
|
|
|
error "tar failed";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} elsif ($msg eq "nblks") {
|
|
|
|
|
|
|
|
# handle the nblks message
|
|
|
|
|
|
|
|
my $numblocks;
|
|
|
|
|
|
|
|
debug "received message: nblks";
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
my $ret = read(STDIN, $numblocks, $len)
|
|
|
|
|
|
|
|
// error "cannot read from socket: $!";
|
|
|
|
|
|
|
|
if ($ret == 0) {
|
|
|
|
|
|
|
|
error "received eof on socket";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($numblocks !~ /^\d+$/) {
|
|
|
|
|
|
|
|
error "invalid number of blocks: $numblocks";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
debug "sending okthx";
|
|
|
|
|
|
|
|
print STDOUT (pack("n", 0) . "okthx")
|
|
|
|
|
|
|
|
or error "cannot write to socket: $!";
|
|
|
|
|
|
|
|
STDOUT->flush();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
error "unknown message: $msg";
|
|
|
|
error "unknown message: $msg";
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -4566,7 +4548,6 @@ sub main() {
|
|
|
|
error "unknown format: $format";
|
|
|
|
error "unknown format: $format";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
my $numblocks = 0;
|
|
|
|
|
|
|
|
my $exitstatus = 0;
|
|
|
|
my $exitstatus = 0;
|
|
|
|
my @taropts = (
|
|
|
|
my @taropts = (
|
|
|
|
'--sort=name',
|
|
|
|
'--sort=name',
|
|
|
@ -4602,6 +4583,13 @@ sub main() {
|
|
|
|
socketpair my $childsock, my $parentsock, AF_UNIX, SOCK_STREAM, PF_UNSPEC
|
|
|
|
socketpair my $childsock, my $parentsock, AF_UNIX, SOCK_STREAM, PF_UNSPEC
|
|
|
|
or error "socketpair failed: $!";
|
|
|
|
or error "socketpair failed: $!";
|
|
|
|
$options->{hooksock} = $childsock;
|
|
|
|
$options->{hooksock} = $childsock;
|
|
|
|
|
|
|
|
# for communicating the required number of blocks, we don't need
|
|
|
|
|
|
|
|
# bidirectional communication, so a pipe() is enough
|
|
|
|
|
|
|
|
# we don't communicate this via the hook communication because
|
|
|
|
|
|
|
|
# a) this would abuse the functionality exclusively for hooks
|
|
|
|
|
|
|
|
# b) it puts code writing the protocol outside of the helper/listener
|
|
|
|
|
|
|
|
# c) the forked listener process cannot communicate to its parent
|
|
|
|
|
|
|
|
pipe my $nblkreader, my $nblkwriter or error "pipe failed: $!";
|
|
|
|
if ($options->{mode} eq 'unshare') {
|
|
|
|
if ($options->{mode} eq 'unshare') {
|
|
|
|
$pid = get_unshare_cmd(
|
|
|
|
$pid = get_unshare_cmd(
|
|
|
|
sub {
|
|
|
|
sub {
|
|
|
@ -4621,21 +4609,19 @@ sub main() {
|
|
|
|
|
|
|
|
|
|
|
|
setup($options);
|
|
|
|
setup($options);
|
|
|
|
|
|
|
|
|
|
|
|
if (!$options->{dryrun} && $format eq 'ext2') {
|
|
|
|
|
|
|
|
my $numblocks = approx_disk_usage($options->{root});
|
|
|
|
|
|
|
|
debug "sending nblks";
|
|
|
|
|
|
|
|
print $childsock (
|
|
|
|
|
|
|
|
pack("n", length "$numblocks") . "nblks$numblocks");
|
|
|
|
|
|
|
|
$childsock->flush();
|
|
|
|
|
|
|
|
debug "waiting for okthx";
|
|
|
|
|
|
|
|
checkokthx $childsock;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print $childsock (pack('n', 0) . 'adios');
|
|
|
|
print $childsock (pack('n', 0) . 'adios');
|
|
|
|
$childsock->flush();
|
|
|
|
$childsock->flush();
|
|
|
|
|
|
|
|
|
|
|
|
close $childsock;
|
|
|
|
close $childsock;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
close $nblkreader;
|
|
|
|
|
|
|
|
if (!$options->{dryrun} && $format eq 'ext2') {
|
|
|
|
|
|
|
|
my $numblocks = approx_disk_usage($options->{root});
|
|
|
|
|
|
|
|
print $nblkwriter "$numblocks\n";
|
|
|
|
|
|
|
|
$nblkwriter->flush();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
close $nblkwriter;
|
|
|
|
|
|
|
|
|
|
|
|
if ($options->{dryrun}) {
|
|
|
|
if ($options->{dryrun}) {
|
|
|
|
info "simulate creating tarball...";
|
|
|
|
info "simulate creating tarball...";
|
|
|
|
} elsif (any { $_ eq $format } ('tar', 'squashfs', 'ext2')) {
|
|
|
|
} elsif (any { $_ eq $format } ('tar', 'squashfs', 'ext2')) {
|
|
|
@ -4690,20 +4676,19 @@ sub main() {
|
|
|
|
|
|
|
|
|
|
|
|
setup($options);
|
|
|
|
setup($options);
|
|
|
|
|
|
|
|
|
|
|
|
if (!$options->{dryrun} && $format eq 'ext2') {
|
|
|
|
|
|
|
|
my $numblocks = approx_disk_usage($options->{root});
|
|
|
|
|
|
|
|
print $childsock (
|
|
|
|
|
|
|
|
pack("n", length "$numblocks") . "nblks$numblocks");
|
|
|
|
|
|
|
|
$childsock->flush();
|
|
|
|
|
|
|
|
debug "waiting for okthx";
|
|
|
|
|
|
|
|
checkokthx $childsock;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print $childsock (pack('n', 0) . 'adios');
|
|
|
|
print $childsock (pack('n', 0) . 'adios');
|
|
|
|
$childsock->flush();
|
|
|
|
$childsock->flush();
|
|
|
|
|
|
|
|
|
|
|
|
close $childsock;
|
|
|
|
close $childsock;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
close $nblkreader;
|
|
|
|
|
|
|
|
if (!$options->{dryrun} && $format eq 'ext2') {
|
|
|
|
|
|
|
|
my $numblocks = approx_disk_usage($options->{root});
|
|
|
|
|
|
|
|
print $nblkwriter $numblocks;
|
|
|
|
|
|
|
|
$nblkwriter->flush();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
close $nblkwriter;
|
|
|
|
|
|
|
|
|
|
|
|
if ($options->{dryrun}) {
|
|
|
|
if ($options->{dryrun}) {
|
|
|
|
info "simulate creating tarball...";
|
|
|
|
info "simulate creating tarball...";
|
|
|
|
} elsif (any { $_ eq $format } ('tar', 'squashfs', 'ext2')) {
|
|
|
|
} elsif (any { $_ eq $format } ('tar', 'squashfs', 'ext2')) {
|
|
|
@ -4827,6 +4812,13 @@ sub main() {
|
|
|
|
|
|
|
|
|
|
|
|
close $parentsock;
|
|
|
|
close $parentsock;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
my $numblocks = 0;
|
|
|
|
|
|
|
|
close $nblkwriter;
|
|
|
|
|
|
|
|
if (!$options->{dryrun} && $format eq 'ext2') {
|
|
|
|
|
|
|
|
chomp($numblocks = <$nblkreader>);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
close $nblkreader;
|
|
|
|
|
|
|
|
|
|
|
|
if ($options->{dryrun}) {
|
|
|
|
if ($options->{dryrun}) {
|
|
|
|
# nothing to do
|
|
|
|
# nothing to do
|
|
|
|
} elsif ($format eq 'directory') {
|
|
|
|
} elsif ($format eq 'directory') {
|
|
|
|