]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/filed/backup.c
Merge branch 'master' into basejobv3
[bacula/bacula] / bacula / src / filed / backup.c
index f098c96ee51a7265debb06267ef9c01b95dd7ee4..e92f880b4f7d7102f47ffd6629c70fbcfc3a51b6 100644 (file)
 #include "bacula.h"
 #include "filed.h"
 
+#if defined(HAVE_ACL)
+const bool have_acl = true;
+#else
+const bool have_acl = false;
+#endif
+
+#if defined(HAVE_XATTR)
+const bool have_xattr = true;
+#else
+const bool have_xattr = false;
+#endif
+
 /* Forward referenced functions */
 int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level);
 static int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, DIGEST *digest, DIGEST *signature_digest);
@@ -128,8 +140,14 @@ bool blast_data_to_storage_daemon(JCR *jcr, char *addr)
    
    start_heartbeat_monitor(jcr);
 
-   jcr->acl_data = get_pool_memory(PM_MESSAGE);
-   jcr->xattr_data = get_pool_memory(PM_MESSAGE);
+   if (have_acl) {
+      jcr->acl_data = get_pool_memory(PM_MESSAGE);
+      jcr->total_acl_errors = 0;
+   }
+   if (have_xattr) {
+      jcr->xattr_data = get_pool_memory(PM_MESSAGE);
+      jcr->total_xattr_errors = 0;
+   }
 
    /* Subroutine save_file() is called for each file */
    if (!find_files(jcr, (FF_PKT *)jcr->ff, save_file, plugin_save)) {
@@ -137,17 +155,26 @@ bool blast_data_to_storage_daemon(JCR *jcr, char *addr)
       set_jcr_job_status(jcr, JS_ErrorTerminated);
    }
 
-   accurate_send_deleted_list(jcr);              /* send deleted list to SD  */
+   if (jcr->total_acl_errors > 0) {
+      Jmsg(jcr, M_ERROR, 0, _("Encountered %ld acl errors while doing backup\n"),
+           jcr->total_acl_errors);
+   }
+   if (jcr->total_xattr_errors > 0) {
+      Jmsg(jcr, M_ERROR, 0, _("Encountered %ld xattr errors while doing backup\n"),
+           jcr->total_xattr_errors);
+   }
+
+   accurate_finish(jcr);              /* send deleted or base file list to SD */
 
    stop_heartbeat_monitor(jcr);
 
    sd->signal(BNET_EOD);            /* end of sending data */
 
-   if (jcr->acl_data) {
+   if (have_acl && jcr->acl_data) {
       free_pool_memory(jcr->acl_data);
       jcr->acl_data = NULL;
    }
-   if (jcr->xattr_data) {
+   if (have_xattr && jcr->xattr_data) {
       free_pool_memory(jcr->xattr_data);
       jcr->xattr_data = NULL;
    }
@@ -580,22 +607,50 @@ int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level)
 #endif
 
    /*
-    * Save ACLs for anything not being a symlink and not being a plugin.
+    * Save ACLs when requested and available for anything not being a symlink and not being a plugin.
     */
-   if (!ff_pkt->cmd_plugin) {
-      if (ff_pkt->flags & FO_ACL && ff_pkt->type != FT_LNK) {
-         if (!build_acl_streams(jcr, ff_pkt))
+   if (have_acl) {
+      if (ff_pkt->flags & FO_ACL && ff_pkt->type != FT_LNK && !ff_pkt->cmd_plugin) {
+         switch (build_acl_streams(jcr, ff_pkt)) {
+         case bacl_exit_fatal:
             goto bail_out;
+         case bacl_exit_error:
+            /*
+             * Non-fatal errors, count them and when the number is under ACL_REPORT_ERR_MAX_PER_JOB
+             * print the error message set by the lower level routine in jcr->errmsg.
+             */
+            if (jcr->total_acl_errors < ACL_REPORT_ERR_MAX_PER_JOB) {
+               Jmsg(jcr, M_ERROR, 0, "%s", jcr->errmsg);
+            }
+            jcr->total_acl_errors++;
+            break;
+         case bacl_exit_ok:
+            break;
+         }
       }
    }
 
    /*
-    * Save Extended Attributes for all files not being a plugin.
+    * Save Extended Attributes when requested and available for all files not being a plugin.
     */
-   if (!ff_pkt->cmd_plugin) {
-      if (ff_pkt->flags & FO_XATTR) {
-         if (!build_xattr_streams(jcr, ff_pkt))
+   if (have_xattr) {
+      if (ff_pkt->flags & FO_XATTR && !ff_pkt->cmd_plugin) {
+         switch (build_xattr_streams(jcr, ff_pkt)) {
+         case bxattr_exit_fatal:
             goto bail_out;
+         case bxattr_exit_error:
+            /*
+             * Non-fatal errors, count them and when the number is under XATTR_REPORT_ERR_MAX_PER_JOB
+             * print the error message set by the lower level routine in jcr->errmsg.
+             */
+            if (jcr->total_xattr_errors < XATTR_REPORT_ERR_MAX_PER_JOB) {
+               Jmsg(jcr, M_ERROR, 0, "%s", jcr->errmsg);
+            }
+            jcr->total_xattr_errors++;
+            break;
+         case bxattr_exit_ok:
+            break;
+         }
       }
    }