-#!/bin/perl -T
+#!/bin/perl
#============================================================= -*-perl-*-
#
# BackupPC_tarCreate: create a tar archive of an existing dump
#
#========================================================================
#
-# Version 2.0.0_CVS, released 3 Feb 2003.
+# Version 2.0.2, released 6 Oct 2003.
#
# See http://backuppc.sourceforge.net.
#
#========================================================================
use strict;
-use lib "/usr/local/BackupPC/lib";
+no utf8;
+use lib "/usr/local/BackupPC2.0.2/lib";
use File::Path;
use Getopt::Std;
use BackupPC::Lib;
my %Conf = $bpc->Conf();
my %opts;
-getopts("th:n:p:r:s:", \%opts);
-if ( @ARGV < 1 ) {
+if ( !getopts("th:n:p:r:s:", \%opts) || @ARGV < 1 ) {
print(STDERR "usage: $0 [-t] [-h host] [-n dumpNum] [-s shareName]"
. " [-r pathRemove] [-p pathAdd]"
. " files/directories...\n");
#
# Write out all the requested files/directories
#
+binmode(STDOUT);
my $fh = *STDOUT;
foreach my $dir ( @ARGV ) {
archiveWrite($fh, $dir);
my $done = $WriteBufSz - length($WriteBuf);
if ( syswrite($fh, $WriteBuf . substr($$dataRef, 0, $done))
!= $WriteBufSz ) {
- print(STDERR "Unable to write to output file\n");
+ print(STDERR "Unable to write to output file ($!)\n");
exit(1);
}
while ( $done + $WriteBufSz <= length($$dataRef) ) {
if ( syswrite($fh, substr($$dataRef, $done, $WriteBufSz))
!= $WriteBufSz ) {
- print(STDERR "Unable to write to output file\n");
+ print(STDERR "Unable to write to output file ($!)\n");
exit(1);
}
$done += $WriteBufSz;
: "";
my $devminor = defined($hdr->{devminor}) ? sprintf("%07o", $hdr->{devminor})
: "";
+ my $sizeStr;
+ if ( $hdr->{size} >= 2 * 65536 * 65536 ) {
+ #
+ # GNU extension for files >= 8GB: send size in big-endian binary
+ #
+ $sizeStr = pack("c4 N N", 0x80, 0, 0, 0,
+ $hdr->{size} / (65536 * 65536),
+ $hdr->{size} % (65536 * 65536));
+ } elsif ( $hdr->{size} >= 1 * 65536 * 65536 ) {
+ #
+ # sprintf octal only handles up to 2^32 - 1
+ #
+ my $sizeStr = sprintf("%03o", $hdr->{size} / (1 << 24))
+ . sprintf("%08o", $hdr->{size} % (1 << 24));
+ } else {
+ $sizeStr = sprintf("%011o", $hdr->{size});
+ }
my $data = pack($tar_pack_header,
substr($hdr->{name}, 0, 99),
sprintf("%07o", $hdr->{mode}),
sprintf("%07o", $hdr->{uid}),
sprintf("%07o", $hdr->{gid}),
- sprintf("%011o", $hdr->{size}),
+ $sizeStr,
sprintf("%011o", $hdr->{mtime}),
"", #checksum field - space padded by pack("A8")
$hdr->{type},