Skip to content
Snippets Groups Projects
Commit 85cd9e71 authored by Gerhard Gonter's avatar Gerhard Gonter :speech_balloon:
Browse files

Option to ignore inode numbers can be specified via command

line or store configuration, see [1].

[1] https://github.com/gonter/forge001/issues/1
parent f80029ae
No related branches found
No related tags found
No related merge requests found
...@@ -6,16 +6,20 @@ ...@@ -6,16 +6,20 @@
=head1 USAGE =head1 USAGE
vlib001.pl -p project-name [-s store-name] [paraemters]* vlib001.pl -p project-name [-s store-name] [parameters]*
options: options:
* -p <project-name> * -p <project-name>
* -s <store-name> * -s <store-name>
* --project <project-name>
* --store <store-name>
* --verify ... verify/create TOC structures (not for MongoDB) * --verify ... verify/create TOC structures (not for MongoDB)
* --fileinfo ... refresh file info * --fileinfo ... refresh file info
* --lookup ... lookup for hashes given as parameters * --lookup ... lookup for hashes given as parameters
* --limit <n> ... check up <n> files * --limit <n> ... check up <n> files
* --noinode ... ignore the inode
* -D ... increase debug level * -D ... increase debug level
* -X ... stop after setup (useful as option -DX)
=head1 DESCRIPTION =head1 DESCRIPTION
...@@ -59,6 +63,7 @@ my $op_mode= 'refresh'; ...@@ -59,6 +63,7 @@ my $op_mode= 'refresh';
my $limit= undef; my $limit= undef;
my $cat_file= '_catalog'; my $cat_file= '_catalog';
my $ino_file= '_catalog.inodes'; my $ino_file= '_catalog.inodes';
my $check_inode= 1;
my @hdr= qw(md5 path mtime fs_size ino); my @hdr= qw(md5 path mtime fs_size ino);
...@@ -74,20 +79,24 @@ while (my $arg= shift (@ARGV)) ...@@ -74,20 +79,24 @@ while (my $arg= shift (@ARGV))
elsif ($arg =~ /^--/) elsif ($arg =~ /^--/)
{ {
if ($arg eq '--project') { $project= shift (@ARGV); } if ($arg eq '--project') { $project= shift (@ARGV); }
elsif ($arg eq '--store') { $store= shift (@ARGV); } elsif ($arg eq '--store') { $store= shift (@ARGV); }
elsif ($arg eq '--limit') { $limit= shift (@ARGV); }
elsif ($arg eq '--fileinfo') { $refresh_fileinfo= 1; } elsif ($arg eq '--fileinfo') { $refresh_fileinfo= 1; }
elsif ($arg eq '--limit') { $limit= shift (@ARGV); } elsif ($arg eq '--noinode') { $check_inode= 0; }
elsif ($arg =~ /^--(refresh|verify|lookup|edit|maint|next-seq|get-cat)$/) { $op_mode= $1; } elsif ($arg =~ /^--(refresh|verify|lookup|edit|maint|next-seq|get-cat)$/) { $op_mode= $1; }
else { &usage ("unknown option '$arg'"); }
} }
elsif ($arg =~ /^-/) elsif ($arg =~ /^-/)
{ {
my @a= split ('|', $arg); my @a= split ('|', $arg);
shift (@a);
foreach my $a (@a) foreach my $a (@a)
{ {
if ($a eq 'p') { $project= shift (@ARGV); } if ($a eq 'p') { $project= shift (@ARGV); }
elsif ($a eq 's') { $store= shift (@ARGV); } elsif ($a eq 's') { $store= shift (@ARGV); }
elsif ($a eq 'D') { $DEBUG++; } elsif ($a eq 'D') { $DEBUG++; }
elsif ($a eq 'X') { $STOP= 1; } elsif ($a eq 'X') { $STOP= 1; }
else { &usage ("unknown option '-$a'"); }
} }
} }
else { push (@PAR, $arg); } else { push (@PAR, $arg); }
...@@ -130,7 +139,18 @@ if ($op_mode eq 'refresh') ...@@ -130,7 +139,18 @@ if ($op_mode eq 'refresh')
print "no store config found for '$store', check these: ", Dumper ($stores_p); print "no store config found for '$store', check these: ", Dumper ($stores_p);
exit (-2); exit (-2);
} }
print "store_cfg: ", Dumper ($store_cfg) if ($DEBUG); print "store_cfg: ", Dumper ($store_cfg) if ($DEBUG);
if (exists ($store_cfg->{'inodes'}))
{
my $i= $store_cfg->{'inodes'};
if ($i eq 'ignore') { $check_inode= 0; }
elsif ($i eq 'check') { $check_inode= 1; }
else
{
print "WARNING: store-parameter 'inodes' has unknown value '$i'\n";
}
}
if ($catalog->{'format'} eq 'md5cat') { refresh_md5cat ($objreg, $store); } if ($catalog->{'format'} eq 'md5cat') { refresh_md5cat ($objreg, $store); }
elsif ($catalog->{'format'} eq 'internal') { refresh_internal ($objreg, $store); } elsif ($catalog->{'format'} eq 'internal') { refresh_internal ($objreg, $store); }
...@@ -188,8 +208,8 @@ exit (0); ...@@ -188,8 +208,8 @@ exit (0);
sub usage sub usage
{ {
my $msg= shift; my $msg= shift;
print $msg, "\n"; print $msg, "\n" if ($msg);
system ("perldoc $0"); system ('perldoc', $0);
exit -1; exit -1;
} }
...@@ -243,6 +263,9 @@ sub refresh_internal ...@@ -243,6 +263,9 @@ sub refresh_internal
# print "md5cat: ", Dumper ($md5cat); # print "md5cat: ", Dumper ($md5cat);
print "flist processed\n"; print "flist processed\n";
my @check_list= qw(mtime size);
push (@check_list, 'ino') if ($check_inode);
# compare TOC and reference filelist # compare TOC and reference filelist
my $fl= $md5cat->{'FLIST'}; my $fl= $md5cat->{'FLIST'};
my %key= (); my %key= ();
...@@ -264,7 +287,7 @@ sub refresh_internal ...@@ -264,7 +287,7 @@ sub refresh_internal
$cnt_processed++; $cnt_processed++;
my $f= $fl->{$p}; my $f= $fl->{$p};
my $matches= 1; my $matches= 1;
AN: foreach my $an (qw(mtime size ino)) AN: foreach my $an (@check_list)
{ {
unless ($f->{$an} eq $x->{$an}) unless ($f->{$an} eq $x->{$an})
{ {
...@@ -361,8 +384,9 @@ sub process_file ...@@ -361,8 +384,9 @@ sub process_file
# 'key' => $md5, 'key_type' => 'md5', # 'key' => $md5, 'key_type' => 'md5',
'store' => $store, 'store' => $store,
'c_size' => $size, 'path' => $path, 'md5' => $md5, 'c_size' => $size, 'path' => $path, 'md5' => $md5,
'mtime' => $st[9], 'fs_size' => $st[7], 'ino' => $st[1] 'mtime' => $st[9], 'fs_size' => $st[7]
}; };
$xdata->{'ino'}= $st[1] if ($check_inode);
my $search= { 'md5' => $md5, 'store' => $store, 'path' => $path }; my $search= { 'md5' => $md5, 'store' => $store, 'path' => $path };
my $reg= $objreg->lookup ($search); my $reg= $objreg->lookup ($search);
...@@ -443,23 +467,26 @@ sub get_cat_internal ...@@ -443,23 +467,26 @@ sub get_cat_internal
my ($md5, $fs_size, $path, $ino)= map { $t->{$_} } qw(md5 fs_size path ino); my ($md5, $fs_size, $path, $ino)= map { $t->{$_} } qw(md5 fs_size path ino);
printf CAT ("%s file %9ld %s\n", $md5, $fs_size, $path); printf CAT ("%s file %9ld %s\n", $md5, $fs_size, $path);
# print "t: ", Dumper ($t); # print "t: ", Dumper ($t);
push (@{$inodes{$ino}}, $path); push (@{$inodes{$ino}}, $path) if ($check_inode);
$count++; $count++;
} }
close (CAT); close (CAT);
if (open (INO, '>:utf8', $ino_file)) if ($check_inode)
{ {
print "writing new catalog '$ino_file'\n"; if (open (INO, '>:utf8', $ino_file))
foreach my $ino (sort { $a <=> $b } keys %inodes)
{ {
print INO join ('|', $ino, @{$inodes{$ino}}), "\n"; print "writing new catalog '$ino_file'\n";
foreach my $ino (sort { $a <=> $b } keys %inodes)
{
print INO join ('|', $ino, @{$inodes{$ino}}), "\n";
}
close (INO);
}
else
{
print "can not write to '$ino_file'\n";
} }
close (INO);
}
else
{
print "can not write to '$ino_file'\n";
} }
$count; $count;
...@@ -477,7 +504,9 @@ sub verify_toc_item ...@@ -477,7 +504,9 @@ sub verify_toc_item
# my @paths= keys %{$jj->{'path'}}; # my @paths= keys %{$jj->{'path'}};
# $ster->{'path_count'}= scalar @paths; ... we don't see that this way anymore # $ster->{'path_count'}= scalar @paths; ... we don't see that this way anymore
foreach my $k (qw(md5 path mtime fs_size ino)) my @check_list= qw(md5 path mtime fs_size);
push (@check_list, 'ino') if ($check_inode);
foreach my $k (@check_list)
{ {
$ster->{$k}= $jj->{$k}; $ster->{$k}= $jj->{$k};
} }
...@@ -493,6 +522,9 @@ __END__ ...@@ -493,6 +522,9 @@ __END__
locate all the stores on a given machine, so there should be an option locate all the stores on a given machine, so there should be an option
that updates everything. that updates everything.
* specifing the store should be optional. * specifing the store should be optional.
* environment variable TABASE:
* add pod section
* allow command line option to specifiy alternative base directory name
=head2 misc =head2 misc
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment