From: <gi...@ba...> - 2012-02-03 20:59:07
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Bacula Community source". The branch, Branch-5.3 has been updated via 927eb9060497e03ecee2d6d6ab623439a4b90c89 (commit) via 2a8cba7af24056ba55bca513f63ab51fdd52fec1 (commit) via 8ad65aa58d26eb00db7ff6d637219eab2113c21d (commit) via e93055bc56489be45e2115a62582044d2507a8e7 (commit) via b49f4c27a49cdbe2e6208d465381bbe37f2b761e (commit) via 8852d2e3109fffbdd6248cc65dce628e2d0d111d (commit) via 554344419918d01b501441e26c350f829a1e20cb (commit) via 56e1a94161ba4d2a226093309409a23b7f55fdf9 (commit) via 9a9fc7543c578788c9ff09dd38082e0b459770a3 (commit) via cff15dca55ce128b18e91d86ae9b4a447ac48735 (commit) from 09783681c0e334daec27e8ef278c6ee42d353db9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 927eb9060497e03ecee2d6d6ab623439a4b90c89 Author: Kern Sibbald <ke...@si...> Date: Fri Feb 3 17:55:00 2012 +0100 Complicate the prune-migration regression by adding one more job commit 2a8cba7af24056ba55bca513f63ab51fdd52fec1 Author: Kern Sibbald <ke...@si...> Date: Fri Feb 3 14:36:29 2012 +0100 Implement more robust check in other drives for tape slot wanted commit 8ad65aa58d26eb00db7ff6d637219eab2113c21d Author: Kern Sibbald <ke...@si...> Date: Fri Feb 3 14:36:01 2012 +0100 Add more debug to failing test commit e93055bc56489be45e2115a62582044d2507a8e7 Author: Kern Sibbald <ke...@si...> Date: Fri Feb 3 11:30:38 2012 +0100 Fix lost dcr point -- memory loss in Copy/Migration + possible confusion commit b49f4c27a49cdbe2e6208d465381bbe37f2b761e Author: Kern Sibbald <ke...@si...> Date: Fri Feb 3 11:29:31 2012 +0100 Make copy-job test handle one more job commit 8852d2e3109fffbdd6248cc65dce628e2d0d111d Author: Marco van Wieringen <mv...@pl...> Date: Tue Jan 31 17:51:18 2012 +0100 Fix typo. commit 554344419918d01b501441e26c350f829a1e20cb Author: Marco van Wieringen <mv...@pl...> Date: Tue Jan 31 13:52:31 2012 +0100 Fix error printing in acl and xattr code. The errno gets saved on an instantiate of the berrno class so we should instantiate the class after the actual errno is set and not as we used to do at the start of the function. Then errno is always 0 and that also explains that on error it was always printing Unknown error 0 in the error printed. Moved all berrno into either an if block or an block within a switch (including additional brackets so it a local code block in which we can instantiate a new berrno class. commit 56e1a94161ba4d2a226093309409a23b7f55fdf9 Author: Marco van Wieringen <mv...@pl...> Date: Sun Jan 29 17:52:06 2012 +0100 Tweak no need to initialize the loop var. commit 9a9fc7543c578788c9ff09dd38082e0b459770a3 Author: Marco van Wieringen <mv...@pl...> Date: Sun Jan 29 17:50:07 2012 +0100 Backport better error debug output for sd plugins. commit cff15dca55ce128b18e91d86ae9b4a447ac48735 Author: Kern Sibbald <ke...@si...> Date: Fri Jan 20 14:47:47 2012 +0100 Fix plugin bug with multiple simultaneous jobs ----------------------------------------------------------------------- Summary of changes: diff --git a/bacula/src/dird/dir_plugins.c b/bacula/src/dird/dir_plugins.c index 6eb98f8..b0b29ab 100644 --- a/bacula/src/dird/dir_plugins.c +++ b/bacula/src/dird/dir_plugins.c @@ -101,7 +101,7 @@ int generate_plugin_event(JCR *jcr, bDirEventType eventType, void *value) bpContext *plugin_ctx; bDirEvent event; Plugin *plugin; - int i = 0; + int i; bRC rc = bRC_OK; if (!bplugin_list || !jcr || !jcr->plugin_ctx_list) { @@ -116,8 +116,8 @@ int generate_plugin_event(JCR *jcr, bDirEventType eventType, void *value) Dmsg2(dbglvl, "dir-plugin_ctx_list=%p JobId=%d\n", jcr->plugin_ctx_list, jcr->JobId); - foreach_alist(plugin, bplugin_list) { - plugin_ctx = &plugin_ctx_list[i++]; + foreach_alist_index(i, plugin, bplugin_list) { + plugin_ctx = &plugin_ctx_list[i]; if (is_plugin_disabled(plugin_ctx)) { continue; } @@ -155,6 +155,7 @@ void dump_dir_plugin(Plugin *plugin, FILE *fp) void load_dir_plugins(const char *plugin_dir) { Plugin *plugin; + int i; Dmsg0(dbglvl, "Load dir plugins\n"); if (!plugin_dir) { @@ -176,7 +177,7 @@ void load_dir_plugins(const char *plugin_dir) * Verify that the plugin is acceptable, and print information * about it. */ - foreach_alist(plugin, bplugin_list) { + foreach_alist_index(i, plugin, bplugin_list) { Jmsg(NULL, M_INFO, 0, _("Loaded plugin: %s\n"), plugin->file); Dmsg1(dbglvl, "Loaded plugin: %s\n", plugin->file); } @@ -237,7 +238,7 @@ static bool is_plugin_compatible(Plugin *plugin) void new_plugins(JCR *jcr) { Plugin *plugin; - int i = 0; + int i; Dmsg0(dbglvl, "=== enter new_plugins ===\n"); if (!bplugin_list) { @@ -259,14 +260,14 @@ void new_plugins(JCR *jcr) bpContext *plugin_ctx_list = jcr->plugin_ctx_list; Dmsg2(dbglvl, "Instantiate dir-plugin_ctx_list=%p JobId=%d\n", jcr->plugin_ctx_list, jcr->JobId); - foreach_alist(plugin, bplugin_list) { + foreach_alist_index(i, plugin, bplugin_list) { /* Start a new instance of each plugin */ bacula_ctx *b_ctx = (bacula_ctx *)malloc(sizeof(bacula_ctx)); memset(b_ctx, 0, sizeof(bacula_ctx)); b_ctx->jcr = jcr; plugin_ctx_list[i].bContext = (void *)b_ctx; plugin_ctx_list[i].pContext = NULL; - if (dirplug_func(plugin)->newPlugin(&plugin_ctx_list[i++]) != bRC_OK) { + if (dirplug_func(plugin)->newPlugin(&plugin_ctx_list[i]) != bRC_OK) { b_ctx->disabled = true; } } @@ -278,7 +279,7 @@ void new_plugins(JCR *jcr) void free_plugins(JCR *jcr) { Plugin *plugin; - int i = 0; + int i; if (!bplugin_list || !jcr->plugin_ctx_list) { return; @@ -286,10 +287,10 @@ void free_plugins(JCR *jcr) bpContext *plugin_ctx_list = (bpContext *)jcr->plugin_ctx_list; Dmsg2(dbglvl, "Free instance dir-plugin_ctx_list=%p JobId=%d\n", jcr->plugin_ctx_list, jcr->JobId); - foreach_alist(plugin, bplugin_list) { + foreach_alist_index(i, plugin, bplugin_list) { /* Free the plugin instance */ dirplug_func(plugin)->freePlugin(&plugin_ctx_list[i]); - free(plugin_ctx_list[i++].bContext); /* free Bacula private context */ + free(plugin_ctx_list[i].bContext); /* free Bacula private context */ } free(plugin_ctx_list); jcr->plugin_ctx_list = NULL; diff --git a/bacula/src/filed/acl.c b/bacula/src/filed/acl.c index 2570fa1..4880d70 100644 --- a/bacula/src/filed/acl.c +++ b/bacula/src/filed/acl.c @@ -193,7 +193,6 @@ static int os_default_acl_streams[1] = { static bacl_exit_code aix_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) { - berrno be; mode_t mode; acl_type_t type; size_t aclsize, acltxtsize; @@ -206,6 +205,8 @@ static bacl_exit_code aix_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) memset(&type, 0, sizeof(acl_type_t)); type.u64 = ACL_ANY; if (aclx_get(jcr->last_fname, GET_ACLINFO_ONLY, &type, NULL, &aclsize, &mode) < 0) { + berrno be; + switch (errno) { case ENOENT: retval = bacl_exit_ok; @@ -239,6 +240,8 @@ static bacl_exit_code aix_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) * Retrieve the ACL info. */ if (aclx_get(jcr->last_fname, 0, &type, aclbuf, &aclsize, &mode) < 0) { + berrno be; + switch (errno) { case ENOENT: retval = bacl_exit_ok; @@ -358,7 +361,6 @@ static bacl_exit_code aix_parse_acl_streams(JCR *jcr, uint32_t content_length) { int cnt; - berrno be; acl_type_t type; size_t aclsize; bacl_exit_code retval = bacl_exit_error; @@ -402,6 +404,8 @@ static bacl_exit_code aix_parse_acl_streams(JCR *jcr, aclbuf = check_pool_memory_size(aclbuf, content_length); aclsize = content_length; if (aclx_scanStr(content, aclbuf, &aclsize, type) < 0) { + berrno be; + switch (errno) { case ENOSPC: /* @@ -431,7 +435,7 @@ static bacl_exit_code aix_parse_acl_streams(JCR *jcr, default: Mmsg2(jcr->errmsg, _("aclx_scanStr error on file \"%s\": ERR=%s\n"), - jcr->last_fname, be.bstrerror()); + jcr->last_fname, be.bstrerror(errno)); Dmsg2(100, "aclx_scanStr error file=%s ERR=%s\n", jcr->last_fname, be.bstrerror()); goto bail_out; @@ -448,6 +452,8 @@ static bacl_exit_code aix_parse_acl_streams(JCR *jcr, } if (aclx_put(jcr->last_fname, SET_ACL, type, aclbuf, aclsize, 0) < 0) { + berrno be; + switch (errno) { case ENOENT: retval = bacl_exit_ok; @@ -748,7 +754,6 @@ static bacl_exit_code generic_get_acl_from_os(JCR *jcr, bacl_type acltype) acl_t acl; acl_type_t ostype; char *acl_text; - berrno be; bacl_exit_code retval = bacl_exit_ok; ostype = bac_to_os_acltype(acltype); @@ -805,6 +810,7 @@ static bacl_exit_code generic_get_acl_from_os(JCR *jcr, bacl_type acltype) return bacl_exit_ok; } + berrno be; Mmsg2(jcr->errmsg, _("acl_to_text error on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); @@ -814,6 +820,8 @@ static bacl_exit_code generic_get_acl_from_os(JCR *jcr, bacl_type acltype) retval = bacl_exit_error; goto bail_out; } else { + berrno be; + /* * Handle errors gracefully. */ @@ -863,7 +871,6 @@ static bacl_exit_code generic_set_acl_on_os(JCR *jcr, { acl_t acl; acl_type_t ostype; - berrno be; /* * If we get empty default ACLs, clear ACLs now @@ -873,6 +880,8 @@ static bacl_exit_code generic_set_acl_on_os(JCR *jcr, if (acl_delete_def_file(jcr->last_fname) == 0) { return bacl_exit_ok; } + berrno be; + switch (errno) { case ENOENT: return bacl_exit_ok; @@ -900,6 +909,8 @@ static bacl_exit_code generic_set_acl_on_os(JCR *jcr, acl = acl_from_text(content); if (acl == NULL) { + berrno be; + Mmsg2(jcr->errmsg, _("acl_from_text error on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); @@ -914,6 +925,8 @@ static bacl_exit_code generic_set_acl_on_os(JCR *jcr, * As it does the right thing, given valid input, just ignore acl_valid(). */ if (acl_valid(acl) != 0) { + berrno be; + Mmsg2(jcr->errmsg, _("acl_valid error on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); @@ -931,6 +944,8 @@ static bacl_exit_code generic_set_acl_on_os(JCR *jcr, * don't save acls of symlinks (which cannot have acls anyhow) */ if (acl_set_file(jcr->last_fname, ostype, acl) != 0 && jcr->last_type != FT_LNK) { + berrno be; + switch (errno) { case ENOENT: acl_free(acl); @@ -1046,7 +1061,6 @@ static bacl_exit_code freebsd_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) { int acl_enabled = 0; bacl_type acltype = BACL_TYPE_NONE; - berrno be; #if defined(_PC_ACL_NFS4) /* @@ -1054,7 +1068,9 @@ static bacl_exit_code freebsd_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) */ acl_enabled = pathconf(jcr->last_fname, _PC_ACL_NFS4); switch (acl_enabled) { - case -1: + case -1: { + berrno be; + switch (errno) { case ENOENT: return bacl_exit_ok; @@ -1066,6 +1082,7 @@ static bacl_exit_code freebsd_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) jcr->last_fname, be.bstrerror()); return bacl_exit_error; } + } case 0: break; default: @@ -1080,7 +1097,9 @@ static bacl_exit_code freebsd_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) */ acl_enabled = pathconf(jcr->last_fname, _PC_ACL_EXTENDED); switch (acl_enabled) { - case -1: + case -1: { + berrno be; + switch (errno) { case ENOENT: return bacl_exit_ok; @@ -1092,6 +1111,7 @@ static bacl_exit_code freebsd_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) jcr->last_fname, be.bstrerror()); return bacl_exit_error; } + } case 0: break; default: @@ -1167,7 +1187,6 @@ static bacl_exit_code freebsd_parse_acl_streams(JCR *jcr, { int acl_enabled = 0; const char *acl_type_name; - berrno be; /* * First make sure the filesystem supports acls. @@ -1192,7 +1211,9 @@ static bacl_exit_code freebsd_parse_acl_streams(JCR *jcr, } switch (acl_enabled) { - case -1: + case -1: { + berrno be; + switch (errno) { case ENOENT: return bacl_exit_ok; @@ -1204,6 +1225,7 @@ static bacl_exit_code freebsd_parse_acl_streams(JCR *jcr, content, jcr->last_fname, be.bstrerror()); return bacl_exit_error; } + } case 0: /* * If the filesystem reports it doesn't support ACLs we clear the @@ -1464,9 +1486,10 @@ static bacl_exit_code hpux_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) int n; struct acl_entry acls[NACLENTRIES]; char *acl_text; - berrno be; if ((n = getacl(jcr->last_fname, 0, acls)) < 0) { + berrno be; + switch (errno) { #if defined(BACL_ENOTSUP) case BACL_ENOTSUP: @@ -1521,6 +1544,8 @@ static bacl_exit_code hpux_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) return send_acl_stream(jcr, STREAM_ACL_HPUX_ACL_ENTRY); } + + berrno be; Mmsg2(jcr->errmsg, _("acltostr error on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); @@ -1538,10 +1563,11 @@ static bacl_exit_code hpux_parse_acl_streams(JCR *jcr, { int n, stat; struct acl_entry acls[NACLENTRIES]; - berrno be; n = strtoacl(content, 0, NACLENTRIES, acls, ACL_FILEOWNER, ACL_FILEGROUP); if (n <= 0) { + berrno be; + Mmsg2(jcr->errmsg, _("strtoacl error on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); @@ -1550,6 +1576,8 @@ static bacl_exit_code hpux_parse_acl_streams(JCR *jcr, return bacl_exit_error; } if (strtoacl(content, n, NACLENTRIES, acls, ACL_FILEOWNER, ACL_FILEGROUP) != n) { + berrno be; + Mmsg2(jcr->errmsg, _("strtoacl error on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); @@ -1564,8 +1592,9 @@ static bacl_exit_code hpux_parse_acl_streams(JCR *jcr, * This is only true for the old acl streams as in the new implementation we * don't save acls of symlinks (which cannot have acls anyhow) */ - if (setacl(jcr->last_fname, n, acls) != 0 && - jcr->last_type != FT_LNK) { + if (setacl(jcr->last_fname, n, acls) != 0 && jcr->last_type != FT_LNK) { + berrno be; + switch (errno) { case ENOENT: return bacl_exit_ok; @@ -1665,7 +1694,6 @@ static bacl_exit_code solaris_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) acl_t *aclp; char *acl_text; bacl_exit_code stream_status = bacl_exit_error; - berrno be; /* * See if filesystem supports acls. @@ -1683,7 +1711,9 @@ static bacl_exit_code solaris_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) pm_strcpy(jcr->acl_data->u.build->content, ""); jcr->acl_data->u.build->content_length = 0; return bacl_exit_ok; - case -1: + case -1: { + berrno be; + switch (errno) { case ENOENT: return bacl_exit_ok; @@ -1695,6 +1725,7 @@ static bacl_exit_code solaris_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) jcr->last_fname, be.bstrerror()); return bacl_exit_error; } + } default: break; } @@ -1703,6 +1734,8 @@ static bacl_exit_code solaris_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) * Get ACL info: don't bother allocating space if there is only a trivial ACL. */ if (acl_get(jcr->last_fname, ACL_NO_TRIVIAL, &aclp) != 0) { + berrno be; + switch (errno) { case ENOENT: return bacl_exit_ok; @@ -1763,7 +1796,6 @@ static bacl_exit_code solaris_parse_acl_streams(JCR *jcr, { acl_t *aclp; int acl_enabled, error; - berrno be; switch (stream) { case STREAM_UNIX_ACCESS_ACL: @@ -1786,7 +1818,9 @@ static bacl_exit_code solaris_parse_acl_streams(JCR *jcr, _("Trying to restore acl on file \"%s\" on filesystem without acl support\n"), jcr->last_fname); return bacl_exit_error; - case -1: + case -1: { + berrno be; + switch (errno) { case ENOENT: return bacl_exit_ok; @@ -1798,6 +1832,7 @@ static bacl_exit_code solaris_parse_acl_streams(JCR *jcr, content, jcr->last_fname, be.bstrerror()); return bacl_exit_error; } + } default: /* * On a filesystem with ACL support make sure this particular ACL type can be restored. @@ -1940,7 +1975,6 @@ static bacl_exit_code solaris_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) int n; aclent_t *acls; char *acl_text; - berrno be; n = acl(jcr->last_fname, GETACLCNT, 0, NULL); if (n < MIN_ACL_ENTRIES) @@ -1967,6 +2001,7 @@ static bacl_exit_code solaris_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) return send_acl_stream(jcr, STREAM_ACL_SOLARIS_ACLENT); } + berrno be; Mmsg2(jcr->errmsg, _("acltotext error on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); @@ -1985,10 +2020,11 @@ static bacl_exit_code solaris_parse_acl_streams(JCR *jcr, { int n; aclent_t *acls; - berrno be; acls = aclfromtext(content, &n); if (!acls) { + berrno be; + Mmsg2(jcr->errmsg, _("aclfromtext error on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); @@ -2002,6 +2038,8 @@ static bacl_exit_code solaris_parse_acl_streams(JCR *jcr, * not have attributes, and the file it is linked to may not yet be restored. */ if (acl(jcr->last_fname, SETACL, n, acls) == -1 && jcr->last_type != FT_LNK) { + berrno be; + switch (errno) { case ENOENT: actuallyfree(acls); @@ -2088,7 +2126,6 @@ bacl_exit_code parse_acl_streams(JCR *jcr, uint32_t content_length) { int ret; - berrno be; struct stat st; unsigned int cnt; @@ -2100,7 +2137,9 @@ bacl_exit_code parse_acl_streams(JCR *jcr, */ ret = lstat(jcr->last_fname, &st); switch (ret) { - case -1: + case -1: { + berrno be; + switch (errno) { case ENOENT: return bacl_exit_ok; @@ -2113,6 +2152,7 @@ bacl_exit_code parse_acl_streams(JCR *jcr, return bacl_exit_error; } break; + } case 0: break; } diff --git a/bacula/src/filed/fd_plugins.c b/bacula/src/filed/fd_plugins.c index 7ea9930..f09d9ad 100644 --- a/bacula/src/filed/fd_plugins.c +++ b/bacula/src/filed/fd_plugins.c @@ -159,7 +159,7 @@ void generate_plugin_event(JCR *jcr, bEventType eventType, void *value) bpContext *plugin_ctx; bEvent event; Plugin *plugin; - int i = 0; + int i; char *name = NULL; int len = 0; bool call_if_canceled = false; @@ -198,7 +198,7 @@ void generate_plugin_event(JCR *jcr, bEventType eventType, void *value) call_if_canceled = true; break; case bEventStartRestoreJob: - foreach_alist(plugin, bplugin_list) { + foreach_alist_index(i, plugin, bplugin_list) { plugin->restoreFileStarted = false; plugin->createFileCalled = false; } @@ -230,12 +230,11 @@ void generate_plugin_event(JCR *jcr, bEventType eventType, void *value) * Pass event to every plugin (except if name is set). If name * is set, we pass it only to the plugin with that name. */ - foreach_alist(plugin, bplugin_list) { + foreach_alist_index(i, plugin, bplugin_list) { if (name && !for_this_plug(plugin, name, len)) { - i++; continue; } - plugin_ctx = &plugin_ctx_list[i++]; + plugin_ctx = &plugin_ctx_list[i]; if (is_plugin_disabled(plugin_ctx)) { continue; } @@ -251,7 +250,7 @@ bool plugin_check_file(JCR *jcr, char *fname) { Plugin *plugin; int rc = bRC_OK; - int i = 0; + int i; if (!bplugin_list || !jcr || !jcr->plugin_ctx_list || jcr->is_job_canceled()) { return false; /* Return if no plugins loaded */ @@ -262,8 +261,8 @@ bool plugin_check_file(JCR *jcr, char *fname) Dmsg2(dbglvl, "plugin_ctx=%p JobId=%d\n", jcr->plugin_ctx_list, jcr->JobId); /* Pass event to every plugin */ - foreach_alist(plugin, bplugin_list) { - jcr->plugin_ctx = &plugin_ctx_list[i++]; + foreach_alist_index(i, plugin, bplugin_list) { + jcr->plugin_ctx = &plugin_ctx_list[i]; jcr->plugin = plugin; if (is_plugin_disabled(jcr)) { continue; @@ -371,10 +370,9 @@ bRC plugin_option_handle_file(JCR *jcr, FF_PKT *ff_pkt, struct save_pkt *sp) } /* Note, we stop the loop on the first plugin that matches the name */ - foreach_alist(plugin, bplugin_list) { + foreach_alist_index(i, plugin, bplugin_list) { Dmsg4(dbglvl, "plugin=%s plen=%d cmd=%s len=%d\n", plugin->file, plugin->file_len, cmd, len); if (!for_this_plug(plugin, cmd, len)) { - i++; continue; } @@ -390,7 +388,7 @@ bRC plugin_option_handle_file(JCR *jcr, FF_PKT *ff_pkt, struct save_pkt *sp) jcr->opt_plugin = true; jcr->plugin = plugin; jcr->plugin_sp = sp; /* Unset sp in save_file */ - jcr->plugin_ctx = &plugin_ctx_list[i++]; + jcr->plugin_ctx = &plugin_ctx_list[i]; update_ff_pkt(ff_pkt, sp); } @@ -419,7 +417,7 @@ bail_out: int plugin_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level) { Plugin *plugin; - int i = 0; + int i; int len; char *cmd = ff_pkt->top_fname; struct save_pkt sp; @@ -441,10 +439,9 @@ int plugin_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level) } /* Note, we stop the loop on the first plugin that matches the name */ - foreach_alist(plugin, bplugin_list) { + foreach_alist_index(i, plugin, bplugin_list) { Dmsg4(dbglvl, "plugin=%s plen=%d cmd=%s len=%d\n", plugin->file, plugin->file_len, cmd, len); if (!for_this_plug(plugin, cmd, len)) { - i++; continue; } /* @@ -557,8 +554,8 @@ bail_out: int plugin_estimate(JCR *jcr, FF_PKT *ff_pkt, bool top_level) { Plugin *plugin; - int i = 0; int len; + int i; char *cmd = ff_pkt->top_fname; struct save_pkt sp; bEvent event; @@ -580,10 +577,9 @@ int plugin_estimate(JCR *jcr, FF_PKT *ff_pkt, bool top_level) } /* Note, we stop the loop on the first plugin that matches the name */ - foreach_alist(plugin, bplugin_list) { + foreach_alist_index(i, plugin, bplugin_list) { Dmsg4(dbglvl, "plugin=%s plen=%d cmd=%s len=%d\n", plugin->file, plugin->file_len, cmd, len); if (!for_this_plug(plugin, cmd, len)) { - i++; continue; } /* @@ -731,7 +727,7 @@ bool plugin_name_stream(JCR *jcr, char *name) bool start; Plugin *plugin; int len; - int i = 0; + int i; bpContext *plugin_ctx_list = jcr->plugin_ctx_list; Dmsg1(dbglvl, "Read plugin stream string=%s\n", name); @@ -776,11 +772,10 @@ bool plugin_name_stream(JCR *jcr, char *name) /* * Search for correct plugin as specified on the command */ - foreach_alist(plugin, bplugin_list) { + foreach_alist_index(i, plugin, bplugin_list) { bEvent event; Dmsg3(dbglvl, "plugin=%s cmd=%s len=%d\n", plugin->file, cmd, len); if (!for_this_plug(plugin, cmd, len)) { - i++; continue; } jcr->plugin_ctx = &plugin_ctx_list[i]; @@ -941,6 +936,7 @@ void dump_fd_plugin(Plugin *plugin, FILE *fp) void load_fd_plugins(const char *plugin_dir) { Plugin *plugin; + int i; if (!plugin_dir) { Dmsg0(dbglvl, "plugin dir is NULL\n"); @@ -970,7 +966,7 @@ void load_fd_plugins(const char *plugin_dir) * Verify that the plugin is acceptable, and print information * about it. */ - foreach_alist(plugin, bplugin_list) { + foreach_alist_index(i, plugin, bplugin_list) { Jmsg(NULL, M_INFO, 0, _("Loaded plugin: %s\n"), plugin->file); Dmsg1(dbglvl, "Loaded plugin: %s\n", plugin->file); } @@ -1031,7 +1027,7 @@ static bool is_plugin_compatible(Plugin *plugin) void new_plugins(JCR *jcr) { Plugin *plugin; - int i = 0; + int i; if (!bplugin_list) { Dmsg0(dbglvl, "plugin list is NULL\n"); @@ -1052,14 +1048,14 @@ void new_plugins(JCR *jcr) bpContext *plugin_ctx_list = (bpContext *)jcr->plugin_ctx_list; Dmsg2(dbglvl, "Instantiate plugin_ctx=%p JobId=%d\n", plugin_ctx_list, jcr->JobId); - foreach_alist(plugin, bplugin_list) { + foreach_alist_index(i, plugin, bplugin_list) { /* Start a new instance of each plugin */ bacula_ctx *b_ctx = (bacula_ctx *)malloc(sizeof(bacula_ctx)); memset(b_ctx, 0, sizeof(bacula_ctx)); b_ctx->jcr = jcr; plugin_ctx_list[i].bContext = (void *)b_ctx; /* Bacula private context */ plugin_ctx_list[i].pContext = NULL; - if (plug_func(plugin)->newPlugin(&plugin_ctx_list[i++]) != bRC_OK) { + if (plug_func(plugin)->newPlugin(&plugin_ctx_list[i]) != bRC_OK) { b_ctx->disabled = true; } } @@ -1071,7 +1067,7 @@ void new_plugins(JCR *jcr) void free_plugins(JCR *jcr) { Plugin *plugin; - int i = 0; + int i; if (!bplugin_list || !jcr->plugin_ctx_list) { return; /* no plugins, nothing to do */ @@ -1079,10 +1075,10 @@ void free_plugins(JCR *jcr) bpContext *plugin_ctx_list = (bpContext *)jcr->plugin_ctx_list; Dmsg2(dbglvl, "Free instance plugin_ctx=%p JobId=%d\n", plugin_ctx_list, jcr->JobId); - foreach_alist(plugin, bplugin_list) { + foreach_alist_index(i, plugin, bplugin_list) { /* Free the plugin instance */ plug_func(plugin)->freePlugin(&plugin_ctx_list[i]); - free(plugin_ctx_list[i++].bContext); /* free Bacula private context */ + free(plugin_ctx_list[i].bContext); /* free Bacula private context */ } free(plugin_ctx_list); jcr->plugin_ctx_list = NULL; diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c index 3833c50..fc22b37 100644 --- a/bacula/src/filed/restore.c +++ b/bacula/src/filed/restore.c @@ -1070,7 +1070,7 @@ ok_out: Jmsg(jcr, M_INFO, 0, _("%d non-supported resource fork streams ignored.\n"), non_support_rsrc); } if (non_support_finfo) { - Jmsg(jcr, M_INFO, 0, _("%d non-supported Finder Info streams ignored.\n"), non_support_rsrc); + Jmsg(jcr, M_INFO, 0, _("%d non-supported Finder Info streams ignored.\n"), non_support_finfo); } if (non_support_acl) { Jmsg(jcr, M_INFO, 0, _("%d non-supported acl streams ignored.\n"), non_support_acl); diff --git a/bacula/src/filed/xattr.c b/bacula/src/filed/xattr.c index 38ea0a1..40a5127 100644 --- a/bacula/src/filed/xattr.c +++ b/bacula/src/filed/xattr.c @@ -350,14 +350,15 @@ static bxattr_exit_code aix_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) xattr_t *current_xattr = NULL; alist *xattr_value_list = NULL; bxattr_exit_code retval = bxattr_exit_error; - berrno be; /* * First get the length of the available list with extended attributes. */ xattr_list_len = llistea(jcr->last_fname, NULL, 0); switch (xattr_list_len) { - case -1: + case -1: { + berrno be; + switch (errno) { case ENOENT: case EFORMAT: @@ -380,6 +381,7 @@ static bxattr_exit_code aix_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) return bxattr_exit_error; } break; + } case 0: return bxattr_exit_ok; default: @@ -397,7 +399,9 @@ static bxattr_exit_code aix_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) */ xattr_list_len = llistea(jcr->last_fname, xattr_list, xattr_list_len); switch (xattr_list_len) { - case -1: + case -1: { + berrno be; + switch (errno) { case ENOENT: case EFORMAT: @@ -412,6 +416,7 @@ static bxattr_exit_code aix_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) goto bail_out; } break; + } default: break; } @@ -461,7 +466,9 @@ static bxattr_exit_code aix_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) */ xattr_value_len = lgetea(jcr->last_fname, bp, NULL, 0); switch (xattr_value_len) { - case -1: + case -1: { + berrno be; + switch (errno) { case ENOENT: case EFORMAT: @@ -476,6 +483,7 @@ static bxattr_exit_code aix_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) goto bail_out; } break; + } case 0: current_xattr->value = NULL; current_xattr->value_length = 0; @@ -490,6 +498,8 @@ static bxattr_exit_code aix_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) xattr_value_len = lgetea(jcr->last_fname, bp, current_xattr->value, xattr_value_len); if (xattr_value_len < 0) { + berrno be; + switch (errno) { case ENOENT: case EFORMAT: @@ -588,7 +598,6 @@ static bxattr_exit_code aix_parse_xattr_streams(JCR *jcr, { xattr_t *current_xattr; alist *xattr_value_list; - berrno be; xattr_value_list = New(alist(10, not_owned_by_alist)); @@ -605,6 +614,8 @@ static bxattr_exit_code aix_parse_xattr_streams(JCR *jcr, current_xattr->name, current_xattr->value, current_xattr->value_length, 0) != 0) { + berrno be; + switch (errno) { case ENOENT: case EFORMAT: @@ -694,13 +705,14 @@ static bxattr_exit_code irix_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) uint32_t expected_serialize_len = 0; bxattr_exit_code retval = bxattr_exit_error; POOLMEM *xattrbuf = get_memory(ATTR_MAX_VALUELEN); - berrno be; for (cnt = 0; xattr_naming_spaces[cnt].name != NULL; cnt++) { memset(&cursor, 0, sizeof(attrlist_cursor_t)); while (1) { if (attr_list(jcr->last_fname, xattrbuf, ATTR_MAX_VALUELEN, xattr_naming_spaces[cnt].flags, &cursor) != 0) { + berrno be; + switch (errno) { case ENOENT: retval = bxattr_exit_ok; @@ -751,6 +763,8 @@ static bxattr_exit_code irix_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) */ if (attr_get(jcr->last_fname, attrlist_ent->a_name, current_xattr->value, &length, xattr_naming_spaces[cnt].flags) != 0) { + berrno be; + switch (errno) { case ENOENT: case ENOATTR: @@ -775,7 +789,7 @@ static bxattr_exit_code irix_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) default: Mmsg2(jcr->errmsg, _("attr_list error on file \"%s\": ERR=%s\n"), - jcr->last_fname, be.bstrerror()); + jcr->last_fname, be.bstrerror(errno)); Dmsg2(100, "attr_list error file=%s ERR=%s\n", jcr->last_fname, be.bstrerror()); goto bail_out; @@ -881,7 +895,6 @@ static bxattr_exit_code irix_parse_xattr_streams(JCR *jcr, xattr_t *current_xattr; alist *xattr_value_list; bxattr_exit_code retval = bxattr_exit_error; - berrno be; xattr_value_list = New(alist(10, not_owned_by_alist)); @@ -927,6 +940,8 @@ static bxattr_exit_code irix_parse_xattr_streams(JCR *jcr, bp = strchr(current_xattr->name, '.'); if (attr_set(jcr->last_fname, ++bp, current_xattr->value, current_xattr->value_length, flags) != 0) { + berrno be; + switch (errno) { case ENOENT: retval = bxattr_exit_ok; @@ -945,7 +960,7 @@ static bxattr_exit_code irix_parse_xattr_streams(JCR *jcr, default: Mmsg2(jcr->errmsg, _("attr_set error on file \"%s\": ERR=%s\n"), - jcr->last_fname, be.bstrerror()); + jcr->last_fname, be.bstrerror(errno)); Dmsg2(100, "attr_set error file=%s ERR=%s\n", jcr->last_fname, be.bstrerror()); goto bail_out; @@ -1066,14 +1081,15 @@ static bxattr_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) xattr_t *current_xattr = NULL; alist *xattr_value_list = NULL; bxattr_exit_code retval = bxattr_exit_error; - berrno be; /* * First get the length of the available list with extended attributes. */ xattr_list_len = llistxattr(jcr->last_fname, NULL, 0); switch (xattr_list_len) { - case -1: + case -1: { + berrno be; + switch (errno) { case ENOENT: return bxattr_exit_ok; @@ -1096,6 +1112,7 @@ static bxattr_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) return bxattr_exit_error; } break; + } case 0: return bxattr_exit_ok; default: @@ -1113,7 +1130,9 @@ static bxattr_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) */ xattr_list_len = llistxattr(jcr->last_fname, xattr_list, xattr_list_len); switch (xattr_list_len) { - case -1: + case -1: { + berrno be; + switch (errno) { case ENOENT: retval = bxattr_exit_ok; @@ -1127,6 +1146,7 @@ static bxattr_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) goto bail_out; } break; + } default: break; } @@ -1194,7 +1214,9 @@ static bxattr_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) */ xattr_value_len = lgetxattr(jcr->last_fname, bp, NULL, 0); switch (xattr_value_len) { - case -1: + case -1: { + berrno be; + switch (errno) { case ENOENT: retval = bxattr_exit_ok; @@ -1208,6 +1230,7 @@ static bxattr_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) goto bail_out; } break; + } case 0: current_xattr->value = NULL; current_xattr->value_length = 0; @@ -1222,6 +1245,8 @@ static bxattr_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) xattr_value_len = lgetxattr(jcr->last_fname, bp, current_xattr->value, xattr_value_len); if (xattr_value_len < 0) { + berrno be; + switch (errno) { case ENOENT: retval = bxattr_exit_ok; @@ -1318,7 +1343,6 @@ static bxattr_exit_code generic_parse_xattr_streams(JCR *jcr, { xattr_t *current_xattr; alist *xattr_value_list; - berrno be; xattr_value_list = New(alist(10, not_owned_by_alist)); @@ -1332,6 +1356,8 @@ static bxattr_exit_code generic_parse_xattr_streams(JCR *jcr, foreach_alist(current_xattr, xattr_value_list) { if (lsetxattr(jcr->last_fname, current_xattr->name, current_xattr->value, current_xattr->value_length, 0) != 0) { + berrno be; + switch (errno) { case ENOENT: goto bail_out; @@ -1468,7 +1494,6 @@ static bxattr_exit_code bsd_build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) xattr_t *current_xattr = NULL; alist *xattr_value_list = NULL; bxattr_exit_code retval = bxattr_exit_error; - berrno be; /* * Loop over all available xattr namespaces. @@ -1487,7 +1512,9 @@ static bxattr_exit_code bsd_build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) */ xattr_list_len = extattr_list_link(jcr->last_fname, attrnamespace, NULL, 0); switch (xattr_list_len) { - case -1: + case -1: { + berrno be; + switch (errno) { case ENOENT: retval = bxattr_exit_ok; @@ -1511,6 +1538,7 @@ static bxattr_exit_code bsd_build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) goto bail_out; } break; + } case 0: continue; default: @@ -1529,7 +1557,9 @@ static bxattr_exit_code bsd_build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) xattr_list_len = extattr_list_link(jcr->last_fname, attrnamespace, xattr_list, xattr_list_len); switch (xattr_list_len) { - case -1: + case -1: { + berrno be; + switch (errno) { case ENOENT: retval = bxattr_exit_ok; @@ -1543,6 +1573,7 @@ static bxattr_exit_code bsd_build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) goto bail_out; } break; + } default: break; } @@ -1643,7 +1674,9 @@ static bxattr_exit_code bsd_build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) xattr_value_len = extattr_get_link(jcr->last_fname, attrnamespace, current_attrname, NULL, 0); switch (xattr_value_len) { - case -1: + case -1: { + berrno be; + switch (errno) { case ENOENT: retval = bxattr_exit_ok; @@ -1657,6 +1690,7 @@ static bxattr_exit_code bsd_build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) goto bail_out; } break; + } case 0: current_xattr->value = NULL; current_xattr->value_length = 0; @@ -1673,6 +1707,8 @@ static bxattr_exit_code bsd_build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) current_attrname, current_xattr->value, xattr_value_len); if (xattr_value_len < 0) { + berrno be; + switch (errno) { case ENOENT: retval = bxattr_exit_ok; @@ -1786,7 +1822,6 @@ static bxattr_exit_code bsd_parse_xattr_streams(JCR *jcr, alist *xattr_value_list; int current_attrnamespace, cnt; char *attrnamespace, *attrname; - berrno be; xattr_value_list = New(alist(10, not_owned_by_alist)); @@ -1832,6 +1867,8 @@ static bxattr_exit_code bsd_parse_xattr_streams(JCR *jcr, cnt = extattr_set_link(jcr->last_fname, current_attrnamespace, attrname, current_xattr->value, current_xattr->value_length); if (cnt < 0 || cnt != (int)current_xattr->value_length) { + berrno be; + switch (errno) { case ENOENT: goto bail_out; @@ -1914,7 +1951,6 @@ static bxattr_exit_code tru64_build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) struct proplistname_args prop_args; bxattr_exit_code retval = bxattr_exit_error; POOLMEM *xattrbuf = get_pool_memory(PM_MESSAGE); - berrno be; xattrbuf_size = sizeof_pool_memory(xattrbuf); xattrbuf_min_size = 0; @@ -1925,7 +1961,9 @@ static bxattr_exit_code tru64_build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) * See what xattr are available. */ switch (xattr_list_len) { - case -1: + case -1: { + berrno be; + switch (errno) { case EOPNOTSUPP: /* @@ -1947,6 +1985,7 @@ static bxattr_exit_code tru64_build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) goto bail_out; } break; + } case 0: if (xattrbuf_min_size) { /* @@ -1958,7 +1997,9 @@ static bxattr_exit_code tru64_build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) xattr_list_len = getproplist(jcr->last_fname, 1, &prop_args, xattrbuf_size, xattrbuf, &xattrbuf_min_size); switch (xattr_list_len) { - case -1: + case -1: { + berrno be; + switch (errno) { default: Mmsg2(jcr->errmsg, @@ -1969,6 +2010,7 @@ static bxattr_exit_code tru64_build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) goto bail_out; } break; + } case 0: /* * This should never happen as we sized the buffer according to the minimumsize @@ -2129,7 +2171,6 @@ static bxattr_exit_code tru64_parse_xattr_streams(JCR *jcr, xattr_t *current_xattr; alist *xattr_value_list; bxattr_exit_code retval = bxattr_exit_error; - berrno be; xattr_value_list = New(alist(10, not_owned_by_alist)); @@ -2178,7 +2219,9 @@ static bxattr_exit_code tru64_parse_xattr_streams(JCR *jcr, */ cnt = setproplist(jcr->last_fname, 1, xattrbuf_size, xattrbuf); switch (cnt) { - case -1: + case -1: { + berrno be; + switch (errno) { case EOPNOTSUPP: /* @@ -2200,6 +2243,7 @@ static bxattr_exit_code tru64_parse_xattr_streams(JCR *jcr, goto bail_out; } break; + } default: break; } @@ -2476,7 +2520,6 @@ static bxattr_exit_code solaris_save_xattr_acl(JCR *jcr, int fd, const char *att #ifdef HAVE_EXTENDED_ACL int flags; acl_t *aclp = NULL; - berrno be; /* * See if this attribute has an ACL @@ -2488,6 +2531,8 @@ static bxattr_exit_code solaris_save_xattr_acl(JCR *jcr, int fd, const char *att */ if ((fd != -1 && facl_get(fd, ACL_NO_TRIVIAL, &aclp) != 0) || acl_get(attrname, ACL_NO_TRIVIAL, &aclp) != 0) { + berrno be; + switch (errno) { case ENOENT: return bxattr_exit_ok; @@ -2523,7 +2568,6 @@ static bxattr_exit_code solaris_save_xattr_acl(JCR *jcr, int fd, const char *att #else /* HAVE_EXTENDED_ACL */ int n; aclent_t *acls = NULL; - berrno be; /* * See if this attribute has an ACL @@ -2538,6 +2582,8 @@ static bxattr_exit_code solaris_save_xattr_acl(JCR *jcr, int fd, const char *att acls = (aclent_t *)malloc(n * sizeof(aclent_t)); if ((fd != -1 && facl(fd, GETACL, n, acls) != n) || acl(attrname, GETACL, n, acls) != n) { + berrno be; + switch (errno) { case ENOENT: free(acls); @@ -2558,6 +2604,8 @@ static bxattr_exit_code solaris_save_xattr_acl(JCR *jcr, int fd, const char *att */ if (!acl_is_trivial(n, acls)) { if ((*acl_text = acltotext(acls, n)) == NULL) { + berrno be; + Mmsg3(jcr->errmsg, _("Unable to get acl text on xattr %s on file \"%s\": ERR=%s\n"), attrname, jcr->last_fname, be.bstrerror()); @@ -2615,7 +2663,6 @@ static bxattr_exit_code solaris_save_xattr(JCR *jcr, int fd, const char *xattr_n char attribs[MAXSTRING]; char buffer[XATTR_BUFSIZ]; bxattr_exit_code retval = bxattr_exit_error; - berrno be; bsnprintf(target_attrname, sizeof(target_attrname), "%s%s", xattr_namespace, attrname); @@ -2623,6 +2670,8 @@ static bxattr_exit_code solaris_save_xattr(JCR *jcr, int fd, const char *xattr_n * Get the stats of the extended or extensible attribute. */ if (fstatat(fd, attrname, &st, AT_SYMLINK_NOFOLLOW) < 0) { + berrno be; + switch (errno) { case ENOENT: retval = bxattr_exit_ok; @@ -2754,6 +2803,8 @@ static bxattr_exit_code solaris_save_xattr(JCR *jcr, int fd, const char *xattr_n * Open the extended or extensible attribute file. */ if ((attrfd = openat(fd, attrname, O_RDONLY)) < 0) { + berrno be; + switch (errno) { case ENOENT: retval = bxattr_exit_ok; @@ -2775,6 +2826,8 @@ static bxattr_exit_code solaris_save_xattr(JCR *jcr, int fd, const char *xattr_n * Encode the stat struct into an ASCII representation. */ if (readlink(attrname, link_source, sizeof(link_source)) < 0) { + berrno be; + switch (errno) { case ENOENT: retval = bxattr_exit_ok; @@ -2888,6 +2941,8 @@ static bxattr_exit_code solaris_save_xattr(JCR *jcr, int fd, const char *xattr_n * The recursive call could change our working dir so change back to the wanted workdir. */ if (fchdir(fd) < 0) { + berrno be; + switch (errno) { case ENOENT: retval = bxattr_exit_ok; @@ -2920,7 +2975,6 @@ static bxattr_exit_code solaris_save_xattrs(JCR *jcr, const char *xattr_namespac struct dirent *dp; char current_xattr_namespace[PATH_MAX]; bxattr_exit_code retval = bxattr_exit_error; - berrno be; /* * Determine what argument to use. Use attr_parent when set @@ -2944,6 +2998,8 @@ static bxattr_exit_code solaris_save_xattrs(JCR *jcr, const char *xattr_namespac * Open the file on which to save the xattrs read-only. */ if ((filefd = open(name, O_RDONLY | O_NONBLOCK)) < 0) { + berrno be; + switch (errno) { case ENOENT: retval = bxattr_exit_ok; @@ -2962,6 +3018,8 @@ static bxattr_exit_code solaris_save_xattrs(JCR *jcr, const char *xattr_namespac * Open the xattr naming space. */ if ((attrdirfd = openat(filefd, ".", O_RDONLY | O_XATTR)) < 0) { + berrno be; + switch (errno) { case EINVAL: /* @@ -2989,6 +3047,8 @@ static bxattr_exit_code solaris_save_xattrs(JCR *jcr, const char *xattr_namespac * attributes should be saved. */ if (fchdir(attrdirfd) < 0) { + berrno be; + Mmsg2(jcr->errmsg, _("Unable to chdir to xattr space on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); @@ -3008,6 +3068,8 @@ static bxattr_exit_code solaris_save_xattrs(JCR *jcr, const char *xattr_namespac if ((fd = dup(attrdirfd)) == -1 || (dirp = fdopendir(fd)) == (DIR *)NULL) { + berrno be; + Mmsg2(jcr->errmsg, _("Unable to list the xattr space on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); @@ -3098,7 +3160,6 @@ static bxattr_exit_code solaris_restore_xattr_acl(JCR *jcr, #ifdef HAVE_EXTENDED_ACL int error; acl_t *aclp = NULL; - berrno be; if ((error = acl_fromtext(acl_text, &aclp)) != 0) { Mmsg1(jcr->errmsg, @@ -3109,6 +3170,8 @@ static bxattr_exit_code solaris_restore_xattr_acl(JCR *jcr, if ((fd != -1 && facl_set(fd, aclp) != 0) || acl_set(attrname, aclp) != 0) { + berrno be; + Mmsg3(jcr->errmsg, _("Unable to restore acl of xattr %s on file \"%s\": ERR=%s\n"), attrname, jcr->last_fname, be.bstrerror()); @@ -3125,12 +3188,13 @@ static bxattr_exit_code solaris_restore_xattr_acl(JCR *jcr, #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; + Mmsg3(jcr->errmsg, _("Unable to restore acl of xattr %s on file \"%s\": ERR=%s\n"), attrname, jcr->last_fname, be.bstrerror()); @@ -3166,7 +3230,6 @@ static bxattr_exit_code solaris_restore_xattrs(JCR *jcr, struct stat st; struct timeval times[2]; bxattr_exit_code retval = bxattr_exit_error; - berrno be; /* * Parse the xattr stream. First the part that is the same for all xattrs. @@ -3189,6 +3252,8 @@ static bxattr_exit_code solaris_restore_xattrs(JCR *jcr, * Open the file on which to restore the xattrs read-only. */ if ((filefd = open(jcr->last_fname, O_RDONLY | O_NONBLOCK)) < 0) { + berrno be; + Mmsg2(jcr->errmsg, _("Unable to open file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); @@ -3201,6 +3266,8 @@ static bxattr_exit_code solaris_restore_xattrs(JCR *jcr, * Open the xattr naming space and make it the current working dir. */ if ((attrdirfd = openat(filefd, ".", O_RDONLY | O_XATTR)) < 0) { + berrno be; + Mmsg2(jcr->errmsg, _("Unable to open xattr space on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); @@ -3210,6 +3277,8 @@ static bxattr_exit_code solaris_restore_xattrs(JCR *jcr, } if (fchdir(attrdirfd) < 0) { + berrno be; + Mmsg2(jcr->errmsg, _("Unable to chdir to xattr space on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); @@ -3227,6 +3296,8 @@ static bxattr_exit_code solaris_restore_xattrs(JCR *jcr, *bp = '\0'; if ((fd = open(target_attrname, O_RDONLY | O_NONBLOCK)) < 0) { + berrno be; + Mmsg3(jcr->errmsg, _("Unable to open xattr %s on file \"%s\": ERR=%s\n"), target_attrname, jcr->last_fname, be.bstrerror()); @@ -3242,6 +3313,8 @@ static bxattr_exit_code solaris_restore_xattrs(JCR *jcr, * Open the xattr naming space. */ if ((fd = openat(filefd, ".", O_RDONLY | O_XATTR)) < 0) { + berrno be; + Mmsg3(jcr->errmsg, _("Unable to open xattr space %s on file \"%s\": ERR=%s\n"), target_attrname, jcr->last_fname, be.bstrerror()); @@ -3257,6 +3330,8 @@ static bxattr_exit_code solaris_restore_xattrs(JCR *jcr, * Make the xattr space our current workingdir. */ if (fchdir(attrdirfd) < 0) { + berrno be; + Mmsg3(jcr->errmsg, _("Unable to chdir to xattr space %s on file \"%s\": ERR=%s\n"), target_attrname, jcr->last_fname, be.bstrerror()); @@ -3295,6 +3370,8 @@ static bxattr_exit_code solaris_restore_xattrs(JCR *jcr, */ unlinkat(attrdirfd, target_attrname, 0); if (mkfifo(target_attrname, st.st_mode) < 0) { + berrno be; + Mmsg3(jcr->errmsg, _("Unable to mkfifo xattr %s on file \"%s\": ERR=%s\n"), target_attrname, jcr->last_fname, be.bstrerror()); @@ -3311,6 +3388,8 @@ static bxattr_exit_code solaris_restore_xattrs(JCR *jcr, */ unlinkat(attrdirfd, target_attrname, 0); if (mknod(target_attrname, st.st_mode, st.st_rdev) < 0) { + berrno be; + Mmsg3(jcr->errmsg, _("Unable to mknod xattr %s on file \"%s\": ERR=%s\n"), target_attrname, jcr->last_fname, be.bstrerror()); @@ -3328,6 +3407,8 @@ static bxattr_exit_code solaris_restore_xattrs(JCR *jcr, if (!bstrcmp(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", @@ -3345,6 +3426,8 @@ static bxattr_exit_code solaris_restore_xattrs(JCR *jcr, unlinkat(attrdirfd, target_attrname, 0); if (link(linked_target, target_attrname) < 0) { + berrno be; + Mmsg4(jcr->errmsg, _("Unable to link xattr %s to %s on file \"%s\": ERR=%s\n"), target_attrname, linked_target, jcr->last_fname, be.bstrerror()); @@ -3375,6 +3458,8 @@ static bxattr_exit_code solaris_restore_xattrs(JCR *jcr, } if ((attrfd = openat(attrdirfd, target_attrname, O_RDWR | O_CREAT | O_TRUNC, st.st_mode)) < 0) { + berrno be; + Mmsg3(jcr->errmsg, _("Unable to open xattr %s on file \"%s\": ERR=%s\n"), target_attrname, jcr->last_fname, be.bstrerror()); @@ -3407,6 +3492,8 @@ static bxattr_exit_code solaris_restore_xattrs(JCR *jcr, while (cnt > 0) { cnt = write(attrfd, data, cnt); if (cnt < 0) { + berrno be; + Mmsg3(jcr->errmsg, _("Unable to restore data of xattr %s on file \"%s\": ERR=%s\n"), target_attrname, jcr->last_fname, be.bstrerror()); @@ -3428,6 +3515,8 @@ static bxattr_exit_code solaris_restore_xattrs(JCR *jcr, linked_target = bp; if (symlink(linked_target, target_attrname) < 0) { + berrno be; + Mmsg4(jcr->errmsg, _("Unable to symlink xattr %s to %s on file \"%s\": ERR=%s\n"), target_attrname, linked_target, jcr->last_fname, be.bstrerror()); @@ -3450,6 +3539,8 @@ static bxattr_exit_code solaris_restore_xattrs(JCR *jcr, */ if (!is_extensible) { if (fchownat(attrdirfd, target_attrname, st.st_uid, st.st_gid, AT_SYMLINK_NOFOLLOW) < 0) { + berrno be; + switch (errno) { case EINVAL: /* @@ -3488,6 +3579,8 @@ static bxattr_exit_code solaris_restore_xattrs(JCR *jcr, times[1].tv_usec = 0; if (futimesat(attrdirfd, target_attrname, times) < 0) { + berrno be; + Mmsg3(jcr->errmsg, _("Unable to restore filetimes of xattr %s on file \"%s\": ERR=%s\n"), target_attrname, jcr->last_fname, be.bstrerror()); @@ -3651,7 +3744,6 @@ bxattr_exit_code parse_xattr_streams(JCR *jcr, uint32_t content_length) { int ret; - berrno be; struct stat st; unsigned int cnt; @@ -3663,7 +3755,9 @@ bxattr_exit_code parse_xattr_streams(JCR *jcr, */ ret = lstat(jcr->last_fname, &st); switch (ret) { - case -1: + case -1: { + berrno be; + switch (errno) { case ENOENT: return bxattr_exit_ok; @@ -3676,6 +3770,7 @@ bxattr_exit_code parse_xattr_streams(JCR *jcr, return bxattr_exit_error; } break; + } case 0: break; } diff --git a/bacula/src/lib/alist.h b/bacula/src/lib/alist.h index 85698e9..d2f1d06 100644 --- a/bacula/src/lib/alist.h +++ b/bacula/src/lib/alist.h @@ -1,7 +1,7 @@ /* Bacula(R) - The Network Backup Solution - Copyright (C) 2003-2011 Free Software Foundation Europe e.V. + Copyright (C) 2003-2012 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -47,6 +47,15 @@ (*((void **)&(var))=(void*)((list)->next()))) #endif +#ifdef HAVE_TYPEOF +#define foreach_alist_index(inx, var, list) \ + for(inx=0; ((var)=(typeof(var))(list)->get(inx)); inx++ ) +#else +#define foreach_alist_index(inx, var, list) \ + for(inx=0; ((*((void **)&(var))=(void*)((list)->get(inx)))); inx++ ) +#endif + + /* Second arg of init */ @@ -81,6 +90,7 @@ public: void *first(); void *last(); void * operator [](int index) const; + int current() const { return cur_item; }; int size() const; void destroy(); void grow(int num); diff --git a/bacula/src/lib/plugins.c b/bacula/src/lib/plugins.c index 0b42f90..0cffff1 100644 --- a/bacula/src/lib/plugins.c +++ b/bacula/src/lib/plugins.c @@ -1,7 +1,7 @@ /* Bacula(R) - The Network Backup Solution - Copyright (C) 2007-2011 Free Software Foundation Europe e.V. + Copyright (C) 2007-2012 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -49,7 +49,12 @@ int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result); static const int dbglvl = 50; -/* All loaded plugins */ +/* + * List of all loaded plugins. + * + * NOTE!!! This is a global do not try walking it with + * foreach_alist, you must use foreach_alist_index !!!!!! + */ alist *bplugin_list = NULL; /* diff --git a/bacula/src/stored/autochanger.c b/bacula/src/stored/autochanger.c index 3d38739..67d1780 100644 --- a/bacula/src/stored/autochanger.c +++ b/bacula/src/stored/autochanger.c @@ -425,6 +425,7 @@ bool unload_autochanger(DCR *dcr, int loaded) static bool unload_other_drive(DCR *dcr, int slot) { DEVICE *dev = NULL; + DEVICE *dev_save; bool found = false; AUTOCHANGER *changer = dcr->dev->device->changer_res; DEVRES *device; @@ -437,16 +438,35 @@ static bool unload_other_drive(DCR *dcr, int slot) return true; } + /* + * We look for the slot number corresponding to the tape + * we want in other drives, and if possible, unload + * it. + */ + Dmsg0(100, "Wiffle through devices looking for slot\n"); foreach_alist(device, changer->device) { - if (device->dev && device->dev->get_slot() == slot) { + dev = device->dev; + if (!dev) { + continue; + } + dev_save = dcr->dev; + dcr->dev = dev; + if (dev->get_slot() <= 0 && get_autochanger_loaded_slot(dcr) <= 0) { + dcr->dev = dev_save; + continue; + } + dcr->dev = dev_save; + if (dev->get_slot() == slot) { found = true; - dev = device->dev; break; } } if (!found) { + Dmsg1(100, "Slot=%d not found in another device\n", slot); return true; - } + } else { + Dmsg1(100, "Slot=%d found in another device\n", slot); + } /* The Volume we want is on another device. */ if (dev->is_busy()) { diff --git a/bacula/src/stored/reserve.c b/bacula/src/stored/reserve.c index dfa081e..a40be16 100644 --- a/bacula/src/stored/reserve.c +++ b/bacula/src/stored/reserve.c @@ -235,6 +235,7 @@ static bool use_device_cmd(JCR *jcr) } } while (ok && dir->recv() >= 0); +#ifdef xxxx /* Developer debug code */ char *device_name; if (debug_level >= dbglvl) { @@ -247,6 +248,7 @@ static bool use_device_cmd(JCR *jcr) } } } +#endif init_jcr_device_wait_timers(jcr); jcr->dcr = new_dcr(jcr, NULL, NULL); /* get a dcr */ @@ -271,6 +273,12 @@ static bool use_device_cmd(JCR *jcr) bool fail = false; rctx.notify_dir = true; + /* Put new dcr in proper location */ + if (rctx.append) { + rctx.jcr->dcr = jcr->dcr; + } else { + rctx.jcr->read_dcr = jcr->dcr; + } lock_reservations(); for ( ; !fail && !job_canceled(jcr); ) { pop_reserve_messages(jcr); diff --git a/bacula/src/stored/sd_plugins.c b/bacula/src/stored/sd_plugins.c index 02ae630..8ea73af 100644 --- a/bacula/src/stored/sd_plugins.c +++ b/bacula/src/stored/sd_plugins.c @@ -104,13 +104,23 @@ int generate_plugin_event(JCR *jcr, bsdEventType eventType, void *value) bpContext *plugin_ctx; bsdEvent event; Plugin *plugin; - int i = 0; + int i; bRC rc = bRC_OK; - if (!bplugin_list || !jcr || !jcr->plugin_ctx_list) { + if (!bplugin_list) { + Dmsg0(dbglvl, "No bplugin_list: generate_plugin_event ignored.\n"); + return bRC_OK; + } + if (!jcr) { + Dmsg0(dbglvl, "No jcr: generate_plugin_event ignored.\n"); + return bRC_OK; + } + if (!jcr->plugin_ctx_list) { + Dmsg0(dbglvl, "No plugin_ctx_list: generate_plugin_event ignored.\n"); return bRC_OK; /* Return if no plugins loaded */ } if (jcr->is_job_canceled()) { + Dmsg0(dbglvl, "Cancel return from generate_plugin_event\n"); return bRC_Cancel; } @@ -119,8 +129,8 @@ int generate_plugin_event(JCR *jcr, bsdEventType eventType, void *value) Dmsg2(dbglvl, "sd-plugin_ctx_list=%p JobId=%d\n", jcr->plugin_ctx_list, jcr->JobId); - foreach_alist(plugin, bplugin_list) { - plugin_ctx = &plugin_ctx_list[i++]; + foreach_alist_index(i, plugin, bplugin_list) { + plugin_ctx = &plugin_ctx_list[i]; if (is_plugin_disabled(plugin_ctx)) { continue; } @@ -158,6 +168,7 @@ void dump_sd_plugin(Plugin *plugin, FILE *fp) void load_sd_plugins(const char *plugin_dir) { Plugin *plugin; + int i; Dmsg0(dbglvl, "Load sd plugins\n"); if (!plugin_dir) { @@ -179,7 +190,7 @@ void load_sd_plugins(const char *plugin_dir) * Verify that the plugin is acceptable, and print information * about it. */ - foreach_alist(plugin, bplugin_list) { +... [truncated message content] |