# pid - the pid that reserved that slot.
# state - SLOT_FULL/SLOT_EMPTY/SLOT_UNKNOWN
# device_status - the status of the device after the open or read_label
+# device_error - error message from the device
# f_type - the F_TYPE of the fileheader.
# label - the label, if known, of the volume in this slot
}
my $state_filename = Amanda::Config::config_dir_relative($config->{'changerfile'});
+ Amanda::Debug::debug("Using state file: $state_filename");
my $self = {
slots => \@slots,
my $slot = $res->{'this_slot'};
my $dev = $res->{device};
- $dev->read_label();
- my $label = $dev->volume_label;
$self->_update_slot_state(state => $state, dev => $dev, slot =>$slot);
- $user_msg_fn->("recording volume '$label' in slot $slot");
+ if ($dev->status() == $DEVICE_STATUS_SUCCESS) {
+ my $label = $dev->volume_label;
+ $user_msg_fn->("recording volume '$label' in slot $slot");
+ } else {
+ my $status = $dev->error_or_status;
+ $user_msg_fn->("recording device error '" . $status . "' in slot $slot");
+ }
$res->release(
finished_cb => $steps->{'released'},
unlocked => 1,
if (defined $state->{slots}->{$unaliased}) {
$s->{'device_status'} =
$state->{slots}->{$unaliased}->{device_status};
+ if ($s->{'device_status'} != $DEVICE_STATUS_SUCCESS) {
+ $s->{'device_error'} =
+ $state->{slots}->{$unaliased}->{device_error};
+ } else {
+ $s->{'device_error'} = undef;
+ }
$s->{'f_type'} = $state->{slots}->{$unaliased}->{f_type};
$s->{'label'} = $state->{slots}->{$unaliased}->{label};
} else {
$s->{'device_status'} = undef;
+ $s->{'device_error'} = undef;
$s->{'f_type'} = undef;
$s->{'label'} = undef;
}
my $slot = $params{slot};
my $unaliased = $self->{unaliased}->{$slot};
$state->{slots}->{$unaliased}->{device_status} = "".scalar($dev->status);
+ if ($dev->status != $DEVICE_STATUS_SUCCESS) {
+ $state->{slots}->{$unaliased}->{device_error} = $dev->error;
+ } else {
+ $state->{slots}->{$unaliased}->{device_error} = undef;
+ }
my $label = $dev->volume_label;
$state->{slots}->{$unaliased}->{state} = Amanda::Changer::SLOT_FULL;
$state->{slots}->{$unaliased}->{label} = $label;
my $label = $params{'label'};
my $slot = $self->{'this_slot'};
my $unaliased = $chg->{unaliased}->{$slot};
+ my $dev = $self->{'device'};
$state->{slots}->{$unaliased}->{label} = $label;
$state->{slots}->{$unaliased}->{device_status} =
- "".$DEVICE_STATUS_SUCCESS;
- $state->{slots}->{$unaliased}->{f_type} =
- "".scalar($Amanda::Header::F_TAPESTART);
+ "".$dev->status;
+ if ($dev->status != $DEVICE_STATUS_SUCCESS) {
+ $state->{slots}->{$unaliased}->{device_error} = $dev->error;
+ } else {
+ $state->{slots}->{$unaliased}->{device_error} = undef;
+ }
+ my $volume_header = $dev->volume_header;
+ if (defined $volume_header) {
+ $state->{slots}->{$unaliased}->{f_type} =
+ "".$volume_header->{type};
+ } else {
+ $state->{slots}->{$unaliased}->{f_type} = undef;
+ }
$finished_cb->();
});
}
# then never mind
return unless $self->{'chg'};
+ $self->{'device'}->eject() if (exists $self->{'device'} and
+ exists $params{'eject'} and
+ $params{'eject'});
+
# unref the device, for good measure
$self->{'device'} = undef;