From 54f73b9d973e0ae4a843b9d7ce920205cdbd87c1 Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Thu, 2 Apr 2009 10:29:26 +0000 Subject: [PATCH] Lets only count non acl xattr in the first place that saves us some tricky coding later on. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8678 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/filed/xattr.c | 54 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/bacula/src/filed/xattr.c b/bacula/src/filed/xattr.c index 44e3f4f60b..fe43b04233 100644 --- a/bacula/src/filed/xattr.c +++ b/bacula/src/filed/xattr.c @@ -248,8 +248,7 @@ static uint32_t serialize_xattr_stream(JCR *jcr, uint32_t expected_serialize_len static bool generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt, int stream) { - bool retval = true; - int count; + int count = 0; int32_t xattr_list_len, xattr_value_len; uint32_t expected_serialize_len = 0; @@ -302,14 +301,26 @@ static bool generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt, int stream) /* * Count the number of extended attributes on a file. */ - count = 0; bp = xattr_list; while ((bp - xattr_list) + 1 < xattr_list_len) { +#if defined(HAVE_LINUX_OS) + /* + * On Linux you also get the acls in the extented attribute list. + * So we check if we are already backing up acls and if we do we + * don't store the extended attribute with the same info. + */ + if ((ff_pkt->flags & FO_ACL) == 0 || strcmp(bp, "system.posix_acl_access")) + count++; +#else count++; +#endif bp = strchr(bp, '\0') + 1; } + if (count == 0) + return true; + /* * Allocate enough room to hold all extended attributes. * After allocating the storage make sure its empty by zeroing it. @@ -325,16 +336,10 @@ static bool generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt, int stream) * Walk the list of extended attributes names and retrieve the data. * We already count the bytes needed for serializing the stream later on. */ - count = 0; current_xattr = xattr_value_list; bp = xattr_list; while ((bp - xattr_list) + 1 < xattr_list_len) { #if defined(HAVE_LINUX_OS) - /* - * On Linux you also get the acls in the extented attribute list. - * So we check if we are already backing up acls and if we do we - * don't store the extended attribute with the same info. - */ if (ff_pkt->flags & FO_ACL && !strcmp(bp, "system.posix_acl_access")) { bp = strchr(bp, '\0') + 1; @@ -415,34 +420,29 @@ static bool generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt, int stream) /* * Next attribute. */ - count++; current_xattr++; bp = strchr(bp, '\0') + 1; } - if (count != 0) { - /* - * Serialize the datastream. - */ - if (serialize_xattr_stream(jcr, expected_serialize_len, xattr_value_list) < expected_serialize_len) { - Jmsg1(jcr, M_ERROR, 0, _("Failed to serialize extended attributes on file \"%s\"\n"), - jcr->last_fname); - Dmsg1(100, "Failed to serialize extended attributes on file \"%s\"\n", - jcr->last_fname); - - goto bail_out; - } + /* + * Serialize the datastream. + */ + if (serialize_xattr_stream(jcr, expected_serialize_len, xattr_value_list) < expected_serialize_len) { + Jmsg1(jcr, M_ERROR, 0, _("Failed to serialize extended attributes on file \"%s\"\n"), + jcr->last_fname); + Dmsg1(100, "Failed to serialize extended attributes on file \"%s\"\n", + jcr->last_fname); - /* - * Send the datastream to the SD. - */ - retval = send_xattr_stream(jcr, stream); + goto bail_out; } xattr_drop_internal_table(xattr_value_list); free(xattr_list); - return retval; + /* + * Send the datastream to the SD. + */ + return send_xattr_stream(jcr, stream); bail_out: xattr_drop_internal_table(xattr_value_list); -- 2.39.5