src/stored/dircmd.c
static bool read_label(DCR *dcr)
{
   int ok;
   JCR *jcr = dcr->jcr;
   BSOCK *dir = jcr->dir_bsock;
   bsteal_lock_t hold;
   DEVICE *dev = dcr->dev;

   if (!obtain_device_block(dev,
                            &hold,
                            1 /* one try */,
                            BST_DOING_ACQUIRE)) {
      send_dir_busy_message(dir, dev);
      return false;
   }
   dev->Unlock();
   dcr->VolumeName[0] = 0;
   dev->clear_labeled();              /* force read of label */
   switch (dev->read_dev_volume_label(dcr)) {
   case VOL_OK:
      dir->fsend(_("3001 Mounted Volume: %s\n"), dev->VolHdr.VolumeName);
      ok = true;
      break;
   default:
      dir->fsend(_("3902 Cannot mount Volume on Storage Device \"%s\" because:\n%s"),
         dev->print_name(), jcr->errmsg);
      ok = false;
      break;
   }
   volume_unused(dcr);
   dev->Lock();
   give_back_device_block(dev, &hold);
   return ok;
}
/*
 * 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 bool read_label(DCR *dcr)
{
   int ok;
   JCR *jcr = dcr->jcr;
   BSOCK *dir = jcr->dir_bsock;
   bsteal_lock_t hold;
   DEVICE *dev = dcr->dev;
   if (!obtain_device_block(dev,
                            &hold,
                            1 ,
                            BST_DOING_ACQUIRE)) {
      send_dir_busy_message(dir, dev);
      return false;
   }
   dev->Unlock();
   dcr->VolumeName[0] = 0;
   dev->clear_labeled();              
   switch (dev->read_dev_volume_label(dcr)) {
   case VOL_OK:
      dir->fsend(_("3001 Mounted Volume: %s\n"), dev->VolHdr.VolumeName);
      ok = true;
      break;
   default:
      dir->fsend(_("3902 Cannot mount Volume on Storage Device \"%s\" because:\n%s"),
         dev->print_name(), jcr->errmsg);
      ok = false;
      break;
   }
   volume_unused(dcr);
   dev->Lock();
   give_back_device_block(dev, &hold);
   return ok;
}
static bool read_label ( DCR * dcr ) { int ok ; JCR * jcr = dcr -> jcr ; BSOCK * dir = jcr -> dir_bsock ; bsteal_lock_t hold ; DEVICE * dev = dcr -> dev ; if ( ! obtain_device_block ( dev , & hold , 1 , BST_DOING_ACQUIRE ) ) { send_dir_busy_message ( dir , dev ) ; return false ; } dev -> Unlock ( ) ; dcr -> VolumeName [ 0 ] = 0 ; dev -> clear_labeled ( ) ; switch ( dev -> read_dev_volume_label ( dcr ) ) { case VOL_OK : dir -> fsend ( _ ( " \n " ) , dev -> VolHdr . VolumeName ) ; ok = true ; break ; default : dir -> fsend ( _ ( " \" \" \n " ) , dev -> print_name ( ) , jcr -> errmsg ) ; ok = false ; break ; } volume_unused ( dcr ) ; dev -> Lock ( ) ; give_back_device_block ( dev , & hold ) ; return ok ; }
Read the tape label
  Enter with the mutex set
Read the tape label Enter with the mutex set
/* one try */ /* force read of label */