X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=server-src%2Famcheck-device.pl;h=b87d0e30954c9534609888f1029b489666523246;hb=HEAD;hp=a27d006148ba4e4880dd787f20bb3995c01cd55b;hpb=cd0b924f27312d57bd42f6c4fae2b795139e2d0b;p=debian%2Famanda diff --git a/server-src/amcheck-device.pl b/server-src/amcheck-device.pl index a27d006..b87d0e3 100644 --- a/server-src/amcheck-device.pl +++ b/server-src/amcheck-device.pl @@ -1,9 +1,10 @@ #! @PERL@ -# Copyright (c) 2009, 2010 Zmanda Inc. All Rights Reserved. +# Copyright (c) 2009-2012 Zmanda Inc. All Rights Reserved. # -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 as published -# by the Free Software Foundation. +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY @@ -38,6 +39,7 @@ my $config_overrides = new_config_overrides($#ARGV+1); 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(); @@ -94,6 +96,17 @@ sub _user_msg_fn { print STDERR "slot $params{'err'}->{'this_slot'}:"; } print STDERR " $params{'err'}\n"; + } elsif (!$params{'res'}) { + my $volume_label = $params{'label'}; + if ($params{'active'}) { + print STDERR " volume '$volume_label' is still active and cannot be overwritten\n"; + } elsif ($params{'does_not_match_labelstr'}) { + print STDERR " volume '$volume_label' does not match labelstr '$params{'labelstr'}'\n"; + } elsif ($params{'not_in_tapelist'}) { + print STDERR " volume '$volume_label' is not in the tapelist\n" + } else { + print STDERR " volume '$volume_label'\n"; + } } else { # res must be defined my $res = $params{'res'}; my $dev = $res->{'device'}; @@ -118,7 +131,12 @@ sub _user_msg_fn { } elsif ($dev->status & $DEVICE_STATUS_VOLUME_UNLABELED and $dev->volume_header and $dev->volume_header->{'type'} == $Amanda::Header::F_WEIRD) { - print STDERR " contains a non-Amanda volume; check and relabel it with 'amlabel -f'\n"; + my $autolabel = getconf($CNF_AUTOLABEL); + if ($autolabel->{'non_amanda'}) { + print STDERR " contains a non-Amanda volume\n"; + } else { + print STDERR " contains a non-Amanda volume; check and relabel it with 'amlabel -f'\n"; + } } elsif ($dev->status & $DEVICE_STATUS_VOLUME_ERROR) { my $message = $dev->error_or_status(); print STDERR " Can't read label: $message\n"; @@ -167,14 +185,29 @@ sub do_check { step result_cb => sub { (my $err, $res, $label, $mode) = @_; - return failure($err, $finished_cb) if $err; + if ($err) { + if ($res) { + $res->release(finished_cb => sub { + return failure($err, $finished_cb); + }); + return; + } else { + return failure($err, $finished_cb); + } + } 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"; + my $header = $res->{'device'}->volume_header(); + if (defined $header and defined $header->{'type'} and + $header->{'type'} == $Amanda::Header::F_WEIRD) { + print "Will $modestr label '$label' to non-Amanda volume in slot $slot.\n"; + } else { + print "Will $modestr label '$label' to new volume in slot $slot.\n"; + } } $steps->{'check_access_type'}->();