]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/dev.c
Extend idea of Prefer Mounted Volumes to mean a volume about
[bacula/bacula] / bacula / src / stored / dev.c
index 802b0647a91e7fe98726721b9bf181da215cfbdb..4c9e0d20c0780f9b6bac11901125e8b223e95bc9 100644 (file)
@@ -254,6 +254,7 @@ init_dev(JCR *jcr, DEVRES *device)
    dev->clear_opened();
    dev->attached_dcrs = New(dlist(dcr, &dcr->dev_link));
    Dmsg2(29, "init_dev: tape=%d dev_name=%s\n", dev->is_tape(), dev->dev_name);
+   dev->initiated = true;
    
    return dev;
 }
@@ -1809,14 +1810,10 @@ void DEVICE::clrerror(int func)
    /* On some systems such as NetBSD, this clears all errors */
    get_os_tape_file();
 
-/* Found on Linux */
+/* Found on Solaris */
 #ifdef MTIOCLRERR
 {
-   struct mtop mt_com;
-   mt_com.mt_op = MTIOCLRERR;
-   mt_com.mt_count = 1;
-   /* Clear any error condition on the tape */
-   tape_ioctl(m_fd, MTIOCTOP, (char *)&mt_com);
+   tape_ioctl(m_fd, MTIOCLRERR);
    Dmsg0(200, "Did MTIOCLRERR\n");
 }
 #endif
@@ -1852,7 +1849,10 @@ void DEVICE::clrerror(int func)
  */
 void DEVICE::clear_volhdr()
 {
-   free_volume(this);
+   /* If we have an unused volume associated with this drive, free it */
+   if (vol && !is_busy()) {
+      free_volume(this);
+   }
    Dmsg1(100, "Clear volhdr vol=%s\n", VolHdr.VolumeName);
    memset(&VolHdr, 0, sizeof(VolHdr));
 }