]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/block.c
Add mac.c file
[bacula/bacula] / bacula / src / stored / block.c
index 1461f777144db3c830f4af549635e10b4b4cff23..a7e7fe1cf443db4d3f4527a8e09136c5452e11d0 100644 (file)
@@ -9,7 +9,7 @@
  *
  */
 /*
-   Copyright (C) 2001-2005 Kern Sibbald
+   Copyright (C) 2001-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
@@ -49,6 +49,7 @@ void dump_block(DEV_BLOCK *b, const char *msg)
    int32_t  FileIndex;
    int32_t  Stream;
    int bhl, rhl;
+   char buf1[100], buf2[100];
 
    unser_begin(b->buf, BLKHDR1_LENGTH);
    unser_uint32(CheckSum);
@@ -89,8 +90,8 @@ void dump_block(DEV_BLOCK *b, const char *msg)
       unser_int32(Stream);
       unser_uint32(data_len);
       Pmsg6(000, _("   Rec: VId=%u VT=%u FI=%s Strm=%s len=%d p=%x\n"),
-           VolSessionId, VolSessionTime, FI_to_ascii(FileIndex),
-           stream_to_ascii(Stream, FileIndex), data_len, p);
+           VolSessionId, VolSessionTime, FI_to_ascii(buf1, FileIndex),
+           stream_to_ascii(buf2, Stream, FileIndex), data_len, p);
       p += data_len + rhl;
   }
 }
@@ -612,13 +613,13 @@ static void reread_last_block(DCR *dcr)
     */
    if (dev->is_tape() && dev_cap(dev, CAP_BSR)) {
       /* Now back up over what we wrote and read the last block */
-      if (!bsf_dev(dev, 1)) {
+      if (!dev->bsf(1)) {
          berrno be;
          ok = false;
          Jmsg(jcr, M_ERROR, 0, _("Backspace file at EOT failed. ERR=%s\n"), 
               be.strerror(dev->dev_errno));
       }
-      if (ok && dev_cap(dev, CAP_TWOEOF) && !bsf_dev(dev, 1)) {
+      if (ok && dev->has_cap(CAP_TWOEOF) && !dev->bsf(1)) {
          berrno be;
          ok = false;
          Jmsg(jcr, M_ERROR, 0, _("Backspace file at EOT failed. ERR=%s\n"), 
@@ -681,7 +682,7 @@ static bool terminate_writing_volume(DCR *dcr)
    dcr->block->write_failed = true;
    if (weof_dev(dev, 1) != 0) {         /* end the tape */
       dev->VolCatInfo.VolCatErrors++;
-      Jmsg(dcr->jcr, M_ERROR, 0, _("Error writing final EOF to tape. This tape may not be readable.\n"
+      Jmsg(dcr->jcr, M_ERROR, 0, _("Error writing final EOF to tape. This Volume may not be readable.\n"
            "%s"), dev->errmsg);
       ok = false;
       Dmsg0(100, "WEOF error.\n");
@@ -693,8 +694,9 @@ static bool terminate_writing_volume(DCR *dcr)
    dev->VolCatInfo.VolCatFiles = dev->file;   /* set number of files */
    dev->VolCatInfo.VolCatJobs++;              /* increment number of jobs */
    
-   if (dev->is_dvd()) { /* Write the current (and last) part. */
-      open_next_part(dcr);
+   if (dev->is_dvd()) {
+      dvd_write_part(dcr);                 /* write last part */
+      dev->VolCatInfo.VolCatParts = dev->num_parts;
    }
    
    if (!dir_update_volume_info(dcr, false)) {
@@ -781,11 +783,14 @@ static bool do_dvd_size_checks(DCR *dcr)
    JCR *jcr = dcr->jcr;
    DEV_BLOCK *block = dcr->block;
 
+   /* Don't go further if the device is not a dvd */
+   if (!dev->is_dvd()) {
+      return true;
+   }
+   
    /* Limit maximum part size to value specified by user 
-    * (not applicable to tapes/fifos)   
     */
-   if (!(dev->is_tape() || dev->is_fifo()) && dev->max_part_size > 0 &&
-        (dev->part_size + block->binbuf) >= dev->max_part_size) {
+   if (dev->max_part_size > 0 && ((dev->part_size + block->binbuf) >= dev->max_part_size)) {
       if (dev->part < dev->num_parts) {
          Jmsg3(dcr->jcr, M_FATAL, 0, _("Error while writing, current part number"
                " is less than the total number of parts (%d/%d, device=%s)\n"),
@@ -794,7 +799,7 @@ static bool do_dvd_size_checks(DCR *dcr)
          return false;
       }
       
-      if (open_next_part(dcr) < 0) {
+      if (dvd_open_next_part(dcr) < 0) {
          Jmsg2(dcr->jcr, M_FATAL, 0, _("Unable to open device next part %s: ERR=%s\n"),
                 dev->print_name(), strerror_dev(dev));
          dev->dev_errno = EIO;
@@ -810,7 +815,7 @@ static bool do_dvd_size_checks(DCR *dcr)
       }
    }
    
-   if (dev->free_space_errno < 0) { /* Error while getting free space */
+   if (!dev->is_freespace_ok()) { /* Error while getting free space */
       char ed1[50], ed2[50];
       Dmsg1(10, "Cannot get free space on the device ERR=%s.\n", dev->errmsg);
       Jmsg(jcr, M_FATAL, 0, _("End of Volume \"%s\" at %u:%u on device %s "
@@ -819,11 +824,11 @@ static bool do_dvd_size_checks(DCR *dcr)
            dev->file, dev->block_num, dev->print_name(),
            edit_uint64_with_commas(dev->part_size, ed1), edit_uint64_with_commas(dev->free_space, ed2),
            dev->free_space_errno, dev->errmsg);
-      dev->dev_errno = -dev->free_space_errno;
+      dev->dev_errno = dev->free_space_errno;
       return false;
    }
    
-   if ((dev->free_space_errno > 0 && (dev->part_size + block->binbuf) >= dev->free_space)) {
+   if ((dev->is_freespace_ok() && (dev->part_size + block->binbuf) >= dev->free_space)) {
       char ed1[50], ed2[50];
       Dmsg0(10, "==== Just enough free space on the device to write the current part...\n");
       Jmsg(jcr, M_INFO, 0, _("End of Volume \"%s\" at %u:%u on device %s "
@@ -904,7 +909,7 @@ reread:
    if ((dev->num_parts > 0) &&
         ((dev->file_addr-dev->part_start) == dev->part_size) && 
         (dev->part < dev->num_parts)) {
-      if (open_next_part(dcr) < 0) {
+      if (dvd_open_next_part(dcr) < 0) {
          Jmsg2(dcr->jcr, M_FATAL, 0, _("Unable to open device next part %s: ERR=%s\n"),
                dev->print_name(), strerror_dev(dev));
          dev->dev_errno = EIO;