]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/dev.c
kes Fix mtx-changer to detect both versions of Ubuntu (Debian)
[bacula/bacula] / bacula / src / stored / dev.c
index 793a7a274095e46d94b657460b9a96ff38b5e73e..0e72db6a84530de7182b80d605238ad46ff934b3 100644 (file)
@@ -128,7 +128,7 @@ init_dev(JCR *jcr, DEVRES *device)
       } else if (S_ISFIFO(statp.st_mode)) {
          device->dev_type = B_FIFO_DEV;
 #ifdef USE_VTAPE
-      /* must set DeviceType = Faketape 
+      /* must set DeviceType = Vtape 
        * in normal mode, autodetection is disabled
        */
       } else if (S_ISREG(statp.st_mode)) { 
@@ -275,29 +275,39 @@ init_dev(JCR *jcr, DEVRES *device)
 /* Choose the right backend */
 void DEVICE::init_backend()
 {
-   if (is_vtape()) {
-      d_open  = vtape_open;
-      d_write = vtape_write;
-      d_close = vtape_close;
-      d_ioctl = vtape_ioctl;
-      d_read  = vtape_read;
 
 #ifdef HAVE_WIN32
-   } else if (is_tape()) {
+   if (is_tape()) {
       d_open  = win32_tape_open;
       d_write = win32_tape_write;
       d_close = win32_tape_close;
       d_ioctl = win32_tape_ioctl;
       d_read  = win32_tape_read;
-#endif
 
    } else {
+      d_open  = ::open;
+      d_close = ::close;
+      d_ioctl = win32_ioctl;    /* dummy function */
+      d_write = win32_write;    /* win32 read/write are not POSIX */
+      d_read  = win32_read;
+   }
+
+#else  /* POSIX / UNIX Interface */
+   if (is_vtape()) {            /* test backend */
+      d_open  = vtape_open;     /* vtape isn't available for WIN32 or FreeBSD */
+      d_write = vtape_write;
+      d_close = vtape_close;
+      d_ioctl = vtape_ioctl;
+      d_read  = vtape_read;
+
+   } else {                     /* tape and file are using normal io */
       d_open  = ::open;
       d_write = ::write;
       d_close = ::close;
       d_ioctl = ::ioctl;
       d_read  = ::read;
    }
+#endif
 }
 
 /*
@@ -1677,7 +1687,7 @@ bool DEVICE::weof(int num)
 {
    struct mtop mt_com;
    int stat;
-   Dmsg0(129, "weof_dev\n");
+   Dmsg1(129, "=== weof_dev=%s\n", print_name());
    
    if (!is_open()) {
       dev_errno = EBADF;
@@ -1862,6 +1872,18 @@ void DEVICE::clrerror(int func)
 }
 
 
+/*
+ * Set to unload the current volume in the drive
+ */
+void DEVICE::set_unload()
+{
+   if (!m_unload && VolHdr.VolumeName[0] != 0) {
+       m_unload = true;
+       memcpy(UnloadVolName, VolHdr.VolumeName, sizeof(UnloadVolName));
+   }
+}
+
+
 /*
  * Clear volume header
  */
@@ -2404,7 +2426,6 @@ void init_device_wait_timers(DCR *dcr)
    dev->rem_wait_sec = dev->wait_sec;
    dev->num_wait = 0;
    dev->poll = false;
-   dev->BadVolName[0] = 0;
 
    jcr->min_wait = 60 * 60;
    jcr->max_wait = 24 * 60 * 60;