src/stored/dircmd.c
static void read_volume_label(JCR *jcr, DCR *dcr, DEVICE *dev, int Slot)
{
   BSOCK *dir = jcr->dir_bsock;
   bsteal_lock_t hold;

   dcr->set_dev(dev);
   if (!obtain_device_block(dev,
                            &hold,
                            1 /* one try */,
                            BST_WRITING_LABEL)) {
      send_dir_busy_message(dir, dev);
      return;
   }
   dev->Unlock();

   if (!try_autoload_device(jcr, dcr, Slot, "")) {
      goto bail_out;                  /* error */
   }

   dev->clear_labeled();              /* force read of label */
   switch (dev->read_dev_volume_label(dcr)) {
   case VOL_OK:
      /* DO NOT add quotes around the Volume name. It is scanned in the DIR */
      dir->fsend(_("3001 Volume=%s Slot=%d\n"), dev->VolHdr.VolumeName, Slot);
      Dmsg1(100, "Volume: %s\n", dev->VolHdr.VolumeName);
      break;
   default:
      dir->fsend(_("3902 Cannot mount Volume on Storage Device \"%s\" because:\n%s"),
                 dev->print_name(), jcr->errmsg);
      break;
   }

bail_out:
   dev->Lock();
   give_back_device_block(dev, &hold);
   return;
}
/*
 * Read the tape label
 *
 *  Enter with the mutex set
 */
Read the tape label
Enter with the mutex set
Read the tape label Enter with the mutex set
static void read_volume_label(JCR *jcr, DCR *dcr, DEVICE *dev, int Slot)
{
   BSOCK *dir = jcr->dir_bsock;
   bsteal_lock_t hold;
   dcr->set_dev(dev);
   if (!obtain_device_block(dev,
                            &hold,
                            1 ,
                            BST_WRITING_LABEL)) {
      send_dir_busy_message(dir, dev);
      return;
   }
   dev->Unlock();
   if (!try_autoload_device(jcr, dcr, Slot, "")) {
      goto bail_out;                  
   }
   dev->clear_labeled();              
   switch (dev->read_dev_volume_label(dcr)) {
   case VOL_OK:
      dir->fsend(_("3001 Volume=%s Slot=%d\n"), dev->VolHdr.VolumeName, Slot);
      Dmsg1(100, "Volume: %s\n", dev->VolHdr.VolumeName);
      break;
   default:
      dir->fsend(_("3902 Cannot mount Volume on Storage Device \"%s\" because:\n%s"),
                 dev->print_name(), jcr->errmsg);
      break;
   }
bail_out:
   dev->Lock();
   give_back_device_block(dev, &hold);
   return;
}
static void read_volume_label ( JCR * jcr , DCR * dcr , DEVICE * dev , int Slot ) { BSOCK * dir = jcr -> dir_bsock ; bsteal_lock_t hold ; dcr -> set_dev ( dev ) ; if ( ! obtain_device_block ( dev , & hold , 1 , BST_WRITING_LABEL ) ) { send_dir_busy_message ( dir , dev ) ; return ; } dev -> Unlock ( ) ; if ( ! try_autoload_device ( jcr , dcr , Slot , " " ) ) { goto bail_out ; } dev -> clear_labeled ( ) ; switch ( dev -> read_dev_volume_label ( dcr ) ) { case VOL_OK : dir -> fsend ( _ ( " \n " ) , dev -> VolHdr . VolumeName , Slot ) ; Dmsg1 ( 100 , " \n " , dev -> VolHdr . VolumeName ) ; break ; default : dir -> fsend ( _ ( " \" \" \n " ) , dev -> print_name ( ) , jcr -> errmsg ) ; break ; } bail_out : dev -> Lock ( ) ; give_back_device_block ( dev , & hold ) ; return ; }
Read the tape label
  Enter with the mutex set
Read the tape label Enter with the mutex set
/* one try */ /* error */ /* force read of label */ /* DO NOT add quotes around the Volume name. It is scanned in the DIR */