From 233a1dd4f465fadf196294046e53700aa39ec181 Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Sun, 5 Jul 2009 16:20:35 +0200 Subject: [PATCH] Moved the berrno as a local variable of the function and not a local context variable. Same as previous change for acl.c --- bacula/src/filed/xattr.c | 42 +++++++++------------------------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/bacula/src/filed/xattr.c b/bacula/src/filed/xattr.c index 23a2926db1..e64a4d3f9d 100644 --- a/bacula/src/filed/xattr.c +++ b/bacula/src/filed/xattr.c @@ -249,6 +249,7 @@ static bsub_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt, int uint32_t expected_serialize_len = 0; char *xattr_list, *bp; xattr_t *xattr_value_list, *current_xattr; + berrno be; /* * First get the length of the available list with extended attributes. @@ -259,7 +260,6 @@ static bsub_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt, int case ENOENT: return bsub_exit_nok; default: - berrno be; Jmsg2(jcr, M_ERROR, 0, _("llistxattr error on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); Dmsg2(100, "llistxattr error file=%s ERR=%s\n", @@ -286,7 +286,6 @@ static bsub_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt, int free(xattr_list); return bsub_exit_nok; default: - berrno be; Jmsg2(jcr, M_ERROR, 0, _("llistxattr error on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); Dmsg2(100, "llistxattr error file=%s ERR=%s\n", @@ -367,7 +366,6 @@ static bsub_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt, int case ENOENT: goto bail_out; default: - berrno be; Jmsg2(jcr, M_ERROR, 0, _("lgetxattr error on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); Dmsg2(100, "lgetxattr error file=%s ERR=%s\n", @@ -388,7 +386,6 @@ static bsub_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt, int case ENOENT: goto bail_out; default: - berrno be; Jmsg2(jcr, M_ERROR, 0, _("lgetxattr error on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); Dmsg2(100, "lgetxattr error file=%s ERR=%s\n", @@ -449,6 +446,7 @@ static bsub_exit_code generic_xattr_parse_streams(JCR *jcr, int stream) unser_declare; xattr_t current_xattr; bsub_exit_code retval = bsub_exit_nok; + berrno be; /* * Parse the stream and perform the setxattr calls on the file. @@ -509,7 +507,6 @@ static bsub_exit_code generic_xattr_parse_streams(JCR *jcr, int stream) break; default: current_xattr.value_length, 0) != 0) { - berrno be; Jmsg2(jcr, M_ERROR, 0, _("lsetxattr error on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); Dmsg2(100, "lsetxattr error file=%s ERR=%s\n", @@ -780,6 +777,7 @@ static bsub_exit_code solaris_save_xattr_acl(JCR *jcr, int fd, const char *attrn #ifdef HAVE_EXTENDED_ACL int flags; acl_t *aclp = NULL; + berrno be; /* * See if this attribute has an ACL @@ -795,7 +793,6 @@ static bsub_exit_code solaris_save_xattr_acl(JCR *jcr, int fd, const char *attrn case ENOENT: return bsub_exit_nok; default: - berrno be; Jmsg3(jcr, M_ERROR, 0, _("Unable to get acl on xattr %s on file \"%s\": ERR=%s\n"), attrname, jcr->last_fname, be.bstrerror()); Dmsg3(100, "facl_get/acl_get of xattr %s on \"%s\" failed: ERR=%s\n", @@ -826,6 +823,7 @@ static bsub_exit_code solaris_save_xattr_acl(JCR *jcr, int fd, const char *attrn #else /* HAVE_EXTENDED_ACL */ int n; aclent_t *acls = NULL; + berrno be; /* * See if this attribute has an ACL @@ -845,7 +843,6 @@ static bsub_exit_code solaris_save_xattr_acl(JCR *jcr, int fd, const char *attrn free(acls); return bsub_exit_nok; default: - berrno be; Jmsg3(jcr, M_ERROR, 0, _("Unable to get acl on xattr %s on file \"%s\": ERR=%s\n"), attrname, jcr->last_fname, be.bstrerror()); Dmsg3(100, "facl/acl of xattr %s on \"%s\" failed: ERR=%s\n", @@ -860,7 +857,6 @@ static bsub_exit_code solaris_save_xattr_acl(JCR *jcr, int fd, const char *attrn */ if (!acl_is_trivial(n, acls)) { if ((*acl_text = acltotext(acls, n)) == NULL) { - berrno be; Jmsg3(jcr, M_ERROR, 0, _("Unable to get acl text on xattr %s on file \"%s\": ERR=%s\n"), attrname, jcr->last_fname, be.bstrerror()); Dmsg3(100, "acltotext of xattr %s on \"%s\" failed: ERR=%s\n", @@ -917,6 +913,7 @@ static bsub_exit_code solaris_save_xattr(JCR *jcr, int fd, const char *xattr_nam char attribs[MAXSTRING]; char buffer[BUFSIZ]; bsub_exit_code retval = bsub_exit_nok; + berrno be; snprintf(target_attrname, sizeof(target_attrname), "%s%s", xattr_namespace, attrname); @@ -928,7 +925,6 @@ static bsub_exit_code solaris_save_xattr(JCR *jcr, int fd, const char *xattr_nam case ENOENT: goto cleanup; default: - berrno be; Jmsg3(jcr, M_ERROR, 0, _("Unable to get status on xattr %s on file \"%s\": ERR=%s\n"), target_attrname, jcr->last_fname, be.bstrerror()); Dmsg3(100, "fstatat of xattr %s on \"%s\" failed: ERR=%s\n", @@ -1050,7 +1046,6 @@ static bsub_exit_code solaris_save_xattr(JCR *jcr, int fd, const char *xattr_nam case ENOENT: goto cleanup; default: - berrno be; Jmsg3(jcr, M_ERROR, 0, _("Unable to open xattr %s on \"%s\": ERR=%s\n"), target_attrname, jcr->last_fname, be.bstrerror()); Dmsg3(100, "openat of xattr %s on \"%s\" failed: ERR=%s\n", @@ -1070,7 +1065,6 @@ static bsub_exit_code solaris_save_xattr(JCR *jcr, int fd, const char *xattr_nam case ENOENT: goto cleanup; default: - berrno be; Jmsg3(jcr, M_ERROR, 0, _("Unable to read symlin %s on \"%s\": ERR=%s\n"), target_attrname, jcr->last_fname, be.bstrerror()); Dmsg3(100, "readlink of xattr %s on \"%s\" failed: ERR=%s\n", @@ -1166,7 +1160,6 @@ static bsub_exit_code solaris_save_xattr(JCR *jcr, int fd, const char *xattr_nam case ENOENT: goto cleanup; default: - berrno be; Jmsg2(jcr, M_ERROR, 0, _("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", @@ -1194,6 +1187,7 @@ static bsub_exit_code solaris_save_xattrs(JCR *jcr, const char *xattr_namespace, struct dirent *dp; char current_xattr_namespace[PATH_MAX]; bsub_exit_code retval = bsub_exit_nok; + berrno be; /* * Determine what argument to use. Use attr_parent when set @@ -1221,7 +1215,6 @@ static bsub_exit_code solaris_save_xattrs(JCR *jcr, const char *xattr_namespace, case ENOENT: goto cleanup; default: - berrno be; Jmsg2(jcr, M_ERROR, 0, _("Unable to open file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); Dmsg2(100, "Unable to open file \"%s\": ERR=%s\n", @@ -1246,7 +1239,6 @@ static bsub_exit_code solaris_save_xattrs(JCR *jcr, const char *xattr_namespace, case ENOENT: goto cleanup; default: - berrno be; Jmsg3(jcr, M_ERROR, 0, _("Unable to open xattr space %s on file \"%s\": ERR=%s\n"), name, jcr->last_fname, be.bstrerror()); Dmsg3(100, "Unable to open xattr space %s on file \"%s\": ERR=%s\n", @@ -1260,7 +1252,6 @@ static bsub_exit_code solaris_save_xattrs(JCR *jcr, const char *xattr_namespace, * attributes should be saved. */ if (fchdir(attrdirfd) < 0) { - berrno be; Jmsg2(jcr, M_ERROR, 0, _("Unable to chdir to xattr space on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); Dmsg3(100, "Unable to fchdir to xattr space on file \"%s\" using fd %d: ERR=%s\n", @@ -1279,7 +1270,6 @@ static bsub_exit_code solaris_save_xattrs(JCR *jcr, const char *xattr_namespace, if ((fd = dup(attrdirfd)) == -1 || (dirp = fdopendir(fd)) == (DIR *)NULL) { - berrno be; Jmsg2(jcr, M_ERROR, 0, _("Unable to list the xattr space on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); Dmsg3(100, "Unable to fdopendir xattr space on file \"%s\" using fd %d: ERR=%s\n", @@ -1366,6 +1356,7 @@ static bsub_exit_code solaris_restore_xattr_acl(JCR *jcr, int fd, const char *at #ifdef HAVE_EXTENDED_ACL int error; acl_t *aclp = NULL; + berrno be; if ((error = acl_fromtext(acl_text, &aclp)) != 0) { Jmsg1(jcr, M_ERROR, 0, _("Unable to convert acl from text on file \"%s\"\n"), @@ -1375,7 +1366,6 @@ static bsub_exit_code solaris_restore_xattr_acl(JCR *jcr, int fd, const char *at if ((fd != -1 && facl_set(fd, aclp) != 0) || acl_set(attrname, aclp) != 0) { - berrno be; Jmsg3(jcr, M_ERROR, 0, _("Unable to restore acl of xattr %s on file \"%s\": ERR=%s\n"), attrname, jcr->last_fname, be.bstrerror()); Dmsg3(100, "Unable to restore acl of xattr %s on file \"%s\": ERR=%s\n", @@ -1391,12 +1381,12 @@ static bsub_exit_code solaris_restore_xattr_acl(JCR *jcr, int fd, const char *at #else /* HAVE_EXTENDED_ACL */ int n; aclent_t *acls = NULL; + berrno be; acls = aclfromtext(acl_text, &n); if (!acls) { if ((fd != -1 && facl(fd, SETACL, n, acls) != 0) || acl(attrname, SETACL, n, acls) != 0) { - berrno be; Jmsg3(jcr, M_ERROR, 0, _("Unable to restore acl of xattr %s on file \"%s\": ERR=%s\n"), attrname, jcr->last_fname, be.bstrerror()); Dmsg3(100, "Unable to restore acl of xattr %s on file \"%s\": ERR=%s\n", @@ -1427,6 +1417,7 @@ static bsub_exit_code solaris_restore_xattrs(JCR *jcr, bool is_extensible) struct stat st; struct timeval times[2]; bsub_exit_code retval = bsub_exit_nok; + berrno be; /* * Parse the xattr stream. First the part that is the same for all xattrs. @@ -1450,7 +1441,6 @@ static bsub_exit_code solaris_restore_xattrs(JCR *jcr, bool is_extensible) * Open the file on which to restore the xattrs read-only. */ if ((filefd = open(jcr->last_fname, O_RDONLY | O_NONBLOCK)) < 0) { - berrno be; Jmsg2(jcr, M_ERROR, 0, _("Unable to open file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); Dmsg2(100, "Unable to open file \"%s\": ERR=%s\n", @@ -1462,7 +1452,6 @@ static bsub_exit_code solaris_restore_xattrs(JCR *jcr, bool is_extensible) * Open the xattr naming space and make it the current working dir. */ if ((attrdirfd = openat(filefd, ".", O_RDONLY | O_XATTR)) < 0) { - berrno be; Jmsg2(jcr, M_ERROR, 0, _("Unable to open xattr space on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); Dmsg2(100, "Unable to open xattr space on file \"%s\": ERR=%s\n", @@ -1471,7 +1460,6 @@ static bsub_exit_code solaris_restore_xattrs(JCR *jcr, bool is_extensible) } if (fchdir(attrdirfd) < 0) { - berrno be; Jmsg2(jcr, M_ERROR, 0, _("Unable to chdir to xattr space on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); Dmsg3(100, "Unable to fchdir to xattr space on file \"%s\" using fd %d: ERR=%s\n", @@ -1488,7 +1476,6 @@ static bsub_exit_code solaris_restore_xattrs(JCR *jcr, bool is_extensible) *bp = '\0'; if ((fd = open(target_attrname, O_RDONLY | O_NONBLOCK)) < 0) { - berrno be; Jmsg3(jcr, M_ERROR, 0, _("Unable to open xattr %s on file \"%s\": ERR=%s\n"), target_attrname, jcr->last_fname, be.bstrerror()); Dmsg3(100, "Unable to open xattr %s on file \"%s\": ERR=%s\n", @@ -1503,7 +1490,6 @@ static bsub_exit_code solaris_restore_xattrs(JCR *jcr, bool is_extensible) * Open the xattr naming space. */ if ((fd = openat(filefd, ".", O_RDONLY | O_XATTR)) < 0) { - berrno be; Jmsg3(jcr, M_ERROR, 0, _("Unable to open xattr space %s on file \"%s\": ERR=%s\n"), target_attrname, jcr->last_fname, be.bstrerror()); Dmsg3(100, "Unable to open xattr space %s on file \"%s\": ERR=%s\n", @@ -1518,7 +1504,6 @@ static bsub_exit_code solaris_restore_xattrs(JCR *jcr, bool is_extensible) * Make the xattr space our current workingdir. */ if (fchdir(attrdirfd) < 0) { - berrno be; Jmsg3(jcr, M_ERROR, 0, _("Unable to chdir to xattr space %s on file \"%s\": ERR=%s\n"), target_attrname, jcr->last_fname, be.bstrerror()); Dmsg4(100, "Unable to fchdir to xattr space %s on file \"%s\" using fd %d: ERR=%s\n", @@ -1555,7 +1540,6 @@ static bsub_exit_code solaris_restore_xattrs(JCR *jcr, bool is_extensible) */ unlinkat(attrdirfd, target_attrname, 0); if (mkfifo(target_attrname, st.st_mode) < 0) { - berrno be; Jmsg3(jcr, M_ERROR, 0, _("Unable to mkfifo xattr %s on file \"%s\": ERR=%s\n"), target_attrname, jcr->last_fname, be.bstrerror()); Dmsg3(100, "Unable to mkfifo xattr %s on file \"%s\": ERR=%s\n", @@ -1570,7 +1554,6 @@ static bsub_exit_code solaris_restore_xattrs(JCR *jcr, bool is_extensible) */ unlinkat(attrdirfd, target_attrname, 0); if (mknod(target_attrname, st.st_mode, st.st_rdev) < 0) { - berrno be; Jmsg3(jcr, M_ERROR, 0, _("Unable to mknod xattr %s on file \"%s\": ERR=%s\n"), target_attrname, jcr->last_fname, be.bstrerror()); Dmsg3(100, "Unable to mknod xattr %s on file \"%s\": ERR=%s\n", @@ -1586,7 +1569,6 @@ static bsub_exit_code solaris_restore_xattrs(JCR *jcr, bool is_extensible) if (strcmp(target_attrname, ".")) { unlinkat(attrdirfd, target_attrname, AT_REMOVEDIR); if (mkdir(target_attrname, st.st_mode) < 0) { - berrno be; Jmsg3(jcr, M_WARNING, 0, _("Unable to mkdir xattr %s on file \"%s\": ERR=%s\n"), target_attrname, jcr->last_fname, be.bstrerror()); Dmsg3(100, "Unable to mkdir xattr %s on file \"%s\": ERR=%s\n", @@ -1604,7 +1586,6 @@ static bsub_exit_code solaris_restore_xattrs(JCR *jcr, bool is_extensible) unlinkat(attrdirfd, target_attrname, 0); if (link(linked_target, target_attrname) < 0) { - berrno be; Jmsg4(jcr, M_ERROR, 0, _("Unable to link xattr %s to %s on file \"%s\": ERR=%s\n"), target_attrname, linked_target, jcr->last_fname, be.bstrerror()); Dmsg4(100, "Unable to link xattr %s to %s on file \"%s\": ERR=%s\n", @@ -1634,7 +1615,6 @@ static bsub_exit_code solaris_restore_xattrs(JCR *jcr, bool is_extensible) } if ((attrfd = openat(attrdirfd, target_attrname, O_RDWR | O_CREAT | O_TRUNC, st.st_mode)) < 0) { - berrno be; Jmsg3(jcr, M_ERROR, 0, _("Unable to open xattr %s on file \"%s\": ERR=%s\n"), target_attrname, jcr->last_fname, be.bstrerror()); Dmsg3(100, "Unable to open xattr %s on file \"%s\": ERR=%s\n", @@ -1665,7 +1645,6 @@ static bsub_exit_code solaris_restore_xattrs(JCR *jcr, bool is_extensible) while (cnt > 0) { cnt = write(attrfd, data, cnt); if (cnt < 0) { - berrno be; Jmsg3(jcr, M_ERROR, 0, _("Unable to restore data of xattr %s on file \"%s\": ERR=%s\n"), target_attrname, jcr->last_fname, be.bstrerror()); Dmsg3(100, "Unable to restore data of xattr %s on file \"%s\": ERR=%s\n", @@ -1686,7 +1665,6 @@ static bsub_exit_code solaris_restore_xattrs(JCR *jcr, bool is_extensible) linked_target = bp; if (symlink(linked_target, target_attrname) < 0) { - berrno be; Jmsg4(jcr, M_ERROR, 0, _("Unable to symlink xattr %s to %s on file \"%s\": ERR=%s\n"), target_attrname, linked_target, jcr->last_fname, be.bstrerror()); Dmsg4(100, "Unable to symlink xattr %s to %s on file \"%s\": ERR=%s\n", @@ -1717,7 +1695,6 @@ static bsub_exit_code solaris_restore_xattrs(JCR *jcr, bool is_extensible) retval = bsub_exit_ok; break; default: - berrno be; Jmsg3(jcr, M_ERROR, 0, _("Unable to restore owner of xattr %s on file \"%s\": ERR=%s\n"), target_attrname, jcr->last_fname, be.bstrerror()); Dmsg3(100, "Unable to restore owner of xattr %s on file \"%s\": ERR=%s\n", @@ -1743,7 +1720,6 @@ static bsub_exit_code solaris_restore_xattrs(JCR *jcr, bool is_extensible) times[1].tv_usec = 0; if (futimesat(attrdirfd, target_attrname, times) < 0) { - berrno be; Jmsg3(jcr, M_ERROR, 0, _("Unable to restore filetimes of xattr %s on file \"%s\": ERR=%s\n"), target_attrname, jcr->last_fname, be.bstrerror()); Dmsg3(100, "Unable to restore filetimes of xattr %s on file \"%s\": ERR=%s\n", -- 2.39.5