]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/filed/accurate.c
Implement .bvfs_versions command to display all file versions for a client
[bacula/bacula] / bacula / src / filed / accurate.c
index 90e7ff24d3138b99678a921e423b9e3387879bb2..edaa3c2a19e08069363f6fce3371aaf05580f1db 100644 (file)
@@ -6,7 +6,7 @@
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
-   modify it under the terms of version two of the GNU General Public
+   modify it under the terms of version three of the GNU Affero General Public
    License as published by the Free Software Foundation and included
    in the file LICENSE.
 
@@ -15,7 +15,7 @@
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
 
-   You should have received a copy of the GNU General Public License
+   You should have received a copy of the GNU Affero General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
@@ -100,7 +100,7 @@ static bool accurate_send_base_file_list(JCR *jcr)
    FF_PKT *ff_pkt;
    int stream = STREAM_UNIX_ATTRIBUTES;
 
-   if (!jcr->accurate || jcr->get_JobLevel() != L_FULL) {
+   if (!jcr->accurate || jcr->getJobLevel() != L_FULL) {
       return true;
    }
 
@@ -183,16 +183,16 @@ bool accurate_finish(JCR *jcr)
 {
    bool ret=true;
    if (jcr->accurate) {
-      if (jcr->get_JobLevel() == L_FULL) {
+      if (jcr->getJobLevel() == L_FULL) {
          ret = accurate_send_base_file_list(jcr);
       } else {
          ret = accurate_send_deleted_list(jcr);
       }
       
       accurate_free(jcr);
-      if (jcr->get_JobLevel() == L_FULL) {
-         Dmsg1(0, "Space saved with Base jobs: %lld MB\n"
-               jcr->base_size/(1024*1024));
+      if (jcr->getJobLevel() == L_FULL) {
+         Jmsg(jcr, M_INFO, 0, _("Space saved with Base jobs: %lld MB\n")
+              jcr->base_size/(1024*1024));
       }
    }
    return ret;
@@ -242,6 +242,7 @@ bool accurate_check_file(JCR *jcr, FF_PKT *ff_pkt)
    struct stat statc;
    int32_t LinkFIc;
    bool stat = false;
+   char *opts;
    char *fname;
    CurFile elt;
 
@@ -270,11 +271,17 @@ bool accurate_check_file(JCR *jcr, FF_PKT *ff_pkt)
 
    decode_stat(elt.lstat, &statc, &LinkFIc); /* decode catalog stat */
 
+   if (jcr->getJobLevel() == L_FULL) {
+      opts = ff_pkt->BaseJobOpts;
+   } else {
+      opts = ff_pkt->AccurateOpts;
+   }
+
    /*
     * Loop over options supplied by user and verify the
     * fields he requests.
     */
-   for (char *p=ff_pkt->AccurateOpts; !stat && *p; p++) {
+   for (char *p=opts; !stat && *p; p++) {
       char ed1[30], ed2[30];
       switch (*p) {
       case 'i':                /* compare INODEs */
@@ -287,6 +294,9 @@ bool accurate_check_file(JCR *jcr, FF_PKT *ff_pkt)
          }
          break;
       case 'p':                /* permissions bits */
+         /* TODO: If something change only in perm, user, group
+          * Backup only the attribute stream
+          */
          if (statc.st_mode != ff_pkt->statp.st_mode) {
             Dmsg3(dbglvl-1, "%s     st_mode  differ. Cat: %x File: %x\n",
                   fname,
@@ -362,13 +372,21 @@ bool accurate_check_file(JCR *jcr, FF_PKT *ff_pkt)
           * The remainder of the function is all about getting the checksum.
           * First we initialise, then we read files, other streams and Finder Info.
           */
-         if (!stat && *elt.chksum && ff_pkt->type != FT_LNKSAVED && 
+         if (!stat && ff_pkt->type != FT_LNKSAVED && 
              (S_ISREG(ff_pkt->statp.st_mode) && 
               ff_pkt->flags & (FO_MD5|FO_SHA1|FO_SHA256|FO_SHA512))) 
          {
+
+            if (!*elt.chksum) {
+               Jmsg(jcr, M_WARNING, 0, _("Can't verify checksum for %s\n"),
+                    ff_pkt->fname);
+               stat = true;
+               break;
+            }
+
             /*
-             * Create our digest context. If this fails, the digest will be set to NULL
-             * and not used.
+             * Create our digest context. If this fails, the digest will be set
+             * to NULL and not used.
              */
             if (ff_pkt->flags & FO_MD5) {
                digest = crypto_digest_new(jcr, CRYPTO_DIGEST_MD5);
@@ -428,6 +446,7 @@ bool accurate_check_file(JCR *jcr, FF_PKT *ff_pkt)
 
          break;
       case ':':
+      case 'J':
       case 'C':
       default:
          break;
@@ -437,7 +456,7 @@ bool accurate_check_file(JCR *jcr, FF_PKT *ff_pkt)
    /* In Incr/Diff accurate mode, we mark all files as seen
     * When in Full+Base mode, we mark only if the file match exactly
     */
-   if (jcr->get_JobLevel() == L_FULL) {
+   if (jcr->getJobLevel() == L_FULL) {
       if (!stat) {               
          /* compute space saved with basefile */
          jcr->base_size += ff_pkt->statp.st_size;