+ $self->with_locked_state($self->{'state_filename'},
+ $params{'finished_cb'}, sub {
+ my ($state, $finished_cb) = @_;
+
+ $slot = (scalar @slots)? $slots[0] : 0;
+ $self->_set_current($slot);
+
+ $finished_cb->();
+ });
+}
+
+sub inventory {
+ my $self = shift;
+ my %params = @_;
+
+ return if $self->check_error($params{'inventory_cb'});
+
+ my @slots = $self->_all_slots();
+
+ $self->with_locked_state($self->{'state_filename'},
+ $params{'inventory_cb'}, sub {
+ my ($state, $finished_cb) = @_;
+ my @inventory;
+
+ my $current = $self->_get_current();
+ for my $slot (@slots) {
+ my $s = { slot => $slot, state => Amanda::Changer::SLOT_FULL };
+ $s->{'reserved'} = $self->_is_slot_in_use($state, $slot);
+ my $label = $self->_get_slot_label($slot);
+ if ($label) {
+ $s->{'label'} = $self->_get_slot_label($slot);
+ $s->{'f_type'} = "".$Amanda::Header::F_TAPESTART;
+ } else {
+ $s->{'label'} = undef;
+ $s->{'f_type'} = "".$Amanda::Header::F_EMPTY;
+ }
+ $s->{'device_status'} = "".$DEVICE_STATUS_SUCCESS;
+ $s->{'current'} = 1 if $slot eq $current;
+ push @inventory, $s;
+ }
+ $finished_cb->(undef, \@inventory);
+ });