]> git.sur5r.net Git - bacula/bacula/commitdiff
The world is cruel, you cannot trust manpages.
authorMarco van Wieringen <mvw@planets.elm.net>
Fri, 16 Sep 2011 08:36:19 +0000 (10:36 +0200)
committerMarco van Wieringen <mvw@planets.elm.net>
Fri, 16 Sep 2011 08:46:01 +0000 (10:46 +0200)
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.

bacula/src/filed/acl.c
bacula/src/filed/acl.h
bacula/src/filed/xattr.c
bacula/src/filed/xattr.h

index f80b2b53a57ecd3c8dd15acf76c7c92d4fbf7cc2..ed2f5766fc811ee4b24c768d026fce85b096c205 100644 (file)
@@ -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;
index d8f1f09ef8f39ecac814a4294873252588150a2a..095cc615ce9e14b39432955cc2c23a70a4a09ead 100644 (file)
@@ -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
 
index 160674d81fa31dfe4b5c93706caf42e9df4fa472..938f8c24c6ca86ac5f0be1f230012b27a328b7f7 100644 (file)
@@ -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"),
index eaa4bf4fb4fb9a5920d23aff136e7d992480c7ae..1fe551818bac4507f06a81a38af0ccabacfb8945 100644 (file)
 #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.