# Craig Barratt <cbarratt@users.sourceforge.net>
#
# COPYRIGHT
-# Copyright (C) 2002 Craig Barratt
+# Copyright (C) 2002-2003 Craig Barratt
#
#========================================================================
#
-# Version 2.0.0beta0, released 23 Feb 2003.
+# Version 2.1.0_CVS, released 3 Jul 2003.
#
# See http://backuppc.sourceforge.net.
#
return if ( !defined($fio->{fh}) );
if ( $fio->{fh}->read(\$fileData, $blockSize * $num) <= 0 ) {
- $fio->log("$fio->{file}{name}: csumGet is at EOF - zero padding\n");
+ $fio->log("$fio->{file}{name}: csumGet is at EOF - zero padding");
$fio->{stats}{errorCnt}++;
$fileData = pack("c", 0) x ($blockSize * $num);
}
$fio->{csumDigest}->add($fileData) if ( defined($fio->{csumDigest}) );
- $fio->log(sprintf("%s: getting csum ($num,$csumLen,%d,0x%x)\n",
+ $fio->log(sprintf("%s: getting csum ($num,$csumLen,%d,0x%x)",
$fio->{file}{name},
length($fileData),
$fio->{checksumSeed}))
$fio->{stats}{errorCnt}++;
return -1;
}
- if ( $attr->{size} < 10 * 1024 * 1024 ) {
+ if ( $attr->{size} < 16 * 1024 * 1024 ) {
#
- # Cache the entire old file if it is less than 10MB
+ # Cache the entire old file if it is less than 16MB
#
my $data;
$fio->{rxInData} = "";
- while ( $fh->read(\$data, 10 * 1024 * 1024) > 0 ) {
+ while ( $fh->read(\$data, 16 * 1024 * 1024) > 0 ) {
$fio->{rxInData} .= $data;
}
$fio->log("$attr->{fullPath}: cached all $attr->{size}"
if ( open(F, "+>", "$fio->{outDirSh}RStmp") ) {
my $data;
my $byteCnt = 0;
+ binmode(F);
while ( $fh->read(\$data, 1024 * 1024) > 0 ) {
if ( syswrite(F, $data) != length($data) ) {
$fio->log(sprintf("Can't write len=%d to %s",
}
$fio->{rxInFd} = *F;
$fio->{rxInName} = "$fio->{outDirSh}RStmp";
- seek($fio->{rxInFd}, 0, 0);
+ sysseek($fio->{rxInFd}, 0, 0);
$fio->log("$attr->{fullPath}: copied $byteCnt,"
. "$attr->{size} bytes to $fio->{rxInName}")
if ( $fio->{logLevel} >= 9 );
$fh->close;
} else {
if ( open(F, "<", $attr->{fullPath}) ) {
+ binmode(F);
$fio->{rxInFd} = *F;
$fio->{rxInName} = $attr->{fullPath};
} else {
. "$lastBlk")
if ( $fio->{logLevel} >= 9 );
my $seekPosn = $fio->{rxMatchBlk} * $fio->{rxBlkSize};
- if ( defined($fio->{rxInFd}) && !seek($fio->{rxInFd}, $seekPosn, 0) ) {
+ if ( defined($fio->{rxInFd})
+ && !sysseek($fio->{rxInFd}, $seekPosn, 0) ) {
$fio->log("Unable to seek $attr->{rxInName} to $seekPosn");
$fio->{stats}{errorCnt}++;
return -1;
$fio->{stats}{errorCnt}++;
return -1;
}
+ $seekPosn += $len;
}
$fio->{rxOutFd}->write(\$data);
$fio->{rxDigest}->add($data);
$fio->{rxDigest} = File::RsyncP::Digest->new;
$fio->{rxDigest}->add(pack("V", $fio->{checksumSeed}));
my $attr = $fio->{rxLocalAttr};
- if ( defined($attr) && defined(my $fh = BackupPC::FileZIO->open(
+ if ( defined($attr) ) {
+ if ( defined(my $fh = BackupPC::FileZIO->open(
$attr->{fullPath},
0,
$attr->{compress})) ) {
- my $data;
- while ( $fh->read(\$data, 4 * 65536) > 0 ) {
- $fio->{rxDigest}->add($data);
- $fio->{rxSize} += length($data);
+ my $data;
+ while ( $fh->read(\$data, 4 * 65536) > 0 ) {
+ $fio->{rxDigest}->add($data);
+ $fio->{rxSize} += length($data);
+ }
+ $fh->close;
+ } else {
+ $fio->log("Can't open $attr->{fullPath} for MD4 check ($name)");
+ $fio->{stats}{errorCnt}++;
}
- $fh->close;
- } else {
- $fio->log("cannot open $attr->{fullPath} for MD4 check");
- $fio->{stats}{errorCnt}++;
}
$fio->log("$name got exact match")
if ( $fio->{logLevel} >= 5 );
$fio->log("$name got digests $md4Str vs $newStr")
}
if ( $md4 ne $newDigest ) {
- $fio->log("$name md4 doesn't match")
- if ( $fio->{logLevel} >= 1 );
+ $fio->log("$name: fatal error: md4 doesn't match");
+ $fio->{stats}{errorCnt}++;
if ( defined($fio->{rxOutFd}) ) {
$fio->{rxOutFd}->close;
unlink($fio->{rxOutFile});
|| $type == BPC_FTYPE_BLOCKDEV
|| $type == BPC_FTYPE_SYMLINK ) {
my $fh = BackupPC::FileZIO->open($a->{fullPath}, 0, $a->{compress});
- my $str;
+ my($str, $rdSize);
if ( defined($fh) ) {
- if ( $fh->read(\$str, $a->{size} + 1) == $a->{size} ) {
- if ( $type == BPC_FTYPE_SYMLINK ) {
- #
- # Reconstruct symbolic link
- #
- $extraAttribs = { link => $str };
- } elsif ( $str =~ /(\d*),(\d*)/ ) {
- #
- # Reconstruct char or block special major/minor device num
- #
- $extraAttribs = { rdev => $1 * 256 + $2 };
- } else {
- $fio->log("$name: unexpected special file contents $str");
+ $rdSize = $fh->read(\$str, $a->{size} + 1024);
+ if ( $type == BPC_FTYPE_SYMLINK ) {
+ #
+ # Reconstruct symbolic link
+ #
+ $extraAttribs = { link => $str };
+ if ( $rdSize != $a->{size} ) {
+ # ERROR
+ $fio->log("$name: can't read exactly $a->{size} bytes");
$fio->{stats}{errorCnt}++;
}
+ } elsif ( $str =~ /(\d*),(\d*)/ ) {
+ #
+ # Reconstruct char or block special major/minor device num
+ #
+ # Note: char/block devices have $a->{size} = 0, so we
+ # can't do an error check on $rdSize.
+ #
+ $extraAttribs = { rdev => $1 * 256 + $2 };
} else {
- # ERROR
- $fio->log("$name: can't read exactly $a->{size} bytes");
+ $fio->log("$name: unexpected special file contents $str");
$fio->{stats}{errorCnt}++;
}
$fh->close;