4 use Amanda::Device qw( :constants );
5 use Amanda::Config qw( :getconf :init );
6 use Amanda::Debug qw( :logging );
7 use Amanda::Util qw( :running_as_flags );
9 # try to open the device and read its label, returning the device_read_label
10 # result (one or more of ReadLabelStatusFlags)
12 my ($device_name) = @_;
14 if ( !$device_name ) {
15 return $READ_LABEL_STATUS_DEVICE_MISSING;
18 my $device = Amanda::Device->new($device_name);
20 return $READ_LABEL_STATUS_DEVICE_MISSING
21 | $READ_LABEL_STATUS_DEVICE_ERROR;
24 $device->set_startup_properties_from_config();
26 return $device->read_label();
29 # print the results, one flag per line
33 print join( "\n", ReadLabelStatusFlags_to_strings($flags) ), "\n";
38 Usage: amdevcheck <config> [ <device name> ]
43 ## Application initialization
45 Amanda::Util::setup_application("amdevcheck", "server", "cmdline");
47 usage() if ( @ARGV < 1 || @ARGV > 2 );
48 my $config_name = $ARGV[0];
49 if (!config_init($CONFIG_INIT_EXPLICIT_NAME, $config_name)) {
50 critical('errors processing config file "' .
51 Amanda::Config::get_config_filename() . '"');
54 Amanda::Util::finish_setup($RUNNING_AS_DUMPUSER);
60 $device_name = $ARGV[1];
62 $device_name = getconf($CNF_TAPEDEV);
65 print_result( try_read_label($device_name) );