use warnings;
use Amanda::Util qw( :constants );
-use Amanda::Config qw( :init );
+use Amanda::Config qw( :init :getconf );
use Amanda::Logfile qw( :logtype_t log_add $amanda_log_trace_log );
use Amanda::Debug;
use Amanda::Device qw( :constants );
use Amanda::MainLoop;
use Amanda::Changer;
use Amanda::Taper::Scan;
+use Amanda::Interactivity;
use Getopt::Long;
Amanda::Util::setup_application("amcheck-device", "server", $CONTEXT_CMDLINE);
my $overwrite = 0;
Getopt::Long::Configure(qw{bundling});
GetOptions(
+ 'version' => \&Amanda::Util::version_opt,
'o=s' => sub { add_config_override_opt($config_overrides, $_[1]); },
'w' => \$overwrite,
) or usage();
sub do_check {
my ($finished_cb) = @_;
my ($res, $label, $mode);
+ my $tlf = Amanda::Config::config_dir_relative(getconf($CNF_TAPELIST));
+ my $tl = Amanda::Tapelist->new($tlf);
+ my $chg = Amanda::Changer->new(undef, tapelist => $tl);
+ return failure($chg, $finished_cb) if ($chg->isa("Amanda::Changer::Error"));
+ my $interactivity = Amanda::Interactivity->new(
+ name => getconf($CNF_INTERACTIVITY));
+ my $scan_name = getconf($CNF_TAPERSCAN);
+ my $taperscan = Amanda::Taper::Scan->new(algorithm => $scan_name,
+ changer => $chg,
+ interactivity => $interactivity,
+ tapelist => $tl);
my $steps = define_steps
- cb_ref => \$finished_cb;
+ cb_ref => \$finished_cb,
+ finalize => sub { $taperscan->quit(); };
step start => sub {
- my $chg = Amanda::Changer->new();
-
- return failure($chg, $finished_cb) if ($chg->isa("Amanda::Changer::Error"));
-
- my $taperscan = Amanda::Taper::Scan->new(changer => $chg);
$taperscan->scan(
result_cb => $steps->{'result_cb'},
user_msg_fn => \&_user_msg_fn
step result_cb => sub {
(my $err, $res, $label, $mode) = @_;
- return failure($err, $finished_cb) if $err;
-
- if (defined $res->{'device'}->volume_label()) {
- $res->set_label(label => $res->{'device'}->volume_label(),
- finished_cb => $steps->{'set_labeled'});
- } else {
- $steps->{'set_labeled'}->(undef);
- };
- };
+ if ($err) {
+ if ($res) {
+ $res->release(finished_cb => sub {
+ return failure($err, $finished_cb);
+ });
+ return;
+ } else {
+ return failure($err, $finished_cb);
+ }
+ }
- step set_labeled => sub {
my $modestr = ($mode == $ACCESS_APPEND)? "append" : "write";
my $slot = $res->{'this_slot'};
- if (defined $res->{'device'}->volume_label()) {
+ if (defined $res->{'device'} and defined $res->{'device'}->volume_label()) {
print "Will $modestr to volume '$label' in slot $slot.\n";
} else {
print "Will $modestr label '$label' to new volume in slot $slot.\n";
print "WARNING: Media access mode is WRITE_ONLY; dumps may not be recoverable\n";
}
+ if (getconf_seen($CNF_DEVICE_OUTPUT_BUFFER_SIZE)) {
+ my $dobs = getconf($CNF_DEVICE_OUTPUT_BUFFER_SIZE);
+ my $block_size = $res->{'device'}->property_get("BLOCK_SIZE");
+ if ($block_size * 2 > $dobs) {
+ print "WARNING: DEVICE-OUTPUT-BUFFER-SIZE is not at least twice the block size of the device, it should be increased for better throughput\n";
+ }
+ }
$steps->{'check_overwrite'}->();
};
$finished_cb->();
};
}
-do_check(\&Amanda::MainLoop::quit);
+
+Amanda::MainLoop::call_later(\&do_check, \&Amanda::MainLoop::quit);
Amanda::MainLoop::run();
Amanda::Util::finish_application();
exit($exit_status);