]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/filed/backup.c
Correct binfo size per James
[bacula/bacula] / bacula / src / filed / backup.c
index afe9f84daf9d99cf50bae2c064a8e5338cfdbc4c..07bbc264d1c4ca6e25947988c4d3a66c0a71afc3 100644 (file)
@@ -20,7 +20,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Bacula® is a registered trademark of John Walker.
+   Bacula® is a registered trademark of Kern Sibbald.
    The licensor of Bacula is the Free Software Foundation Europe
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
@@ -505,7 +505,7 @@ int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level)
       do_read = true;
    }
 
-   Dmsg1(100, "do_read=%d\n", do_read);
+   Dmsg1(400, "do_read=%d\n", do_read);
    if (do_read) {
       btimer_t *tid;
 
@@ -831,19 +831,21 @@ int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, DIGEST *digest,
       /* Check for sparse blocks */
       if (ff_pkt->flags & FO_SPARSE) {
          ser_declare;
-         bool haveBlock = true;
+         bool allZeros = false;
          if (sd->msglen == rsize &&
              fileAddr+sd->msglen < (uint64_t)ff_pkt->statp.st_size ||
              ((ff_pkt->type == FT_RAW || ff_pkt->type == FT_FIFO) &&
                (uint64_t)ff_pkt->statp.st_size == 0)) {
-            haveBlock = !is_buf_zero(rbuf, rsize);
+            allZeros = is_buf_zero(rbuf, rsize);
          }
-         if (haveBlock) {
+         if (!allZeros) {
+            /* Put file address as first data in buffer */
             ser_begin(wbuf, SPARSE_FADDR_SIZE);
             ser_uint64(fileAddr);     /* store fileAddr in begin of buffer */
          }
          fileAddr += sd->msglen;      /* update file address */
-         if (!haveBlock) {
+         /* Skip block of all zeros */
+         if (allZeros) {
             continue;                 /* skip block of zeros */
          }
       }
@@ -1169,9 +1171,9 @@ static bool do_strip(int count, char *in)
 
    /* Copy to first path separator -- Win32 might have c: ... */
    while (*in && !IsPathSeparator(*in)) {    
-      *out++ = *in++;
+      out++; in++;
    }
-   *out++ = *in++;
+   out++; in++;
    numsep++;                     /* one separator seen */
    for (stripped=0; stripped<count && *in; stripped++) {
       while (*in && !IsPathSeparator(*in)) {
@@ -1213,6 +1215,12 @@ void strip_path(FF_PKT *ff_pkt)
      ff_pkt->link_save = get_pool_memory(PM_FNAME);
    }
    pm_strcpy(ff_pkt->fname_save, ff_pkt->fname);
+   if (ff_pkt->type != FT_LNK && ff_pkt->fname != ff_pkt->link) {
+      pm_strcpy(ff_pkt->link_save, ff_pkt->link);
+      Dmsg2(500, "strcpy link_save=%d link=%d\n", strlen(ff_pkt->link_save),
+         strlen(ff_pkt->link));
+      sm_check(__FILE__, __LINE__, true);
+   }
 
    /* 
     * Strip path.  If it doesn't succeed put it back.  If
@@ -1222,19 +1230,20 @@ void strip_path(FF_PKT *ff_pkt)
     * Do not strip symlinks.
     * I.e. if either stripping fails don't strip anything.
     */
-   if (do_strip(ff_pkt->strip_path, ff_pkt->fname)) {
-      /* Strip links but not symlinks */
-      if (ff_pkt->type != FT_LNK && ff_pkt->fname != ff_pkt->link) {
-         pm_strcpy(ff_pkt->link_save, ff_pkt->link);
-         if (!do_strip(ff_pkt->strip_path, ff_pkt->link)) {
-            strcpy(ff_pkt->link, ff_pkt->link_save);
-            strcpy(ff_pkt->fname, ff_pkt->fname_save);
-         }
-      }
-   } else {
-      strcpy(ff_pkt->fname, ff_pkt->fname_save);
+   if (!do_strip(ff_pkt->strip_path, ff_pkt->fname)) {
+      unstrip_path(ff_pkt);
+      goto rtn;
    } 
-   Dmsg2(200, "fname=%s stripped=%s\n", ff_pkt->fname_save, ff_pkt->fname);
+   /* Strip links but not symlinks */
+   if (ff_pkt->type != FT_LNK && ff_pkt->fname != ff_pkt->link) {
+      if (!do_strip(ff_pkt->strip_path, ff_pkt->link)) {
+         unstrip_path(ff_pkt);
+      }
+   }
+
+rtn:
+   Dmsg3(100, "fname=%s stripped=%s link=%s\n", ff_pkt->fname_save, ff_pkt->fname, 
+       ff_pkt->link);
 }
 
 void unstrip_path(FF_PKT *ff_pkt)
@@ -1244,6 +1253,11 @@ void unstrip_path(FF_PKT *ff_pkt)
    }
    strcpy(ff_pkt->fname, ff_pkt->fname_save);
    if (ff_pkt->type != FT_LNK && ff_pkt->fname != ff_pkt->link) {
+      Dmsg2(500, "strcpy link=%s link_save=%s\n", ff_pkt->link,
+          ff_pkt->link_save);
       strcpy(ff_pkt->link, ff_pkt->link_save);
+      Dmsg2(500, "strcpy link=%d link_save=%d\n", strlen(ff_pkt->link),
+          strlen(ff_pkt->link_save));
+      sm_check(__FILE__, __LINE__, true);
    }
 }