From 5c8cd75967b688fc0dba98e1e65e376eff78451f Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Sun, 9 Aug 2009 11:57:00 +0200 Subject: [PATCH] Changes due to code review by Kern added. --- bacula/src/filed/acl.c | 242 ++++++++++++++++++------------------- bacula/src/filed/backup.c | 12 +- bacula/src/filed/filed.h | 19 ++- bacula/src/filed/protos.h | 8 +- bacula/src/filed/restore.c | 12 +- bacula/src/filed/xattr.c | 164 ++++++++++++------------- bacula/src/filed/xattr.h | 8 +- 7 files changed, 237 insertions(+), 228 deletions(-) diff --git a/bacula/src/filed/acl.c b/bacula/src/filed/acl.c index c1fbc3b989..5a26b80abe 100644 --- a/bacula/src/filed/acl.c +++ b/bacula/src/filed/acl.c @@ -59,32 +59,32 @@ /* * Entry points when compiled without support for ACLs or on an unsupported platform. */ -bsub_exit_code build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) +bacl_exit_code build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) { - return bsub_exit_fatal; + return bacl_exit_fatal; } -bsub_exit_code parse_acl_stream(JCR *jcr, int stream) +bacl_exit_code parse_acl_stream(JCR *jcr, int stream) { - return bsub_exit_fatal; + return bacl_exit_fatal; } #else /* * Send an ACL stream to the SD. */ -static bsub_exit_code send_acl_stream(JCR *jcr, int stream) +static bacl_exit_code send_acl_stream(JCR *jcr, int stream) { BSOCK *sd = jcr->store_bsock; POOLMEM *msgsave; #ifdef FD_NO_SEND_TEST - return bsub_exit_ok; + return bacl_exit_ok; #endif /* * Sanity check */ if (jcr->acl_data_len <= 0) - return bsub_exit_ok; + return bacl_exit_ok; /* * Send header @@ -92,7 +92,7 @@ static bsub_exit_code send_acl_stream(JCR *jcr, int stream) if (!sd->fsend("%ld %d 0", jcr->JobFiles, stream)) { Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), sd->bstrerror()); - return bsub_exit_fatal; + return bacl_exit_fatal; } /* @@ -107,7 +107,7 @@ static bsub_exit_code send_acl_stream(JCR *jcr, int stream) sd->msglen = 0; Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), sd->bstrerror()); - return bsub_exit_fatal; + return bacl_exit_fatal; } jcr->JobBytes += sd->msglen; @@ -115,11 +115,11 @@ static bsub_exit_code send_acl_stream(JCR *jcr, int stream) if (!sd->signal(BNET_EOD)) { Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), sd->bstrerror()); - return bsub_exit_fatal; + return bacl_exit_fatal; } Dmsg1(200, "ACL of file: %s successfully backed up!\n", jcr->last_fname); - return bsub_exit_ok; + return bacl_exit_ok; } #if defined(HAVE_AIX_OS) @@ -132,7 +132,7 @@ static bsub_exit_code send_acl_stream(JCR *jcr, int stream) static int os_access_acl_streams[1] = { STREAM_ACL_AIX_TEXT }; static int os_default_acl_streams[1] = { -1 }; -static bsub_exit_code aix_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) +static bacl_exit_code aix_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) { char *acl_text; @@ -141,22 +141,22 @@ static bsub_exit_code aix_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) actuallyfree(acl_text); return send_acl_stream(jcr, STREAM_ACL_AIX_TEXT); } - return bsub_exit_nok; + return bacl_exit_error; } -static bsub_exit_code aix_parse_acl_streams(JCR *jcr, int stream) +static bacl_exit_code aix_parse_acl_streams(JCR *jcr, int stream) { if (acl_put(jcr->last_fname, jcr->acl_data, 0) != 0) { - return bsub_exit_nok; + return bacl_exit_error; } - return bsub_exit_ok; + return bacl_exit_ok; } /* * For this OS setup the build and parse function pointer to the OS specific functions. */ -static bsub_exit_code (*os_build_acl_streams)(JCR *jcr, FF_PKT *ff_pkt) = aix_build_acl_streams; -static bsub_exit_code (*os_parse_acl_streams)(JCR *jcr, int stream) = aix_parse_acl_streams; +static bacl_exit_code (*os_build_acl_streams)(JCR *jcr, FF_PKT *ff_pkt) = aix_build_acl_streams; +static bacl_exit_code (*os_parse_acl_streams)(JCR *jcr, int stream) = aix_parse_acl_streams; #elif defined(HAVE_DARWIN_OS) || \ defined(HAVE_FREEBSD_OS) || \ @@ -319,7 +319,7 @@ static bool acl_is_trivial(acl_t acl) /* * Generic wrapper around acl_get_file call. */ -static bsub_exit_code generic_get_acl_from_os(JCR *jcr, bacl_type acltype) +static bacl_exit_code generic_get_acl_from_os(JCR *jcr, bacl_type acltype) { acl_t acl; acl_type_t ostype; @@ -346,7 +346,7 @@ static bsub_exit_code generic_get_acl_from_os(JCR *jcr, bacl_type acltype) pm_strcpy(jcr->acl_data, ""); jcr->acl_data_len = 0; acl_free(acl); - return bsub_exit_ok; + return bacl_exit_ok; } #endif @@ -362,7 +362,7 @@ static bsub_exit_code generic_get_acl_from_os(JCR *jcr, bacl_type acltype) pm_strcpy(jcr->acl_data, ""); jcr->acl_data_len = 0; acl_free(acl); - return bsub_exit_ok; + return bacl_exit_ok; } #endif @@ -370,7 +370,7 @@ static bsub_exit_code generic_get_acl_from_os(JCR *jcr, bacl_type acltype) jcr->acl_data_len = pm_strcpy(jcr->acl_data, acl_text); acl_free(acl); acl_free(acl_text); - return bsub_exit_ok; + return bacl_exit_ok; } Mmsg2(jcr->errmsg, _("acl_to_text error on file \"%s\": ERR=%s\n"), @@ -381,7 +381,7 @@ static bsub_exit_code generic_get_acl_from_os(JCR *jcr, bacl_type acltype) pm_strcpy(jcr->acl_data, ""); jcr->acl_data_len = 0; acl_free(acl); - return bsub_exit_nok; + return bacl_exit_error; } /* @@ -396,7 +396,7 @@ static bsub_exit_code generic_get_acl_from_os(JCR *jcr, bacl_type acltype) case ENOENT: pm_strcpy(jcr->acl_data, ""); jcr->acl_data_len = 0; - return bsub_exit_ok; + return bacl_exit_ok; default: /* Some real error */ Mmsg2(jcr->errmsg, _("acl_get_file error on file \"%s\": ERR=%s\n"), @@ -406,7 +406,7 @@ static bsub_exit_code generic_get_acl_from_os(JCR *jcr, bacl_type acltype) pm_strcpy(jcr->acl_data, ""); jcr->acl_data_len = 0; - return bsub_exit_nok; + return bacl_exit_error; } } /* @@ -414,13 +414,13 @@ static bsub_exit_code generic_get_acl_from_os(JCR *jcr, bacl_type acltype) */ pm_strcpy(jcr->acl_data, ""); jcr->acl_data_len = 0; - return bsub_exit_ok; + return bacl_exit_ok; } /* * Generic wrapper around acl_set_file call. */ -static bsub_exit_code generic_set_acl_on_os(JCR *jcr, bacl_type acltype) +static bacl_exit_code generic_set_acl_on_os(JCR *jcr, bacl_type acltype) { acl_t acl; acl_type_t ostype; @@ -432,15 +432,15 @@ static bsub_exit_code generic_set_acl_on_os(JCR *jcr, bacl_type acltype) ostype = bac_to_os_acltype(acltype); if (ostype == ACL_TYPE_DEFAULT && strlen(jcr->acl_data) == 0) { if (acl_delete_def_file(jcr->last_fname) == 0) { - return bsub_exit_ok; + return bacl_exit_ok; } switch (errno) { case ENOENT: - return bsub_exit_ok; + return bacl_exit_ok; default: Mmsg2(jcr->errmsg, _("acl_delete_def_file error on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); - return bsub_exit_nok; + return bacl_exit_error; } } @@ -450,7 +450,7 @@ static bsub_exit_code generic_set_acl_on_os(JCR *jcr, bacl_type acltype) jcr->last_fname, be.bstrerror()); Dmsg3(100, "acl_from_text error acl=%s file=%s ERR=%s\n", jcr->acl_data, jcr->last_fname, be.bstrerror()); - return bsub_exit_nok; + return bacl_exit_error; } #ifndef HAVE_FREEBSD_OS @@ -464,7 +464,7 @@ static bsub_exit_code generic_set_acl_on_os(JCR *jcr, bacl_type acltype) Dmsg3(100, "acl_valid error acl=%s file=%s ERR=%s\n", jcr->acl_data, jcr->last_fname, be.bstrerror()); acl_free(acl); - return bsub_exit_nok; + return bacl_exit_error; } #endif @@ -478,18 +478,18 @@ static bsub_exit_code generic_set_acl_on_os(JCR *jcr, bacl_type acltype) switch (errno) { case ENOENT: acl_free(acl); - return bsub_exit_ok; + return bacl_exit_ok; default: Mmsg2(jcr->errmsg, _("acl_set_file error on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); Dmsg3(100, "acl_set_file error acl=%s file=%s ERR=%s\n", jcr->acl_data, jcr->last_fname, be.bstrerror()); acl_free(acl); - return bsub_exit_nok; + return bacl_exit_error; } } acl_free(acl); - return bsub_exit_ok; + return bacl_exit_ok; } /* @@ -502,7 +502,7 @@ static bsub_exit_code generic_set_acl_on_os(JCR *jcr, bacl_type acltype) static int os_access_acl_streams[1] = { STREAM_ACL_DARWIN_ACCESS_ACL }; static int os_default_acl_streams[1] = { -1 }; -static bsub_exit_code darwin_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) +static bacl_exit_code darwin_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) { #if defined(ACL_TYPE_EXTENDED) /* @@ -514,23 +514,23 @@ static bsub_exit_code darwin_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) * * Read access ACLs for files, dirs and links */ - if (generic_get_acl_from_os(jcr, BACL_TYPE_EXTENDED) == bsub_exit_fatal) - return bsub_exit_fatal; + if (generic_get_acl_from_os(jcr, BACL_TYPE_EXTENDED) == bacl_exit_fatal) + return bacl_exit_fatal; #else /* * Read access ACLs for files, dirs and links */ - if (generic_get_acl_from_os(jcr, BACL_TYPE_ACCESS) == bsub_exit_fatal) - return bsub_exit_fatal; + if (generic_get_acl_from_os(jcr, BACL_TYPE_ACCESS) == bacl_exit_fatal) + return bacl_exit_fatal; #endif if (jcr->acl_data_len > 0) { return send_acl_stream(jcr, STREAM_ACL_DARWIN_ACCESS_ACL); } - return bsub_exit_ok; + return bacl_exit_ok; } -static bsub_exit_code darwin_parse_acl_streams(JCR *jcr, int stream) +static bacl_exit_code darwin_parse_acl_streams(JCR *jcr, int stream) { #if defined(ACL_TYPE_EXTENDED) return generic_set_acl_on_os(jcr, BACL_TYPE_EXTENDED); @@ -542,8 +542,8 @@ static bsub_exit_code darwin_parse_acl_streams(JCR *jcr, int stream) /* * For this OS setup the build and parse function pointer to the OS specific functions. */ -static bsub_exit_code (*os_build_acl_streams)(JCR *jcr, FF_PKT *ff_pkt) = darwin_build_acl_streams; -static bsub_exit_code (*os_parse_acl_streams)(JCR *jcr, int stream) = darwin_parse_acl_streams; +static bacl_exit_code (*os_build_acl_streams)(JCR *jcr, FF_PKT *ff_pkt) = darwin_build_acl_streams; +static bacl_exit_code (*os_parse_acl_streams)(JCR *jcr, int stream) = darwin_parse_acl_streams; #elif defined(HAVE_FREEBSD_OS) || \ defined(HAVE_IRIX_OS) || \ @@ -563,34 +563,34 @@ static int os_access_acl_streams[1] = { STREAM_ACL_LINUX_ACCESS_ACL }; static int os_default_acl_streams[1] = { STREAM_ACL_LINUX_DEFAULT_ACL }; #endif -static bsub_exit_code generic_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) +static bacl_exit_code generic_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) { /* * Read access ACLs for files, dirs and links */ - if (generic_get_acl_from_os(jcr, BACL_TYPE_ACCESS) == bsub_exit_fatal) - return bsub_exit_fatal; + if (generic_get_acl_from_os(jcr, BACL_TYPE_ACCESS) == bacl_exit_fatal) + return bacl_exit_fatal; if (jcr->acl_data_len > 0) { - if (send_acl_stream(jcr, os_access_acl_streams[0]) == bsub_exit_fatal) - return bsub_exit_fatal; + if (send_acl_stream(jcr, os_access_acl_streams[0]) == bacl_exit_fatal) + return bacl_exit_fatal; } /* * Directories can have default ACLs too */ if (ff_pkt->type == FT_DIREND) { - if (generic_get_acl_from_os(jcr, BACL_TYPE_DEFAULT) == bsub_exit_fatal) - return bsub_exit_fatal; + if (generic_get_acl_from_os(jcr, BACL_TYPE_DEFAULT) == bacl_exit_fatal) + return bacl_exit_fatal; if (jcr->acl_data_len > 0) { - if (send_acl_stream(jcr, os_default_acl_streams[0]) == bsub_exit_fatal) - return bsub_exit_fatal; + if (send_acl_stream(jcr, os_default_acl_streams[0]) == bacl_exit_fatal) + return bacl_exit_fatal; } } - return bsub_exit_ok; + return bacl_exit_ok; } -static bsub_exit_code generic_parse_acl_streams(JCR *jcr, int stream) +static bacl_exit_code generic_parse_acl_streams(JCR *jcr, int stream) { int cnt; @@ -615,14 +615,14 @@ static bsub_exit_code generic_parse_acl_streams(JCR *jcr, int stream) } break; } - return bsub_exit_nok; + return bacl_exit_error; } /* * For this OSes setup the build and parse function pointer to the OS specific functions. */ -static bsub_exit_code (*os_build_acl_streams)(JCR *jcr, FF_PKT *ff_pkt) = generic_build_acl_streams; -static bsub_exit_code (*os_parse_acl_streams)(JCR *jcr, int stream) = generic_parse_acl_streams; +static bacl_exit_code (*os_build_acl_streams)(JCR *jcr, FF_PKT *ff_pkt) = generic_build_acl_streams; +static bacl_exit_code (*os_parse_acl_streams)(JCR *jcr, int stream) = generic_parse_acl_streams; #elif defined(HAVE_OSF1_OS) @@ -632,26 +632,26 @@ static bsub_exit_code (*os_parse_acl_streams)(JCR *jcr, int stream) = generic_pa static int os_access_acl_streams[1] = { STREAM_ACL_TRU64_ACCESS_ACL }; static int os_default_acl_streams[2] = { STREAM_ACL_TRU64_DEFAULT_ACL, STREAM_ACL_TRU64_DEFAULT_DIR_ACL }; -static bsub_exit_code tru64_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) +static bacl_exit_code tru64_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) { /* * Read access ACLs for files, dirs and links */ if ((jcr->acl_data_len = generic_get_acl_from_os(jcr, BACL_TYPE_ACCESS)) < 0) - return bsub_exit_nok; + return bacl_exit_error; if (jcr->acl_data_len > 0) { if (!send_acl_stream(jcr, STREAM_ACL_TRU64_ACCESS_ACL)) - return bsub_exit_nok; + return bacl_exit_error; } /* * Directories can have default ACLs too */ if (ff_pkt->type == FT_DIREND) { if ((jcr->acl_data_len = generic_get_acl_from_os(jcr, BACL_TYPE_DEFAULT)) < 0) - return bsub_exit_nok; + return bacl_exit_error; if (jcr->acl_data_len > 0) { if (!send_acl_stream(jcr, STREAM_ACL_TRU64_DEFAULT_ACL)) - return bsub_exit_nok; + return bacl_exit_error; } /* * Tru64 has next to BACL_TYPE_DEFAULT also BACL_TYPE_DEFAULT_DIR acls. @@ -660,16 +660,16 @@ static bsub_exit_code tru64_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) * Section 21.5 Default ACLs */ if ((jcr->acl_data_len = generic_get_acl_from_os(jcr, BACL_TYPE_DEFAULT_DIR)) < 0) - return bsub_exit_nok; + return bacl_exit_error; if (jcr->acl_data_len > 0) { if (!send_acl_stream(jcr, STREAM_ACL_TRU64_DEFAULT_DIR_ACL)) - return bsub_exit_nok; + return bacl_exit_error; } } - return bsub_exit_ok; + return bacl_exit_ok; } -static bsub_exit_code tru64_parse_acl_streams(JCR *jcr, int stream) +static bacl_exit_code tru64_parse_acl_streams(JCR *jcr, int stream) { switch (stream) { case STREAM_UNIX_ACCESS_ACL: @@ -685,8 +685,8 @@ static bsub_exit_code tru64_parse_acl_streams(JCR *jcr, int stream) /* * For this OS setup the build and parse function pointer to the OS specific functions. */ -static bsub_exit_code (*os_build_acl_streams)(JCR *jcr, FF_PKT *ff_pkt) = tru64_build_acl_streams; -static bsub_exit_code (*os_parse_acl_streams)(JCR *jcr, int stream) = tru64_parse_acl_streams; +static bacl_exit_code (*os_build_acl_streams)(JCR *jcr, FF_PKT *ff_pkt) = tru64_build_acl_streams; +static bacl_exit_code (*os_parse_acl_streams)(JCR *jcr, int stream) = tru64_parse_acl_streams; #endif @@ -730,7 +730,7 @@ static bool acl_is_trivial(int count, struct acl_entry *entries, struct stat sb) /* * OS specific functions for handling different types of acl streams. */ -static bsub_exit_code hpux_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) +static bacl_exit_code hpux_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) { int n; struct acl_entry acls[NACLENTRIES]; @@ -746,12 +746,12 @@ static bsub_exit_code hpux_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) */ pm_strcpy(jcr->acl_data, ""); jcr->acl_data_len = 0; - return bsub_exit_ok; + return bacl_exit_ok; #endif case ENOENT: pm_strcpy(jcr->acl_data, ""); jcr->acl_data_len = 0; - return bsub_exit_ok; + return bacl_exit_ok; default: Mmsg2(jcr->errmsg, _("getacl error on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); @@ -760,13 +760,13 @@ static bsub_exit_code hpux_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) pm_strcpy(jcr->acl_data, ""); jcr->acl_data_len = 0; - return bsub_exit_nok; + return bacl_exit_error; } } if (n == 0) { pm_strcpy(jcr->acl_data, ""); jcr->acl_data_len = 0; - return bsub_exit_ok; + return bacl_exit_ok; } if ((n = getacl(jcr->last_fname, n, acls)) > 0) { if (acl_is_trivial(n, acls, ff_pkt->statp)) { @@ -776,7 +776,7 @@ static bsub_exit_code hpux_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) */ pm_strcpy(jcr->acl_data, ""); jcr->acl_data_len = 0; - return bsub_exit_ok; + return bacl_exit_ok; } if ((acl_text = acltostr(n, acls, FORM_SHORT)) != NULL) { jcr->acl_data_len = pm_strcpy(jcr->acl_data, acl_text); @@ -788,12 +788,12 @@ static bsub_exit_code hpux_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) jcr->last_fname, be.bstrerror()); Dmsg3(100, "acltostr error acl=%s file=%s ERR=%s\n", jcr->acl_data, jcr->last_fname, be.bstrerror()); - return bsub_exit_nok; + return bacl_exit_error; } - return bsub_exit_nok; + return bacl_exit_error; } -static bsub_exit_code hpux_parse_acl_streams(JCR *jcr, int stream) +static bacl_exit_code hpux_parse_acl_streams(JCR *jcr, int stream) { int n, stat; struct acl_entry acls[NACLENTRIES]; @@ -805,7 +805,7 @@ static bsub_exit_code hpux_parse_acl_streams(JCR *jcr, int stream) jcr->last_fname, be.bstrerror()); Dmsg3(100, "strtoacl error acl=%s file=%s ERR=%s\n", jcr->acl_data, jcr->last_fname, be.bstrerror()); - return bsub_exit_nok; + return bacl_exit_error; } if (strtoacl(jcr->acl_data, n, NACLENTRIES, acls, ACL_FILEOWNER, ACL_FILEGROUP) != n) { Mmsg2(jcr->errmsg, _("strtoacl error on file \"%s\": ERR=%s\n"), @@ -813,7 +813,7 @@ static bsub_exit_code hpux_parse_acl_streams(JCR *jcr, int stream) Dmsg3(100, "strtoacl error acl=%s file=%s ERR=%s\n", jcr->acl_data, jcr->last_fname, be.bstrerror()); - return bsub_exit_nok; + return bacl_exit_error; } /* * Restore the ACLs, but don't complain about links which really should @@ -824,23 +824,23 @@ static bsub_exit_code hpux_parse_acl_streams(JCR *jcr, int stream) if (setacl(jcr->last_fname, n, acls) != 0 && jcr->last_type != FT_LNK) { switch (errno) { case ENOENT: - return bsub_exit_ok; + return bacl_exit_ok; default: Mmsg2(jcr->errmsg, _("setacl error on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); Dmsg3(100, "setacl error acl=%s file=%s ERR=%s\n", jcr->acl_data, jcr->last_fname, be.bstrerror()); - return bsub_exit_nok; + return bacl_exit_error; } } - return bsub_exit_ok; + return bacl_exit_ok; } /* * For this OS setup the build and parse function pointer to the OS specific functions. */ -static bsub_exit_code (*os_build_acl_streams)(JCR *jcr, FF_PKT *ff_pkt) = hpux_build_acl_streams; -static bsub_exit_code (*os_parse_acl_streams)(JCR *jcr, int stream) = hpux_parse_acl_streams; +static bacl_exit_code (*os_build_acl_streams)(JCR *jcr, FF_PKT *ff_pkt) = hpux_build_acl_streams; +static bacl_exit_code (*os_parse_acl_streams)(JCR *jcr, int stream) = hpux_parse_acl_streams; #elif defined(HAVE_SUN_OS) #ifdef HAVE_SYS_ACL_H @@ -889,12 +889,12 @@ static int os_default_acl_streams[1] = { -1 }; * for acls retrieved and stored in the database with older fd versions. If the * new interface is not defined (Solaris 9 and older we fall back to the old code) */ -static bsub_exit_code solaris_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) +static bacl_exit_code solaris_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) { int acl_enabled, flags; acl_t *aclp; char *acl_text; - bsub_exit_code stream_status = bsub_exit_nok; + bacl_exit_code stream_status = bacl_exit_error; berrno be; /* @@ -905,17 +905,17 @@ static bsub_exit_code solaris_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) case 0: pm_strcpy(jcr->acl_data, ""); jcr->acl_data_len = 0; - return bsub_exit_ok; + return bacl_exit_ok; case -1: switch (errno) { case ENOENT: - return bsub_exit_ok; + return bacl_exit_ok; default: Mmsg2(jcr->errmsg, _("pathconf error on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); Dmsg2(100, "pathconf error file=%s ERR=%s\n", jcr->last_fname, be.bstrerror()); - return bsub_exit_nok; + return bacl_exit_error; } default: break; @@ -927,13 +927,13 @@ static bsub_exit_code solaris_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) if (acl_get(jcr->last_fname, ACL_NO_TRIVIAL, &aclp) != 0) { switch (errno) { case ENOENT: - return bsub_exit_ok; + return bacl_exit_ok; default: Mmsg2(jcr->errmsg, _("acl_get error on file \"%s\": ERR=%s\n"), jcr->last_fname, acl_strerror(errno)); Dmsg2(100, "acl_get error file=%s ERR=%s\n", jcr->last_fname, acl_strerror(errno)); - return bsub_exit_nok; + return bacl_exit_error; } } @@ -944,7 +944,7 @@ static bsub_exit_code solaris_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) */ pm_strcpy(jcr->acl_data, ""); jcr->acl_data_len = 0; - return bsub_exit_ok; + return bacl_exit_ok; } #if defined(ACL_SID_FMT) @@ -976,7 +976,7 @@ static bsub_exit_code solaris_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) return stream_status; } -static bsub_exit_code solaris_parse_acl_streams(JCR *jcr, int stream) +static bacl_exit_code solaris_parse_acl_streams(JCR *jcr, int stream) { acl_t *aclp; int acl_enabled, error; @@ -994,17 +994,17 @@ static bsub_exit_code solaris_parse_acl_streams(JCR *jcr, int stream) case 0: Mmsg1(jcr->errmsg, _("Trying to restore acl on file \"%s\" on filesystem without acl support\n"), jcr->last_fname); - return bsub_exit_nok; + return bacl_exit_error; case -1: switch (errno) { case ENOENT: - return bsub_exit_ok; + return bacl_exit_ok; default: Mmsg2(jcr->errmsg, _("pathconf error on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); Dmsg3(100, "pathconf error acl=%s file=%s ERR=%s\n", jcr->acl_data, jcr->last_fname, be.bstrerror()); - return bsub_exit_nok; + return bacl_exit_error; } default: /* @@ -1018,7 +1018,7 @@ static bsub_exit_code solaris_parse_acl_streams(JCR *jcr, int stream) if ((acl_enabled & (_ACL_ACLENT_ENABLED | _ACL_ACE_ENABLED)) == 0) { Mmsg1(jcr->errmsg, _("Trying to restore acl on file \"%s\" on filesystem without aclent acl support\n"), jcr->last_fname); - return bsub_exit_nok; + return bacl_exit_error; } break; case STREAM_ACL_SOLARIS_ACE: @@ -1028,7 +1028,7 @@ static bsub_exit_code solaris_parse_acl_streams(JCR *jcr, int stream) if ((acl_enabled & _ACL_ACE_ENABLED) == 0) { Mmsg1(jcr->errmsg, _("Trying to restore acl on file \"%s\" on filesystem without ace acl support\n"), jcr->last_fname); - return bsub_exit_nok; + return bacl_exit_error; } break; default: @@ -1045,7 +1045,7 @@ static bsub_exit_code solaris_parse_acl_streams(JCR *jcr, int stream) jcr->last_fname, acl_strerror(error)); Dmsg3(100, "acl_fromtext error acl=%s file=%s ERR=%s\n", jcr->acl_data, jcr->last_fname, acl_strerror(error)); - return bsub_exit_nok; + return bacl_exit_error; } /* @@ -1056,14 +1056,14 @@ static bsub_exit_code solaris_parse_acl_streams(JCR *jcr, int stream) if (acl_type(aclp) != ACLENT_T) { Mmsg1(jcr->errmsg, _("wrong encoding of acl type in acl stream on file \"%s\"\n"), jcr->last_fname); - return bsub_exit_nok; + return bacl_exit_error; } break; case STREAM_ACL_SOLARIS_ACE: if (acl_type(aclp) != ACE_T) { Mmsg1(jcr->errmsg, _("wrong encoding of acl type in acl stream on file \"%s\"\n"), jcr->last_fname); - return bsub_exit_nok; + return bacl_exit_error; } break; default: @@ -1083,21 +1083,21 @@ static bsub_exit_code solaris_parse_acl_streams(JCR *jcr, int stream) switch (errno) { case ENOENT: acl_free(aclp); - return bsub_exit_ok; + return bacl_exit_ok; default: Mmsg2(jcr->errmsg, _("acl_set error on file \"%s\": ERR=%s\n"), jcr->last_fname, acl_strerror(error)); Dmsg3(100, "acl_set error acl=%s file=%s ERR=%s\n", jcr->acl_data, jcr->last_fname, acl_strerror(error)); acl_free(aclp); - return bsub_exit_nok; + return bacl_exit_error; } } acl_free(aclp); - return bsub_exit_ok; + return bacl_exit_ok; default: - return bsub_exit_nok; + return bacl_exit_error; } /* end switch (stream) */ } @@ -1133,7 +1133,7 @@ static bool acl_is_trivial(int count, aclent_t *entries) /* * OS specific functions for handling different types of acl streams. */ -static bsub_exit_code solaris_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) +static bacl_exit_code solaris_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) { int n; aclent_t *acls; @@ -1142,7 +1142,7 @@ static bsub_exit_code solaris_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) n = acl(jcr->last_fname, GETACLCNT, 0, NULL); if (n < MIN_ACL_ENTRIES) - return bsub_exit_nok; + return bacl_exit_error; acls = (aclent_t *)malloc(n * sizeof(aclent_t)); if (acl(jcr->last_fname, GETACL, n, acls) == n) { @@ -1154,7 +1154,7 @@ static bsub_exit_code solaris_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) free(acls); pm_strcpy(jcr->acl_data, ""); jcr->acl_data_len = 0; - return bsub_exit_ok; + return bacl_exit_ok; } if ((acl_text = acltotext(acls, n)) != NULL) { @@ -1171,10 +1171,10 @@ static bsub_exit_code solaris_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) } free(acls); - return bsub_exit_nok; + return bacl_exit_error; } -static bsub_exit_code solaris_parse_acl_streams(JCR *jcr, int stream) +static bacl_exit_code solaris_parse_acl_streams(JCR *jcr, int stream) { int n; aclent_t *acls; @@ -1186,7 +1186,7 @@ static bsub_exit_code solaris_parse_acl_streams(JCR *jcr, int stream) jcr->last_fname, be.bstrerror()); Dmsg3(100, "aclfromtext error acl=%s file=%s ERR=%s\n", jcr->acl_data, jcr->last_fname, be.bstrerror()); - return bsub_exit_nok; + return bacl_exit_error; } /* @@ -1197,26 +1197,26 @@ static bsub_exit_code solaris_parse_acl_streams(JCR *jcr, int stream) switch (errno) { case ENOENT: actuallyfree(acls); - return bsub_exit_ok; + return bacl_exit_ok; default: Mmsg2(jcr->errmsg, _("acl(SETACL) error on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); Dmsg3(100, "acl(SETACL) error acl=%s file=%s ERR=%s\n", jcr->acl_data, jcr->last_fname, be.bstrerror()); actuallyfree(acls); - return bsub_exit_nok; + return bacl_exit_error; } } actuallyfree(acls); - return bsub_exit_ok; + return bacl_exit_ok; } #endif /* HAVE_EXTENDED_ACL */ /* * For this OS setup the build and parse function pointer to the OS specific functions. */ -static bsub_exit_code (*os_build_acl_streams)(JCR *jcr, FF_PKT *ff_pkt) = solaris_build_acl_streams; -static bsub_exit_code (*os_parse_acl_streams)(JCR *jcr, int stream) = solaris_parse_acl_streams; +static bacl_exit_code (*os_build_acl_streams)(JCR *jcr, FF_PKT *ff_pkt) = solaris_build_acl_streams; +static bacl_exit_code (*os_parse_acl_streams)(JCR *jcr, int stream) = solaris_parse_acl_streams; #endif /* HAVE_SUN_OS */ @@ -1227,7 +1227,7 @@ static bsub_exit_code (*os_parse_acl_streams)(JCR *jcr, int stream) = solaris_pa /* * Read and send an ACL for the last encountered file. */ -bsub_exit_code build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) +bacl_exit_code build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) { /* * Call the appropriate function. @@ -1235,10 +1235,10 @@ bsub_exit_code build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) if (os_build_acl_streams) { return (*os_build_acl_streams)(jcr, ff_pkt); } - return bsub_exit_nok; + return bacl_exit_error; } -bsub_exit_code parse_acl_streams(JCR *jcr, int stream) +bacl_exit_code parse_acl_streams(JCR *jcr, int stream) { int cnt; @@ -1276,6 +1276,6 @@ bsub_exit_code parse_acl_streams(JCR *jcr, int stream) Qmsg2(jcr, M_WARNING, 0, _("Can't restore ACLs of %s - incompatible acl stream encountered - %d\n"), jcr->last_fname, stream); - return bsub_exit_nok; + return bacl_exit_error; } #endif diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index 517e3c7679..54f42f9613 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -612,9 +612,9 @@ int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level) 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 bsub_exit_fatal: + case bacl_exit_fatal: goto bail_out; - case bsub_exit_nok: + 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. @@ -624,7 +624,7 @@ int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level) } jcr->total_acl_errors++; break; - case bsub_exit_ok: + case bacl_exit_ok: break; } } @@ -636,9 +636,9 @@ int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level) if (have_xattr) { if (ff_pkt->flags & FO_XATTR && !ff_pkt->cmd_plugin) { switch (build_xattr_streams(jcr, ff_pkt)) { - case bsub_exit_fatal: + case bxattr_exit_fatal: goto bail_out; - case bsub_exit_nok: + 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. @@ -648,7 +648,7 @@ int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level) } jcr->total_xattr_errors++; break; - case bsub_exit_ok: + case bxattr_exit_ok: break; } } diff --git a/bacula/src/filed/filed.h b/bacula/src/filed/filed.h index 078f11019c..b82aef0860 100644 --- a/bacula/src/filed/filed.h +++ b/bacula/src/filed/filed.h @@ -44,13 +44,22 @@ #define XATTR_REPORT_ERR_MAX_PER_JOB 25 /* - * Return codes from acl and xattr subroutines. + * Return codes from acl subroutines. */ typedef enum { - bsub_exit_fatal = -1, - bsub_exit_nok = 0, - bsub_exit_ok = 1 -} bsub_exit_code; + bacl_exit_fatal = -1, + bacl_exit_error = 0, + bacl_exit_ok = 1 +} bacl_exit_code; + +/* + * Return codes from xattr subroutines. + */ +typedef enum { + bxattr_exit_fatal = -1, + bxattr_exit_error = 0, + bxattr_exit_ok = 1 +} bxattr_exit_code; #define FILE_DAEMON 1 #include "lib/htable.h" diff --git a/bacula/src/filed/protos.h b/bacula/src/filed/protos.h index 4a6d476e37..4c426923d0 100644 --- a/bacula/src/filed/protos.h +++ b/bacula/src/filed/protos.h @@ -47,8 +47,8 @@ void start_dir_heartbeat(JCR *jcr); void stop_dir_heartbeat(JCR *jcr); /* From acl.c */ -bsub_exit_code build_acl_streams(JCR *jcr, FF_PKT *ff_pkt); -bsub_exit_code parse_acl_streams(JCR *jcr, int stream); +bacl_exit_code build_acl_streams(JCR *jcr, FF_PKT *ff_pkt); +bacl_exit_code parse_acl_streams(JCR *jcr, int stream); /* from accurate.c */ bool accurate_send_deleted_list(JCR *jcr); @@ -62,5 +62,5 @@ void strip_path(FF_PKT *ff_pkt); void unstrip_path(FF_PKT *ff_pkt); /* from xattr.c */ -bsub_exit_code build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt); -bsub_exit_code parse_xattr_streams(JCR *jcr, int stream); +bxattr_exit_code build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt); +bxattr_exit_code parse_xattr_streams(JCR *jcr, int stream); diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c index 3f367f43aa..c1dc3b7352 100644 --- a/bacula/src/filed/restore.c +++ b/bacula/src/filed/restore.c @@ -613,9 +613,9 @@ void do_restore(JCR *jcr) pm_memcpy(jcr->acl_data, sd->msg, sd->msglen); jcr->acl_data_len = sd->msglen; switch (parse_acl_streams(jcr, rctx.stream)) { - case bsub_exit_fatal: + case bacl_exit_fatal: goto bail_out; - case bsub_exit_nok: + 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. @@ -625,7 +625,7 @@ void do_restore(JCR *jcr) } jcr->total_acl_errors++; break; - case bsub_exit_ok: + case bacl_exit_ok: break; } } else { @@ -652,9 +652,9 @@ void do_restore(JCR *jcr) pm_memcpy(jcr->xattr_data, sd->msg, sd->msglen); jcr->xattr_data_len = sd->msglen; switch (parse_xattr_streams(jcr, rctx.stream)) { - case bsub_exit_fatal: + case bxattr_exit_fatal: goto bail_out; - case bsub_exit_nok: + 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. @@ -664,7 +664,7 @@ void do_restore(JCR *jcr) } jcr->total_xattr_errors++; break; - case bsub_exit_ok: + case bxattr_exit_ok: break; } } else { diff --git a/bacula/src/filed/xattr.c b/bacula/src/filed/xattr.c index 3af55cf3be..f66b829958 100644 --- a/bacula/src/filed/xattr.c +++ b/bacula/src/filed/xattr.c @@ -51,32 +51,32 @@ /* * Entry points when compiled without support for XATTRs or on an unsupported platform. */ -bsub_exit_code build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) +bxattr_exit_code build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) { - return bsub_exit_fatal; + return bxattr_exit_fatal; } -bsub_exit_code parse_xattr_streams(JCR *jcr, int stream) +bxattr_exit_code parse_xattr_streams(JCR *jcr, int stream) { - return bsub_exit_fatal; + return bxattr_exit_fatal; } #else /* * Send a XATTR stream to the SD. */ -static bsub_exit_code send_xattr_stream(JCR *jcr, int stream) +static bxattr_exit_code send_xattr_stream(JCR *jcr, int stream) { BSOCK *sd = jcr->store_bsock; POOLMEM *msgsave; #ifdef FD_NO_SEND_TEST - return bsub_exit_ok; + return bxattr_exit_ok; #endif /* * Sanity check */ if (jcr->xattr_data_len <= 0) - return bsub_exit_ok; + return bxattr_exit_ok; /* * Send header @@ -84,7 +84,7 @@ static bsub_exit_code send_xattr_stream(JCR *jcr, int stream) if (!sd->fsend("%ld %d 0", jcr->JobFiles, stream)) { Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), sd->bstrerror()); - return bsub_exit_fatal; + return bxattr_exit_fatal; } /* @@ -99,7 +99,7 @@ static bsub_exit_code send_xattr_stream(JCR *jcr, int stream) sd->msglen = 0; Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), sd->bstrerror()); - return bsub_exit_fatal; + return bxattr_exit_fatal; } jcr->JobBytes += sd->msglen; @@ -107,10 +107,10 @@ static bsub_exit_code send_xattr_stream(JCR *jcr, int stream) if (!sd->signal(BNET_EOD)) { Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), sd->bstrerror()); - return bsub_exit_fatal; + return bxattr_exit_fatal; } Dmsg1(200, "XATTR of file: %s successfully backed up!\n", jcr->last_fname); - return bsub_exit_ok; + return bxattr_exit_ok; } /* @@ -241,7 +241,7 @@ static uint32_t serialize_xattr_stream(JCR *jcr, uint32_t expected_serialize_len return jcr->xattr_data_len; } -static bsub_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) +static bxattr_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) { int count = 0; int32_t xattr_list_len, @@ -249,7 +249,7 @@ static bsub_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) uint32_t expected_serialize_len = 0; char *xattr_list, *bp; xattr_t *xattr_value_list = NULL, *current_xattr; - bsub_exit_code retval = bsub_exit_nok; + bxattr_exit_code retval = bxattr_exit_error; berrno be; /* @@ -259,16 +259,16 @@ static bsub_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) if (xattr_list_len < 0) { switch (errno) { case ENOENT: - return bsub_exit_ok; + return bxattr_exit_ok; default: Mmsg2(jcr->errmsg, _("llistxattr error on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); Dmsg2(100, "llistxattr error file=%s ERR=%s\n", jcr->last_fname, be.bstrerror()); - return bsub_exit_nok; + return bxattr_exit_error; } } else if (xattr_list_len == 0) { - return bsub_exit_ok; + return bxattr_exit_ok; } /* @@ -284,7 +284,7 @@ static bsub_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) if (xattr_list_len < 0) { switch (errno) { case ENOENT: - retval = bsub_exit_ok; + retval = bxattr_exit_ok; goto bail_out; default: Mmsg2(jcr->errmsg, _("llistxattr error on file \"%s\": ERR=%s\n"), @@ -317,7 +317,7 @@ static bsub_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) } if (count == 0) { - retval = bsub_exit_ok; + retval = bxattr_exit_ok; goto bail_out; } @@ -369,7 +369,7 @@ static bsub_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) if (xattr_value_len < 0) { switch (errno) { case ENOENT: - retval = bsub_exit_ok; + retval = bxattr_exit_ok; goto bail_out; default: Mmsg2(jcr->errmsg, _("lgetxattr error on file \"%s\": ERR=%s\n"), @@ -390,7 +390,7 @@ static bsub_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) if (xattr_value_len < 0) { switch (errno) { case ENOENT: - retval = bsub_exit_ok; + retval = bxattr_exit_ok; goto bail_out; default: Mmsg2(jcr->errmsg, _("lgetxattr error on file \"%s\": ERR=%s\n"), @@ -450,11 +450,11 @@ bail_out: return retval; } -static bsub_exit_code generic_xattr_parse_streams(JCR *jcr, int stream) +static bxattr_exit_code generic_xattr_parse_streams(JCR *jcr, int stream) { unser_declare; xattr_t current_xattr; - bsub_exit_code retval = bsub_exit_ok; + bxattr_exit_code retval = bxattr_exit_ok; berrno be; /* @@ -475,7 +475,7 @@ static bsub_exit_code generic_xattr_parse_streams(JCR *jcr, int stream) jcr->last_fname); Dmsg1(100, "Illegal xattr stream, no XATTR_MAGIC on file \"%s\"\n", jcr->last_fname); - return bsub_exit_nok; + return bxattr_exit_error; } /* @@ -520,7 +520,7 @@ static bsub_exit_code generic_xattr_parse_streams(JCR *jcr, int stream) jcr->last_fname, be.bstrerror()); Dmsg2(100, "lsetxattr error file=%s ERR=%s\n", jcr->last_fname, be.bstrerror()); - retval = bsub_exit_nok; + retval = bxattr_exit_error; break; } } @@ -539,8 +539,8 @@ static bsub_exit_code generic_xattr_parse_streams(JCR *jcr, int stream) /* * For all these os-es setup the build and parse function pointer to the generic functions. */ -static bsub_exit_code (*os_build_xattr_streams)(JCR *jcr, FF_PKT *ff_pkt) = generic_xattr_build_streams; -static bsub_exit_code (*os_parse_xattr_streams)(JCR *jcr, int stream) = generic_xattr_parse_streams; +static bxattr_exit_code (*os_build_xattr_streams)(JCR *jcr, FF_PKT *ff_pkt) = generic_xattr_build_streams; +static bxattr_exit_code (*os_parse_xattr_streams)(JCR *jcr, int stream) = generic_xattr_parse_streams; #elif defined(HAVE_SUN_OS) /* @@ -663,7 +663,7 @@ static int toplevel_hidden_dir_xattr_data_len; */ static alist *xattr_link_cache = NULL; -static struct xattr_link_cache_entry *find_xattr_link_cache_entry(ino_t inum) +static xattr_link_cache_entry *find_xattr_link_cache_entry(ino_t inum) { xattr_link_cache_entry_t *ptr; @@ -679,8 +679,8 @@ static void add_xattr_link_cache_entry(ino_t inum, char *target) { xattr_link_cache_entry_t *ptr; - ptr = (xattr_link_cache_entry_t *)malloc(sizeof(struct xattr_link_cache_entry)); - memset((caddr_t)ptr, 0, sizeof(struct xattr_link_cache_entry)); + ptr = (xattr_link_cache_entry_t *)malloc(sizeof(xattr_link_cache_entry)); + memset((caddr_t)ptr, 0, sizeof(xattr_link_cache_entry)); ptr->inum = inum; bstrncpy(ptr->target, target, sizeof(ptr->target)); xattr_link_cache->append(ptr); @@ -781,7 +781,7 @@ static bool acl_is_trivial(int count, aclent_t *entries) } #endif /* HAVE_ACL && !HAVE_EXTENDED_ACL */ -static bsub_exit_code solaris_save_xattr_acl(JCR *jcr, int fd, const char *attrname, char **acl_text) +static bxattr_exit_code solaris_save_xattr_acl(JCR *jcr, int fd, const char *attrname, char **acl_text) { #ifdef HAVE_ACL #ifdef HAVE_EXTENDED_ACL @@ -801,13 +801,13 @@ static bsub_exit_code solaris_save_xattr_acl(JCR *jcr, int fd, const char *attrn acl_get(attrname, ACL_NO_TRIVIAL, &aclp) != 0) { switch (errno) { case ENOENT: - return bsub_exit_ok; + return bxattr_exit_ok; default: Mmsg3(jcr->errmsg, _("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", attrname, jcr->last_fname, be.bstrerror()); - return bsub_exit_nok; + return bxattr_exit_error; } } @@ -829,7 +829,7 @@ static bsub_exit_code solaris_save_xattr_acl(JCR *jcr, int fd, const char *attrn } else { *acl_text = NULL; } - return bsub_exit_ok; + return bxattr_exit_ok; #else /* HAVE_EXTENDED_ACL */ int n; aclent_t *acls = NULL; @@ -851,14 +851,14 @@ static bsub_exit_code solaris_save_xattr_acl(JCR *jcr, int fd, const char *attrn switch (errno) { case ENOENT: free(acls); - return bsub_exit_ok; + return bxattr_exit_ok; default: Mmsg3(jcr->errmsg, _("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", attrname, jcr->last_fname, be.bstrerror()); free(acls); - return bsub_exit_nok; + return bxattr_exit_error; } } @@ -872,7 +872,7 @@ static bsub_exit_code solaris_save_xattr_acl(JCR *jcr, int fd, const char *attrn Dmsg3(100, "acltotext of xattr %s on \"%s\" failed: ERR=%s\n", attrname, jcr->last_fname, be.bstrerror()); free(acls); - return bsub_exit_nok; + return bxattr_exit_error; } } else { *acl_text = NULL; @@ -882,18 +882,18 @@ static bsub_exit_code solaris_save_xattr_acl(JCR *jcr, int fd, const char *attrn } else { *acl_text = NULL; } - return bsub_exit_ok; + return bxattr_exit_ok; #endif /* HAVE_EXTENDED_ACL */ #else /* HAVE_ACL */ - return bsub_exit_ok; + return bxattr_exit_ok; #endif /* HAVE_ACL */ } /* * Forward declaration for recursive function call. */ -static bsub_exit_code solaris_save_xattrs(JCR *jcr, const char *xattr_namespace, const char *attr_parent); +static bxattr_exit_code solaris_save_xattrs(JCR *jcr, const char *xattr_namespace, const char *attr_parent); /* * Save an extended or extensible attribute. @@ -910,19 +910,19 @@ static bsub_exit_code solaris_save_xattrs(JCR *jcr, const char *xattr_namespace, * acl_string is an acl text when a non trivial acl is set on the xattr. * actual_xattr_data is the content of the xattr file. */ -static bsub_exit_code solaris_save_xattr(JCR *jcr, int fd, const char *xattr_namespace, +static bxattr_exit_code solaris_save_xattr(JCR *jcr, int fd, const char *xattr_namespace, const char *attrname, bool toplevel_hidden_dir, int stream) { int cnt; int attrfd = -1; struct stat st; - struct xattr_link_cache_entry *xlce; + xattr_link_cache_entry *xlce; char target_attrname[PATH_MAX]; char link_source[PATH_MAX]; char *acl_text = NULL; char attribs[MAXSTRING]; char buffer[BUFSIZ]; - bsub_exit_code retval = bsub_exit_nok; + bxattr_exit_code retval = bxattr_exit_error; berrno be; bsnprintf(target_attrname, sizeof(target_attrname), "%s%s", xattr_namespace, attrname); @@ -933,7 +933,7 @@ static bsub_exit_code solaris_save_xattr(JCR *jcr, int fd, const char *xattr_nam if (fstatat(fd, attrname, &st, AT_SYMLINK_NOFOLLOW) < 0) { switch (errno) { case ENOENT: - retval = bsub_exit_ok; + retval = bxattr_exit_ok; goto bail_out; default: Mmsg3(jcr->errmsg, _("Unable to get status on xattr %s on file \"%s\": ERR=%s\n"), @@ -956,7 +956,7 @@ static bsub_exit_code solaris_save_xattr(JCR *jcr, int fd, const char *xattr_nam /* * Get any acl on the xattr. */ - if (solaris_save_xattr_acl(jcr, attrfd, attrname, &acl_text) != bsub_exit_ok) + if (solaris_save_xattr_acl(jcr, attrfd, attrname, &acl_text) != bxattr_exit_ok) goto bail_out; /* @@ -972,7 +972,7 @@ static bsub_exit_code solaris_save_xattr(JCR *jcr, int fd, const char *xattr_nam /* * Get any acl on the xattr. */ - if (solaris_save_xattr_acl(jcr, attrfd, attrname, &acl_text) != bsub_exit_ok) + if (solaris_save_xattr_acl(jcr, attrfd, attrname, &acl_text) != bxattr_exit_ok) goto bail_out; /* @@ -1037,7 +1037,7 @@ static bsub_exit_code solaris_save_xattr(JCR *jcr, int fd, const char *xattr_nam /* * Get any acl on the xattr. */ - if (solaris_save_xattr_acl(jcr, attrfd, attrname, &acl_text) != bsub_exit_ok) { + if (solaris_save_xattr_acl(jcr, attrfd, attrname, &acl_text) != bxattr_exit_ok) { goto bail_out; } @@ -1055,7 +1055,7 @@ static bsub_exit_code solaris_save_xattr(JCR *jcr, int fd, const char *xattr_nam if ((attrfd = openat(fd, attrname, O_RDONLY)) < 0) { switch (errno) { case ENOENT: - retval = bsub_exit_ok; + retval = bxattr_exit_ok; goto bail_out; default: Mmsg3(jcr->errmsg, _("Unable to open xattr %s on \"%s\": ERR=%s\n"), @@ -1075,7 +1075,7 @@ static bsub_exit_code solaris_save_xattr(JCR *jcr, int fd, const char *xattr_nam if (readlink(attrname, link_source, sizeof(link_source)) < 0) { switch (errno) { case ENOENT: - retval = bsub_exit_ok; + retval = bxattr_exit_ok; goto bail_out; default: Mmsg3(jcr->errmsg, _("Unable to read symlin %s on \"%s\": ERR=%s\n"), @@ -1171,7 +1171,7 @@ static bsub_exit_code solaris_save_xattr(JCR *jcr, int fd, const char *xattr_nam if (fchdir(fd) < 0) { switch (errno) { case ENOENT: - retval = bsub_exit_ok; + retval = bxattr_exit_ok; goto bail_out; default: Mmsg2(jcr->errmsg, _("Unable to chdir to xattr space of file \"%s\": ERR=%s\n"), @@ -1193,14 +1193,14 @@ bail_out: return retval; } -static bsub_exit_code solaris_save_xattrs(JCR *jcr, const char *xattr_namespace, const char *attr_parent) +static bxattr_exit_code solaris_save_xattrs(JCR *jcr, const char *xattr_namespace, const char *attr_parent) { const char *name; int fd, filefd = -1, attrdirfd = -1; DIR *dirp; struct dirent *dp; char current_xattr_namespace[PATH_MAX]; - bsub_exit_code retval = bsub_exit_nok; + bxattr_exit_code retval = bxattr_exit_error; berrno be; /* @@ -1227,7 +1227,7 @@ static bsub_exit_code solaris_save_xattrs(JCR *jcr, const char *xattr_namespace, if ((filefd = open(name, O_RDONLY | O_NONBLOCK)) < 0) { switch (errno) { case ENOENT: - retval = bsub_exit_ok; + retval = bxattr_exit_ok; goto bail_out; default: Mmsg2(jcr->errmsg, _("Unable to open file \"%s\": ERR=%s\n"), @@ -1249,10 +1249,10 @@ static bsub_exit_code solaris_save_xattrs(JCR *jcr, const char *xattr_namespace, * Which is not problem we just forget about this this xattr. * But as this is not an error we return a positive return value. */ - retval = bsub_exit_ok; + retval = bxattr_exit_ok; goto bail_out; case ENOENT: - retval = bsub_exit_ok; + retval = bxattr_exit_ok; goto bail_out; default: Mmsg3(jcr->errmsg, _("Unable to open xattr space %s on file \"%s\": ERR=%s\n"), @@ -1356,7 +1356,7 @@ static bsub_exit_code solaris_save_xattrs(JCR *jcr, const char *xattr_namespace, } closedir(dirp); - retval = bsub_exit_ok; + retval = bxattr_exit_ok; bail_out: if (attrdirfd != -1) @@ -1367,7 +1367,7 @@ bail_out: } #ifdef HAVE_ACL -static bsub_exit_code solaris_restore_xattr_acl(JCR *jcr, int fd, const char *attrname, char *acl_text) +static bxattr_exit_code solaris_restore_xattr_acl(JCR *jcr, int fd, const char *attrname, char *acl_text) { #ifdef HAVE_EXTENDED_ACL int error; @@ -1377,7 +1377,7 @@ static bsub_exit_code solaris_restore_xattr_acl(JCR *jcr, int fd, const char *at if ((error = acl_fromtext(acl_text, &aclp)) != 0) { Mmsg1(jcr->errmsg, _("Unable to convert acl from text on file \"%s\"\n"), jcr->last_fname); - return bsub_exit_nok; + return bxattr_exit_error; } if ((fd != -1 && facl_set(fd, aclp) != 0) || @@ -1386,13 +1386,13 @@ static bsub_exit_code solaris_restore_xattr_acl(JCR *jcr, int fd, const char *at attrname, jcr->last_fname, be.bstrerror()); Dmsg3(100, "Unable to restore acl of xattr %s on file \"%s\": ERR=%s\n", attrname, jcr->last_fname, be.bstrerror()); - return bsub_exit_nok; + return bxattr_exit_error; } if (aclp) { acl_free(aclp); } - return bsub_exit_ok; + return bxattr_exit_ok; #else /* HAVE_EXTENDED_ACL */ int n; @@ -1407,21 +1407,21 @@ static bsub_exit_code solaris_restore_xattr_acl(JCR *jcr, int fd, const char *at attrname, jcr->last_fname, be.bstrerror()); Dmsg3(100, "Unable to restore acl of xattr %s on file \"%s\": ERR=%s\n", attrname, jcr->last_fname, be.bstrerror()); - return bsub_exit_nok; + return bxattr_exit_error; } } if (acls) { free(acls); } - return bsub_exit_ok; + return bxattr_exit_ok; #endif /* HAVE_EXTENDED_ACL */ } #endif /* HAVE_ACL */ -static bsub_exit_code solaris_restore_xattrs(JCR *jcr, bool is_extensible) +static bxattr_exit_code solaris_restore_xattrs(JCR *jcr, bool is_extensible) { int fd, filefd = -1, attrdirfd = -1, attrfd = -1; int used_bytes, total_bytes, cnt; @@ -1432,7 +1432,7 @@ static bsub_exit_code solaris_restore_xattrs(JCR *jcr, bool is_extensible) int32_t inum; struct stat st; struct timeval times[2]; - bsub_exit_code retval = bsub_exit_nok; + bxattr_exit_code retval = bxattr_exit_error; berrno be; /* @@ -1612,7 +1612,7 @@ static bsub_exit_code solaris_restore_xattrs(JCR *jcr, bool is_extensible) /* * Successfully restored xattr. */ - retval = bsub_exit_ok; + retval = bxattr_exit_ok; goto bail_out; } else { if ((bp = strchr(acl_text, '\0')) == (char *)NULL || @@ -1691,7 +1691,7 @@ static bsub_exit_code solaris_restore_xattrs(JCR *jcr, bool is_extensible) /* * Successfully restored xattr. */ - retval = bsub_exit_ok; + retval = bxattr_exit_ok; goto bail_out; default: goto bail_out; @@ -1708,10 +1708,10 @@ static bsub_exit_code solaris_restore_xattrs(JCR *jcr, bool is_extensible) * Gentile way of the system saying this type of xattr layering is not supported. * But as this is not an error we return a positive return value. */ - retval = bsub_exit_ok; + retval = bxattr_exit_ok; break; case ENOENT: - retval = bsub_exit_ok; + retval = bxattr_exit_ok; break; default: Mmsg3(jcr->errmsg, _("Unable to restore owner of xattr %s on file \"%s\": ERR=%s\n"), @@ -1725,7 +1725,7 @@ static bsub_exit_code solaris_restore_xattrs(JCR *jcr, bool is_extensible) #ifdef HAVE_ACL if (acl_text && *acl_text) - if (solaris_restore_xattr_acl(jcr, attrfd, target_attrname, acl_text) != bsub_exit_ok) + if (solaris_restore_xattr_acl(jcr, attrfd, target_attrname, acl_text) != bxattr_exit_ok) goto bail_out; #endif /* HAVE_ACL */ @@ -1750,7 +1750,7 @@ static bsub_exit_code solaris_restore_xattrs(JCR *jcr, bool is_extensible) /* * Successfully restored xattr. */ - retval = bsub_exit_ok; + retval = bxattr_exit_ok; goto bail_out; parse_error: @@ -1772,10 +1772,10 @@ bail_out: return retval; } -static bsub_exit_code solaris_build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) +static bxattr_exit_code solaris_build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) { char cwd[PATH_MAX]; - bsub_exit_code retval = bsub_exit_ok; + bxattr_exit_code retval = bxattr_exit_ok; /* * First see if extended attributes or extensible attributes are present. @@ -1798,11 +1798,11 @@ static bsub_exit_code solaris_build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) return retval; } -static bsub_exit_code solaris_parse_xattr_streams(JCR *jcr, int stream) +static bxattr_exit_code solaris_parse_xattr_streams(JCR *jcr, int stream) { char cwd[PATH_MAX]; bool is_extensible = false; - bsub_exit_code retval; + bxattr_exit_code retval; /* * First make sure we can restore xattr on the filesystem. @@ -1816,7 +1816,7 @@ static bsub_exit_code solaris_parse_xattr_streams(JCR *jcr, int stream) jcr->last_fname); Dmsg1(100, "Unable to restore extensible attributes on file \"%s\", filesystem doesn't support this\n", jcr->last_fname); - return bsub_exit_nok; + return bxattr_exit_error; } is_extensible = true; @@ -1829,11 +1829,11 @@ static bsub_exit_code solaris_parse_xattr_streams(JCR *jcr, int stream) jcr->last_fname); Dmsg1(100, "Unable to restore extended attributes on file \"%s\", filesystem doesn't support this\n", jcr->last_fname); - return bsub_exit_nok; + return bxattr_exit_error; } break; default: - return bsub_exit_nok; + return bxattr_exit_error; } /* @@ -1850,23 +1850,23 @@ static bsub_exit_code solaris_parse_xattr_streams(JCR *jcr, int stream) /* * Function pointers to the build and parse function to use for these xattrs. */ -static bsub_exit_code (*os_build_xattr_streams)(JCR *jcr, FF_PKT *ff_pkt) = solaris_build_xattr_streams; -static bsub_exit_code (*os_parse_xattr_streams)(JCR *jcr, int stream) = solaris_parse_xattr_streams; +static bxattr_exit_code (*os_build_xattr_streams)(JCR *jcr, FF_PKT *ff_pkt) = solaris_build_xattr_streams; +static bxattr_exit_code (*os_parse_xattr_streams)(JCR *jcr, int stream) = solaris_parse_xattr_streams; #endif /* defined(HAVE_SUN_OS) */ /* * Entry points when compiled with support for XATTRs on a supported platform. */ -bsub_exit_code build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) +bxattr_exit_code build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) { if (os_build_xattr_streams) { return (*os_build_xattr_streams)(jcr, ff_pkt); } - return bsub_exit_nok; + return bxattr_exit_error; } -bsub_exit_code parse_xattr_streams(JCR *jcr, int stream) +bxattr_exit_code parse_xattr_streams(JCR *jcr, int stream) { int cnt; @@ -1886,6 +1886,6 @@ bsub_exit_code parse_xattr_streams(JCR *jcr, int stream) Jmsg2(jcr, M_WARNING, 0, _("Can't restore Extended Attributes of %s - incompatible xattr stream encountered - %d\n"), jcr->last_fname, stream); - return bsub_exit_nok; + return bxattr_exit_error; } #endif diff --git a/bacula/src/filed/xattr.h b/bacula/src/filed/xattr.h index ba66e1de4f..16056165e7 100644 --- a/bacula/src/filed/xattr.h +++ b/bacula/src/filed/xattr.h @@ -38,21 +38,21 @@ /* * Internal representation of an extended attribute. */ -typedef struct xattr { +struct xattr_t { uint32_t magic; uint32_t name_length; char *name; uint32_t value_length; char *value; -} xattr_t; +}; /* * Internal representation of an extended attribute hardlinked file. */ -typedef struct xattr_link_cache_entry { +struct xattr_link_cache_entry_t { uint32_t inum; char target[PATH_MAX]; -} xattr_link_cache_entry_t; +}; /* * Maximum size of the XATTR stream this prevents us from blowing up the filed. -- 2.39.5