]> git.sur5r.net Git - bacula/bacula/commitdiff
Correct return code handling for bsf_dev and bsr_dev
authorKern Sibbald <kern@sibbald.com>
Thu, 9 Oct 2003 09:58:24 +0000 (09:58 +0000)
committerKern Sibbald <kern@sibbald.com>
Thu, 9 Oct 2003 09:58:24 +0000 (09:58 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@737 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/kernstodo
bacula/src/stored/block.c
bacula/src/stored/btape.c
bacula/src/stored/dev.c
bacula/src/stored/read_record.c
bacula/src/version.h

index c21fbecea043476da87f49c8e6d3b54271a74a5f..d563ae846864fb174319ff91491bb90d2356034c 100644 (file)
@@ -35,6 +35,7 @@ For 1.33 Testing/Documentation:
   SuSE.
                 
 For 1.33
+- Implement .consolerc for Console
 - I want to restore by file to some date.
 - Implement fast block rejection.
 - Is it really important to make Job name the same to find the
index bbdc478ed6c73db45eb7729d2ebe44df76f2ebf0..358ff6ec998065b4e6775acb839e9f95753008fb 100644 (file)
@@ -491,12 +491,12 @@ int write_block_to_dev(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
       if (dev->state & ST_TAPE && dev_cap(dev, CAP_BSR)) {
 
         /* Now back up over what we wrote and read the last block */
-        if (bsf_dev(dev, 1) != 0 || bsf_dev(dev, 1) != 0) {
+        if (!bsf_dev(dev, 1) || !bsf_dev(dev, 1)) {
            ok = false;
             Jmsg(jcr, M_ERROR, 0, _("Backspace file at EOT failed. ERR=%s\n"), strerror(dev->dev_errno));
         }
         /* Backspace over record */
-        if (ok && bsr_dev(dev, 1) != 0) {
+        if (ok && !bsr_dev(dev, 1)) {
            ok = false;
             Jmsg(jcr, M_ERROR, 0, _("Backspace record at EOT failed. ERR=%s\n"), strerror(dev->dev_errno));
            /*
@@ -668,8 +668,8 @@ reread:
       /* Attempt to reposition to re-read the block */
       if (dev->state & ST_TAPE) {
          Dmsg0(100, "Backspace record for reread.\n");
-        if (bsr_dev(dev, 1) != 0) {
-            Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
+        if (!bsr_dev(dev, 1)) {
+            Jmsg(jcr, M_ERROR, 0, "%s", strerror_dev(dev));
            block->read_len = 0;
            return 0;
         }
index d81f177f9706438391fb11a9e37a0dc257b38852..ee3a24a1f3a0a068935d0347c4fc58f726e4e794 100644 (file)
@@ -414,7 +414,7 @@ static void weofcmd()
 static void eomcmd()
 {
    if (!eod_dev(dev)) {
-      Pmsg1(0, _("Bad status from MTEOD. ERR=%s\n"), strerror_dev(dev));
+      Pmsg1(0, "%s", strerror_dev(dev));
       return;
    } else {
       Pmsg0(0, _("Moved to end of medium.\n"));
@@ -435,10 +435,9 @@ static void eodcmd()
  */
 static void bsfcmd()
 {
-   int stat;
 
-   if ((stat=bsf_dev(dev, 1)) < 0) {
-      Pmsg1(0, _("Bad status from bsf. ERR=%s\n"), strerror(errno));
+   if (!bsf_dev(dev, 1)) {
+      Pmsg1(0, _("Bad status from bsf. ERR=%s\n"), strerror_dev(dev));
    } else {
       Pmsg0(0, _("Backspaced one file.\n"));
    }
@@ -449,10 +448,8 @@ static void bsfcmd()
  */
 static void bsrcmd()
 {
-   int stat;
-
-   if ((stat=bsr_dev(dev, 1)) < 0) {
-      Pmsg1(0, _("Bad status from bsr. ERR=%s\n"), strerror(errno));
+   if (!bsr_dev(dev, 1)) {
+      Pmsg1(0, _("Bad status from bsr. ERR=%s\n"), strerror_dev(dev));
    } else {
       Pmsg0(0, _("Backspaced one record.\n"));
    }
@@ -613,17 +610,17 @@ static int re_read_block_test()
    }
    weofcmd();
    weofcmd();
-   if (bsf_dev(dev, 1) != 0) {
-      Pmsg1(0, _("Backspace file failed! ERR=%s\n"), strerror(dev->dev_errno));
+   if (!bsf_dev(dev, 1)) {
+      Pmsg1(0, _("Backspace file failed! ERR=%s\n"), strerror_dev(dev));
       goto bail_out;
    }
-   if (bsf_dev(dev, 1) != 0) {
-      Pmsg1(0, _("Backspace file failed! ERR=%s\n"), strerror(dev->dev_errno));
+   if (!bsf_dev(dev, 1)) {
+      Pmsg1(0, _("Backspace file failed! ERR=%s\n"), strerror_dev(dev));
       goto bail_out;
    }
    Pmsg0(0, "Backspaced over two EOFs OK.\n");
-   if (bsr_dev(dev, 1) != 0) {
-      Pmsg1(0, _("Backspace record failed! ERR=%s\n"), strerror(dev->dev_errno));
+   if (!bsr_dev(dev, 1)) {
+      Pmsg1(0, _("Backspace record failed! ERR=%s\n"), strerror_dev(dev));
       goto bail_out;
    }
    Pmsg0(0, "Backspace record OK.\n");
index dfde94eba213e7665237b828628ee44912383371..78fe85ef638f30f7dc327e4fa4adc54a119f4ea6 100644 (file)
@@ -418,6 +418,9 @@ eod_dev(DEVICE *dev)
         dev->state |= ST_EOT;
         return 1;
       }
+      dev->dev_errno = errno;
+      Mmsg2(&dev->errmsg, _("lseek error on %s. ERR=%s.\n"),
+            dev->dev_name, strerror(dev->dev_errno));
       return 0;
    }
 #ifdef MTEOM
@@ -465,7 +468,7 @@ eod_dev(DEVICE *dev)
     * the second EOF.
     */
    if (dev_cap(dev, CAP_BSFATEOM)) {
-      stat =  (bsf_dev(dev, 1) == 0);
+      stat =  bsf_dev(dev, 1);
       dev->file++;                   /* keep same file */
    } else {
       update_pos_dev(dev);                  /* update position */
@@ -830,12 +833,14 @@ bsf_dev(DEVICE *dev, int num)
 
    if (dev->fd < 0) {
       dev->dev_errno = EBADF;
-      Mmsg0(&dev->errmsg, _("Bad call to bsf_dev. Archive not open\n"));
+      Mmsg0(&dev->errmsg, _("Bad call to bsf_dev. Archive device not open\n"));
       Emsg0(M_FATAL, 0, dev->errmsg);
       return 0;
    }
 
    if (!(dev_state(dev, ST_TAPE))) {
+      Mmsg1(&dev->errmsg, _("Device %s cannot BSF because it is not a tape.\n"),
+        dev->dev_name);
       return 0;
    }
    Dmsg0(29, "bsf_dev\n");
@@ -1002,7 +1007,7 @@ weof_dev(DEVICE *dev, int num)
 
    if (dev->fd < 0) {
       dev->dev_errno = EBADF;
-      Mmsg0(&dev->errmsg, _("Bad call to weof_dev. Archive not open\n"));
+      Mmsg0(&dev->errmsg, _("Bad call to weof_dev. Archive drive not open\n"));
       Emsg0(M_FATAL, 0, dev->errmsg);
       return -1;
    }
@@ -1021,8 +1026,10 @@ weof_dev(DEVICE *dev, int num)
       dev->file_addr = 0;
    } else {
       clrerror_dev(dev, MTWEOF);
-      Mmsg2(&dev->errmsg, _("ioctl MTWEOF error on %s. ERR=%s.\n"),
-        dev->dev_name, strerror(dev->dev_errno));
+      if (stat == -1) {
+         Mmsg2(&dev->errmsg, _("ioctl MTWEOF error on %s. ERR=%s.\n"),
+           dev->dev_name, strerror(dev->dev_errno));
+       }
    }
    return stat;
 }
index 9528a920db099f19a4d72e8cea292bcb73c458d3..7a8b3c26a472d89d98d1ec8632013896d17c376f 100644 (file)
@@ -115,6 +115,7 @@ int read_records(JCR *jcr,  DEVICE *dev,
         }
       }
       Dmsg2(100, "New block at position=(file:block) %d:%d\n", dev->file, dev->block_num);
+#define FAST_BLOCK_REJECTION
 #ifdef FAST_BLOCK_REJECTION
       /* this does not stop when file/block are too big */
       if (!match_bsr_block(jcr->bsr, block)) {
index 8839fef8674fc5b6feb507ffd5d975bbdd190fad..977a839edb52ffc4e6abc86c5a8cc68b19388f3f 100644 (file)
@@ -1,12 +1,12 @@
 /* */
-#undef VERSION
+#undef  VERSION
 #define VERSION "1.32b"
 #define VSTRING "1"
-#define BDATE   "08 Oct 2003"
-#define LSMDATE "08Oct03"
+#define BDATE   "09 Oct 2003"
+#define LSMDATE "09Oct03"
 
 /* Debug flags */
-#undef DEBUG
+#undef  DEBUG
 #define DEBUG 1
 #define TRACEBACK 1
 #define SMCHECK