BackupPC_attribPrint (BackupPC-4.3.2) | : | BackupPC_attribPrint (BackupPC-4.4.0) | ||
---|---|---|---|---|
skipping to change at line 31 | skipping to change at line 31 | |||
# This program is distributed in the hope that it will be useful, | # This program is distributed in the hope that it will be useful, | |||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
# GNU General Public License for more details. | # GNU General Public License for more details. | |||
# | # | |||
# You should have received a copy of the GNU General Public License | # You should have received a copy of the GNU General Public License | |||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
# | # | |||
#======================================================================== | #======================================================================== | |||
# | # | |||
# Version 4.3.2, released 17 Feb 2020. | # Version 4.4.0, released 20 Jun 2020. | |||
# | # | |||
# See http://backuppc.sourceforge.net. | # See http://backuppc.sourceforge.net. | |||
# | # | |||
#======================================================================== | #======================================================================== | |||
use strict; | use strict; | |||
no utf8; | no utf8; | |||
use lib "__INSTALLDIR__/lib"; | use lib "__INSTALLDIR__/lib"; | |||
use BackupPC::Lib; | use BackupPC::Lib; | |||
use BackupPC::XS; | use BackupPC::XS; | |||
use Data::Dumper; | use Data::Dumper; | |||
die("BackupPC::Lib->new failed\n") if ( !(my $bpc = BackupPC::Lib->new) ); | die("BackupPC::Lib->new failed\n") if ( !(my $bpc = BackupPC::Lib->new) ); | |||
my $TopDir = $bpc->TopDir(); | my $TopDir = $bpc->TopDir(); | |||
my $BinDir = $bpc->BinDir(); | my $BinDir = $bpc->BinDir(); | |||
my %Conf = $bpc->Conf(); | my %Conf = $bpc->Conf(); | |||
skipping to change at line 60 | skipping to change at line 60 | |||
if ( @ARGV != 1 ) { | if ( @ARGV != 1 ) { | |||
print STDERR "Usage: $0 attribPath\n"; | print STDERR "Usage: $0 attribPath\n"; | |||
print STDERR " $0 inodePath/inodeNum\n"; | print STDERR " $0 inodePath/inodeNum\n"; | |||
exit(1); | exit(1); | |||
} | } | |||
my($dir, $file, $specificInode, $specificInodeHexStr); | my($dir, $file, $specificInode, $specificInodeHexStr); | |||
if ( $ARGV[0] =~ m{(.*/inode)/(\d+)$} ) { | if ( $ARGV[0] =~ m{(.*/inode)/(\d+)$} ) { | |||
$specificInode = $2; | $specificInode = $2; | |||
$dir = sprintf("%s/%02x", $1, ($specificInode >> 17) & 0x7f); | $dir = sprintf("%s/%02x", $1, ($specificInode >> 17) & 0x7f); | |||
$file = sprintf("attrib%02x", ($specificInode >> 10) & 0x7f); | $file = sprintf("attrib%02x", ($specificInode >> 10) & 0x7f); | |||
do { | do { | |||
$specificInodeHexStr .= sprintf("%02x", $specificInode & 0xff); | $specificInodeHexStr .= sprintf("%02x", $specificInode & 0xff); | |||
$specificInode = $specificInode >> 8; | $specificInode = $specificInode >> 8; | |||
} while ( $specificInode > 0 ); | } while ( $specificInode > 0 ); | |||
print("Reading inode attrib file $dir/$file; inodeName = $specificInodeHexSt r\n"); | print("Reading inode attrib file $dir/$file; inodeName = $specificInodeHexSt r\n"); | |||
} elsif ( $ARGV[0] =~ m{(.+)/(.+)} ) { | } elsif ( $ARGV[0] =~ m{(.+)/(.+)} ) { | |||
$dir = $1; | $dir = $1; | |||
$file = $2; | $file = $2; | |||
} elsif ( -f $ARGV[0] || $ARGV[0] eq "attrib" ) { | } elsif ( -f $ARGV[0] || $ARGV[0] eq "attrib" ) { | |||
$dir = "."; | $dir = "."; | |||
$file = $ARGV[0]; | $file = $ARGV[0]; | |||
} else { | } else { | |||
$dir = $ARGV[0]; | $dir = $ARGV[0]; | |||
$file = "attrib"; | $file = "attrib"; | |||
} | } | |||
# | # | |||
# We don't know if compression is on or off for a particular attrib file, so we try | # We don't know if compression is on or off for a particular attrib file, so we try | |||
# the opposite if the global setting fails. | # the opposite if the global setting fails. | |||
# | # | |||
my $attrib = BackupPC::XS::Attrib::new($Conf{CompressLevel}); | my $attrib = BackupPC::XS::Attrib::new($Conf{CompressLevel}); | |||
if ( !$attrib->read($dir, $file) ) { | if ( !$attrib->read($dir, $file) ) { | |||
my $digestStr = sprintf(" (%s)", unpack("H*", $attrib->digest())) if ( lengt h($attrib->digest()) ); | my $digestStr = sprintf(" (%s)", unpack("H*", $attrib->digest())) if ( lengt h($attrib->digest()) ); | |||
$attrib = BackupPC::XS::Attrib::new(!$Conf{CompressLevel}); | $attrib = BackupPC::XS::Attrib::new(!$Conf{CompressLevel}); | |||
if ( !$attrib->read($dir, $file) ) { | if ( !$attrib->read($dir, $file) ) { | |||
$digestStr = sprintf(" (%s)", unpack("H*", $attrib->digest())) if ( leng th($attrib->digest()) ); | $digestStr = sprintf(" (%s)", unpack("H*", $attrib->digest())) if ( leng th($attrib->digest()) ); | |||
print STDERR "BackupPC_attribPrint: cannot read attrib file $ARGV[0]$dig estStr\n"; | print STDERR "BackupPC_attribPrint: cannot read attrib file $ARGV[0]$dig estStr\n"; | |||
exit(1); | exit(1); | |||
} | } | |||
} | } | |||
my $info = $attrib->get(); | if ( my $msg = BackupPC::XS::Lib::logMsgGet() ) { | |||
# | print join("", @$msg); | |||
# convert digest to a hex string | ||||
# | ||||
foreach my $file ( keys(%$info) ) { | ||||
next if ( !defined($info->{$file}{digest}) ); | ||||
$info->{$file}{digest} = unpack("H*", $info->{$file}{digest}); | ||||
} | } | |||
if ( length($attrib->digest()) ) { | if ( length($attrib->digest()) ) { | |||
printf("Attrib digest is %s\n", unpack("H*", $attrib->digest())); | printf("Attrib digest is %s\n", unpack("H*", $attrib->digest())); | |||
} | } | |||
$Data::Dumper::Indent = 1; | $Data::Dumper::Indent = 1; | |||
$Data::Dumper::Sortkeys = 1; | $Data::Dumper::Sortkeys = 1; | |||
if ( defined($specificInode) ) { | $Data::Dumper::Pad = " "; | |||
print Dumper($info->{$specificInodeHexStr}); | $Data::Dumper::Terse = 1; | |||
} else { | my $idx = 0; | |||
print Dumper($info); | my $info; | |||
print("\$attrib = {\n"); | ||||
while ( 1 ) { | ||||
($info, $idx) = $attrib->iterate($idx); | ||||
last if ( !defined($info) ); | ||||
next if ( defined($specificInode) && $info->{name} ne $specificInodeHexStr ) | ||||
; | ||||
$info->{digest} = unpack("H*", $info->{digest}) if ( defined($info->{digest} | ||||
) ); | ||||
my $str = Data::Dumper->Dump([$info]); | ||||
$str =~ s/\n$//; | ||||
$str =~ s/^ *//; | ||||
print " '$info->{name}' => ", $str, ",\n"; | ||||
} | } | |||
print("};\n") | ||||
End of changes. 8 change blocks. | ||||
17 lines changed or deleted | 25 lines changed or added |