]> git.sur5r.net Git - bacula/bacula/commitdiff
Replace ASSERT in block.c with fail Job
authorKern Sibbald <kern@sibbald.com>
Sat, 3 Apr 2010 18:55:57 +0000 (20:55 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 3 Apr 2010 19:00:16 +0000 (21:00 +0200)
bacula/src/stored/block.c

index e4a12fe9342b2e062f7a5af121e082799731432d..313a3dde6f84951cec79a69df9ac74edb53658eb 100644 (file)
@@ -418,25 +418,31 @@ bool write_block_to_dev(DCR *dcr)
    if (job_canceled(jcr)) {
       return false;
    }
+
    ASSERT(block->binbuf == ((uint32_t) (block->bufp - block->buf)));
-   ASSERT(dev->is_open());
+
+   wlen = block->binbuf;
+   if (wlen <= WRITE_BLKHDR_LENGTH) {  /* Does block have data in it? */
+      Dmsg0(100, "return write_block_to_dev no data to write\n");
+      return true;
+   }
 
    /* dump_block(block, "before write"); */
    if (dev->at_weot()) {
       Dmsg0(100, "return write_block_to_dev with ST_WEOT\n");
       dev->dev_errno = ENOSPC;
-      Jmsg0(jcr, M_FATAL, 0,  _("Cannot write block. Device at EOM.\n"));
+      Jmsg1(jcr, M_FATAL, 0,  _("Cannot write block. Device at EOM. dev=%s\n"), dev->print_name());
       return false;
    }
    if (!dev->can_append()) {
       dev->dev_errno = EIO;
-      Jmsg(jcr, M_FATAL, 0, _("Attempt to write on read-only Volume.\n"));
+      Jmsg1(jcr, M_FATAL, 0, _("Attempt to write on read-only Volume. dev=%s\n"), dev->print_name());
       return false;
    }
-   wlen = block->binbuf;
-   if (wlen <= WRITE_BLKHDR_LENGTH) {  /* Does block have data in it? */
-      Dmsg0(100, "return write_block_to_dev no data to write\n");
-      return true;
+
+   if (!dev->is_open()) {
+      Jmsg1(jcr, M_FATAL, 0, _("Attempt to write on closed device=%s\n"), dev->print_name());
+      return false;
    }
    /*
     * Clear to the end of the buffer if it is not full,