From: Marco van Wieringen Date: Fri, 16 Sep 2011 08:36:19 +0000 (+0200) Subject: The world is cruel, you cannot trust manpages. X-Git-Tag: Release-7.0.0~573 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=87005d3feb067bce65a624e58d0409227e165597;p=bacula%2Fbacula The world is cruel, you cannot trust manpages. As it seems ENOTSUP is defined as EOPNOTSUPP on Linux. The manpages says certain functions return ENOTSUP while they return EOPNOTSUPP because the other doesn't really exist. So we have to do some more magic, restored the old acl errno logic which is somewhat cleaner now that everything except for IRIX seems to not adhere to POSIX and use EOPNOTSUPP (which is according to POSIX only valid for a socket). Added same kind of logic to xattr code as on OSX the xattr functions are supposed to return ENOTSUP and not EOPNOTSUPP which Linux is returning there. What a mess trying to write portable code when manpages just cannot be trusted. Hopefully this is the end of it. --- diff --git a/bacula/src/filed/acl.c b/bacula/src/filed/acl.c index f80b2b53a5..ed2f5766fc 100644 --- a/bacula/src/filed/acl.c +++ b/bacula/src/filed/acl.c @@ -701,9 +701,8 @@ static bacl_exit_code generic_get_acl_from_os(JCR *jcr, bacl_type acltype) * Handle errors gracefully. */ switch (errno) { - case ENOSYS: - case ENOTSUP: - case EOPNOTSUPP: +#if defined(BACL_ENOTSUP) + case BACL_ENOTSUP: /** * If the filesystem reports it doesn't support ACLs we clear the * BACL_FLAG_SAVE_NATIVE flag so we skip ACL saves on all other files @@ -712,6 +711,7 @@ static bacl_exit_code generic_get_acl_from_os(JCR *jcr, bacl_type acltype) */ jcr->acl_data->flags &= ~BACL_FLAG_SAVE_NATIVE; goto bail_out; +#endif case ENOENT: goto bail_out; default: @@ -755,12 +755,12 @@ static bacl_exit_code generic_set_acl_on_os(JCR *jcr, bacl_type acltype) switch (errno) { case ENOENT: return bacl_exit_ok; - case ENOSYS: - case ENOTSUP: - case EOPNOTSUPP: +#if defined(BACL_ENOTSUP) + case BACL_ENOTSUP: Mmsg1(jcr->errmsg, _("acl_delete_def_file error on file \"%s\": filesystem doesn't support ACLs\n"), jcr->last_fname); return bacl_exit_ok; +#endif default: Mmsg2(jcr->errmsg, _("acl_delete_def_file error on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); @@ -803,15 +803,15 @@ static bacl_exit_code generic_set_acl_on_os(JCR *jcr, bacl_type acltype) case ENOENT: acl_free(acl); return bacl_exit_ok; - case ENOSYS: - case ENOTSUP: - case EOPNOTSUPP: +#if defined(BACL_ENOTSUP) + case BACL_ENOTSUP: Mmsg1(jcr->errmsg, _("acl_set_file error on file \"%s\": filesystem doesn't support ACLs\n"), jcr->last_fname); Dmsg2(100, "acl_set_file error acl=%s file=%s filesystem doesn't support ACLs\n", jcr->acl_data->content, jcr->last_fname); acl_free(acl); return bacl_exit_ok; +#endif default: Mmsg2(jcr->errmsg, _("acl_set_file error on file \"%s\": ERR=%s\n"), jcr->last_fname, be.bstrerror()); @@ -1262,9 +1262,8 @@ static bacl_exit_code hpux_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) if ((n = getacl(jcr->last_fname, 0, acls)) < 0) { switch (errno) { - case ENOSYS: - case ENOTSUP: - case EOPNOTSUPP: +#if defined(BACL_ENOTSUP) + case BACL_ENOTSUP: /** * Not supported, just pretend there is nothing to see * @@ -1277,6 +1276,7 @@ static bacl_exit_code hpux_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) pm_strcpy(jcr->acl_data->content, ""); jcr->acl_data->content_length = 0; return bacl_exit_ok; +#endif case ENOENT: pm_strcpy(jcr->acl_data->content, ""); jcr->acl_data->content_length = 0; diff --git a/bacula/src/filed/acl.h b/bacula/src/filed/acl.h index d8f1f09ef8..095cc615ce 100644 --- a/bacula/src/filed/acl.h +++ b/bacula/src/filed/acl.h @@ -58,6 +58,15 @@ typedef enum { #define ACL_TYPE_NONE 0x0 #endif +#if defined(HAVE_FREEBSD_OS) || \ + defined(HAVE_DARWIN_OS) || \ + defined(HAVE_HPUX_OS) || \ + defined(HAVE_LINUX_OS) +#define BACL_ENOTSUP EOPNOTSUPP +#elif defined(HAVE_IRIX_OS) +#define BACL_ENOTSUP ENOSYS +#endif + #define BACL_FLAG_SAVE_NATIVE 0x01 #define BACL_FLAG_SAVE_AFS 0x02 diff --git a/bacula/src/filed/xattr.c b/bacula/src/filed/xattr.c index 160674d81f..938f8c24c6 100644 --- a/bacula/src/filed/xattr.c +++ b/bacula/src/filed/xattr.c @@ -966,8 +966,7 @@ static bxattr_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) case -1: switch (errno) { case ENOENT: - case ENOTSUP: - case EOPNOTSUPP: + case BXATTR_ENOTSUP: return bxattr_exit_ok; default: Mmsg2(jcr->errmsg, _("llistxattr error on file \"%s\": ERR=%s\n"), @@ -997,8 +996,7 @@ static bxattr_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) case -1: switch (errno) { case ENOENT: - case ENOTSUP: - case EOPNOTSUPP: + case BXATTR_ENOTSUP: retval = bxattr_exit_ok; goto bail_out; default: @@ -1079,8 +1077,7 @@ static bxattr_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) case -1: switch (errno) { case ENOENT: - case ENOTSUP: - case EOPNOTSUPP: + case BXATTR_ENOTSUP: retval = bxattr_exit_ok; goto bail_out; default: @@ -1107,8 +1104,7 @@ static bxattr_exit_code generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt) if (xattr_value_len < 0) { switch (errno) { case ENOENT: - case ENOTSUP: - case EOPNOTSUPP: + case BXATTR_ENOTSUP: retval = bxattr_exit_ok; goto bail_out; default: @@ -1208,8 +1204,7 @@ static bxattr_exit_code generic_xattr_parse_streams(JCR *jcr, int stream) if (lsetxattr(jcr->last_fname, current_xattr->name, current_xattr->value, current_xattr->value_length, 0) != 0) { switch (errno) { case ENOENT: - case ENOTSUP: - case EOPNOTSUPP: + case BXATTR_ENOTSUP: goto bail_out; default: Mmsg2(jcr->errmsg, _("lsetxattr error on file \"%s\": ERR=%s\n"), diff --git a/bacula/src/filed/xattr.h b/bacula/src/filed/xattr.h index eaa4bf4fb4..1fe551818b 100644 --- a/bacula/src/filed/xattr.h +++ b/bacula/src/filed/xattr.h @@ -29,6 +29,12 @@ #ifndef __XATTR_H #define __XATTR_H +#if defined(HAVE_LINUX_OS) +#define BXATTR_ENOTSUP EOPNOTSUPP +#elif defined(HAVE_DARWIN_OS) +#define BXATTR_ENOTSUP ENOTSUP +#endif + /* * Magic used in the magic field of the xattr struct. * This way we can see we encounter a valid xattr struct.