]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/filed/xattr.c
Fix bug #1811 Filed fails to backup more then one xattr.
[bacula/bacula] / bacula / src / filed / xattr.c
index a0ee5926255369bd52afc72735cb3eef35c51a84..d91b602fd2e382c5a4855a19ab02dfc2be8afc0b 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.
@@ -208,7 +208,6 @@ static bxattr_exit_code unserialize_xattr_stream(JCR *jcr, alist *xattr_value_li
 {
    unser_declare;
    xattr_t *current_xattr;
-   bxattr_exit_code retval = bxattr_exit_ok;
 
    /*
     * Parse the stream and call restore_xattr_on_file for each extended attribute.
@@ -277,7 +276,7 @@ static bxattr_exit_code unserialize_xattr_stream(JCR *jcr, alist *xattr_value_li
    }
 
    unser_end(jcr->xattr_data->content, jcr->xattr_data->content_length);
-   return retval;
+   return bxattr_exit_ok;
 }
 #endif
 
@@ -532,12 +531,12 @@ static bxattr_exit_code linux_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt)
             free(current_xattr);
             goto bail_out;
          }
+         break;
       }
 
       xattr_value_list->append(current_xattr);
       xattr_count++;
       bp = strchr(bp, '\0') + 1;
-      break;
    }
 
    free(xattr_list);
@@ -960,11 +959,9 @@ static bxattr_exit_code bsd_build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt)
       /*
        * Send the datastream to the SD.
        */
-      return send_xattr_stream(jcr, os_default_xattr_streams[0]);
+      retval = send_xattr_stream(jcr, os_default_xattr_streams[0]);
    } else {
-      xattr_drop_internal_table(xattr_value_list);
-
-      return bxattr_exit_ok;
+      retval = bxattr_exit_ok;
    }
 
 bail_out:
@@ -1669,35 +1666,36 @@ static bxattr_exit_code solaris_save_xattr(JCR *jcr, int fd, const char *xattr_n
       break;
    }
 
-   if (retval) {
-      retval = send_xattr_stream(jcr, stream);
-      if (retval == bxattr_exit_ok) {
-         jcr->xattr_data->nr_saved++;
-      }
+   /*
+    * We build a new xattr stream send it to the SD.
+    */
+   retval = send_xattr_stream(jcr, stream);
+   if (retval != bxattr_exit_ok) {
+       goto bail_out;
    }
+   jcr->xattr_data->nr_saved++;
 
    /*
     * Recursivly call solaris_save_extended_attributes for archiving the attributes
     * available on this extended attribute.
     */
-   if (retval) {
-      retval = solaris_save_xattrs(jcr, xattr_namespace, attrname);
+   retval = solaris_save_xattrs(jcr, xattr_namespace, attrname);
       
-      /*
-       * The recursive call could change our working dir so change back to the wanted workdir.
-       */
-      if (fchdir(fd) < 0) {
-         switch (errno) {
-         case ENOENT:
-            retval = bxattr_exit_ok;
-            goto bail_out;
-         default:
-            Mmsg2(jcr->errmsg, _("Unable to chdir to xattr space of file \"%s\": ERR=%s\n"),
-                  jcr->last_fname, be.bstrerror());
-            Dmsg3(100, "Unable to fchdir to xattr space of file \"%s\" using fd %d: ERR=%s\n",
-                  jcr->last_fname, fd, be.bstrerror());
-            goto bail_out;
-         }
+   /*
+    * The recursive call could change our working dir so change back to the wanted workdir.
+    */
+   if (fchdir(fd) < 0) {
+      switch (errno) {
+      case ENOENT:
+         retval = bxattr_exit_ok;
+         goto bail_out;
+      default:
+         Mmsg2(jcr->errmsg,
+               _("Unable to chdir to xattr space of file \"%s\": ERR=%s\n"),
+               jcr->last_fname, be.bstrerror());
+         Dmsg3(100, "Unable to fchdir to xattr space of file \"%s\" using fd %d: ERR=%s\n",
+               jcr->last_fname, fd, be.bstrerror());
+         goto bail_out;
       }
    }