Imported Upstream version 3.3.3
[debian/amanda] / server-src / amcheck-device.pl
index 87331a6fa27a01d07a8f56243addd74e9fc6c232..b87d0e30954c9534609888f1029b489666523246 100644 (file)
@@ -1,9 +1,10 @@
 #! @PERL@
 # 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
@@ -95,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'};
@@ -190,7 +202,8 @@ sub do_check {
            print "Will $modestr to volume '$label' in slot $slot.\n";
        } else {
            my $header = $res->{'device'}->volume_header();
-           if ($header->{'type'} == $Amanda::Header::F_WEIRD) {
+           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";