]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/btape.c
kes Apply Richard Mortimer's patches for printing an error
[bacula/bacula] / bacula / src / stored / btape.c
index f3c4b4d55ee7a4882a40bb882e4a55e20e575592..43c00d64d9f991734b9379bfa392b5b73c6cb026 100644 (file)
@@ -152,6 +152,7 @@ int main(int margc, char *margv[])
    setlocale(LC_ALL, "");
    bindtextdomain("bacula", LOCALEDIR);
    textdomain("bacula");
+   init_stack_dump();
 
    /* Sanity checks */
    if (TAPE_BSIZE % B_DEV_BSIZE != 0 || TAPE_BSIZE / B_DEV_BSIZE == 0) {
@@ -269,6 +270,16 @@ int main(int margc, char *margv[])
    if (!dev) {
       exit(1);
    }
+   if (dev->is_dvd()) {
+      Pmsg0(000, _("btape does not work with DVD storage.\n"));
+      usage();
+      exit(1);
+   }
+   if (!dev->is_tape()) {
+      Pmsg0(000, _("btape only works with tape storage.\n"));
+      usage();
+      exit(1);
+   }
    dcr = jcr->dcr;
    if (!open_the_device()) {
       goto terminate;
@@ -2687,7 +2698,6 @@ bool dir_ask_sysop_to_mount_volume(DCR *dcr)
    if (dcr->VolumeName[0] == 0) {
       return dir_ask_sysop_to_create_appendable_volume(dcr);
    }
-   dev->close();
    Pmsg1(-1, "%s", dev->errmsg);           /* print reason */
    if (dcr->VolumeName[0] == 0 || strcmp(dcr->VolumeName, "TestVolume2") == 0) {
       fprintf(stderr, _("Mount second Volume on device %s and press return when ready: "),
@@ -2696,6 +2706,7 @@ bool dir_ask_sysop_to_mount_volume(DCR *dcr)
       fprintf(stderr, _("Mount Volume \"%s\" on device %s and press return when ready: "),
          dcr->VolumeName, dev->print_name());
    }
+   dev->close();
    getchar();
    return true;
 }
@@ -2716,9 +2727,9 @@ bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr)
    }
    autochanger = autoload_device(dcr, 1, NULL);
    if (!autochanger) {
-      dev->close();
       fprintf(stderr, _("Mount blank Volume on device %s and press return when ready: "),
          dev->print_name());
+      dev->close();
       getchar();
    }
    open_device(dcr);