build: bundle and reduce huge number of EA function tests
authorBjörn Jacke <bjacke@samba.org>
Mon, 12 Mar 2018 17:44:38 +0000 (18:44 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 3 Jul 2018 11:24:51 +0000 (13:24 +0200)
It's sufficient to check for one basic function of an EA implementation and a
use a single ifdef for each group of EA functions. This makes more sense than
checking for each EA function on each platform.

Signed-off-by: Bjoern Jacke <bjacke@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Tue Jul  3 13:24:51 CEST 2018 on sn-devel-144

lib/replace/system/filesys.h
lib/replace/wscript
lib/replace/xattr.c

index bd6e6a0dd19887b2e08eb9b7b677228c91e4c95e..faa94c73f2662ef2ff939ae2d7c7ab2ccb5f38ff 100644 (file)
 #endif
 
 
-#if !defined(HAVE_GETXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
+#if !defined(HAVE_XATTR_XATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
+
 ssize_t rep_getxattr (const char *path, const char *name, void *value, size_t size);
 #define getxattr(path, name, value, size) rep_getxattr(path, name, value, size)
 /* define is in "replace.h" */
-#endif
-
-#if !defined(HAVE_FGETXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
 ssize_t rep_fgetxattr (int filedes, const char *name, void *value, size_t size);
 #define fgetxattr(filedes, name, value, size) rep_fgetxattr(filedes, name, value, size)
 /* define is in "replace.h" */
-#endif
-
-#if !defined(HAVE_LISTXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
 ssize_t rep_listxattr (const char *path, char *list, size_t size);
 #define listxattr(path, list, size) rep_listxattr(path, list, size)
 /* define is in "replace.h" */
-#endif
-
-#if !defined(HAVE_FLISTXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
 ssize_t rep_flistxattr (int filedes, char *list, size_t size);
 #define flistxattr(filedes, value, size) rep_flistxattr(filedes, value, size)
 /* define is in "replace.h" */
-#endif
-
-#if !defined(HAVE_REMOVEXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
 int rep_removexattr (const char *path, const char *name);
 #define removexattr(path, name) rep_removexattr(path, name)
 /* define is in "replace.h" */
-#endif
-
-#if !defined(HAVE_FREMOVEXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
 int rep_fremovexattr (int filedes, const char *name);
 #define fremovexattr(filedes, name) rep_fremovexattr(filedes, name)
 /* define is in "replace.h" */
-#endif
-
-#if !defined(HAVE_SETXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
 int rep_setxattr (const char *path, const char *name, const void *value, size_t size, int flags);
 #define setxattr(path, name, value, size, flags) rep_setxattr(path, name, value, size, flags)
 /* define is in "replace.h" */
-#endif
-
-#if !defined(HAVE_FSETXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
 int rep_fsetxattr (int filedes, const char *name, const void *value, size_t size, int flags);
 #define fsetxattr(filedes, name, value, size, flags) rep_fsetxattr(filedes, name, value, size, flags)
 /* define is in "replace.h" */
-#endif
+
+#endif /* !defined(HAVE_XATTR_XATTR) || defined(XATTR_ADDITIONAL_OPTIONS) */
 
 #endif
index 3df86b1b5bc1e0f2ff0d55c3cbdf7ed40a630dcf..66694f7d0af317224614a20449289333e4568d8d 100644 (file)
@@ -393,35 +393,24 @@ def configure(conf):
 
     xattr_headers='sys/attributes.h attr/xattr.h sys/xattr.h'
 
-    conf.CHECK_FUNCS_IN('''
-fgetxattr flistea flistxattr
-fremovexattr fsetxattr getxattr
-listxattr removexattr setxattr
-''', 'attr', checklibc=True, headers=xattr_headers)
-
-    # We need to check for linux xattrs first, as we do not wish to link to -lattr
-    # (the XFS compat API) on Linux systems with the native xattr API
-    if not conf.CONFIG_SET('HAVE_GETXATTR'):
-        conf.CHECK_FUNCS_IN('''
-attr_get attr_getf attr_list attr_listf attropen attr_remove
-attr_removef attr_set attr_setf extattr_delete_fd extattr_delete_file
-extattr_get_fd extattr_get_file extattr_list_fd extattr_list_file
-extattr_set_fd extattr_set_file fgetea
-fremoveea fsetea getea listea
-removeea setea
-''', 'attr', checklibc=True, headers=xattr_headers)
-
-    if (conf.CONFIG_SET('HAVE_ATTR_LISTF') or
-        conf.CONFIG_SET('HAVE_EXTATTR_LIST_FD') or
-        conf.CONFIG_SET('HAVE_FLISTEA') or
-        conf.CONFIG_SET('HAVE_FLISTXATTR')):
-            conf.DEFINE('HAVE_XATTR_SUPPORT', 1)
-
-    # Darwin has extra options to xattr-family functions
-    conf.CHECK_CODE('getxattr(NULL, NULL, NULL, 0, 0, 0)',
-                    headers=xattr_headers, local_include=False,
-                    define='XATTR_ADDITIONAL_OPTIONS',
-                    msg="Checking whether xattr interface takes additional options")
+    # default to 1, we set it to 0 if we don't find any EA implementation below:
+    conf.DEFINE('HAVE_XATTR_SUPPORT', 1)
+    if conf.CHECK_FUNCS_IN('getxattr', 'attr', checklibc=True, headers=xattr_headers):
+        conf.DEFINE('HAVE_XATTR_XATTR', 1)
+        # Darwin has extra options to xattr-family functions
+        conf.CHECK_CODE('getxattr(NULL, NULL, NULL, 0, 0, 0)',
+                        headers=xattr_headers, local_include=False,
+                        define='XATTR_ADDITIONAL_OPTIONS',
+                        msg="Checking whether xattr interface takes additional options")
+    elif conf.CHECK_FUNCS_IN('attr_listf', 'attr', checklibc=True, headers=xattr_headers):
+        conf.DEFINE('HAVE_XATTR_ATTR', 1)
+    elif conf.CHECK_FUNCS('extattr_list_fd'):
+        conf.DEFINE('HAVE_XATTR_EXTATTR', 1)
+    elif conf.CHECK_FUNCS('flistea'):
+        conf.DEFINE('HAVE_XATTR_EA', 1)
+    elif not conf.CHECK_FUNCS('attropen'):
+            conf.DEFINE('HAVE_XATTR_SUPPORT', 0)
+
 
     conf.CHECK_FUNCS_IN('dlopen dlsym dlerror dlclose', 'dl',
                         checklibc=True, headers='dlfcn.h dl.h')
index 2479c21b5533886442ffae178cd585d16f8aaf0c..2420ee1f808f959b1338449d83f888b0d0004f83 100644 (file)
@@ -48,7 +48,7 @@ static int solaris_openat(int fildes, const char *path, int oflag, mode_t mode);
 
 ssize_t rep_getxattr (const char *path, const char *name, void *value, size_t size)
 {
-#if defined(HAVE_GETXATTR)
+#if defined(HAVE_XATTR_XATTR)
 #ifndef XATTR_ADDITIONAL_OPTIONS
        return getxattr(path, name, value, size);
 #else
@@ -58,9 +58,9 @@ ssize_t rep_getxattr (const char *path, const char *name, void *value, size_t si
        int options = 0;
        return getxattr(path, name, value, size, 0, options);
 #endif
-#elif defined(HAVE_GETEA)
+#elif defined(HAVE_XATTR_EA)
        return getea(path, name, value, size);
-#elif defined(HAVE_EXTATTR_GET_FILE)
+#elif defined(HAVE_XATTR_EXTATTR)
        ssize_t retval;
        int attrnamespace;
        const char *attrname;
@@ -93,7 +93,7 @@ ssize_t rep_getxattr (const char *path, const char *name, void *value, size_t si
        }
 
        return -1;
-#elif defined(HAVE_ATTR_GET)
+#elif defined(HAVE_XATTR_ATTR)
        int retval, flags = 0;
        int valuelength = (int)size;
        char *attrname = strchr(name,'.') + 1;
@@ -122,7 +122,7 @@ ssize_t rep_getxattr (const char *path, const char *name, void *value, size_t si
 
 ssize_t rep_fgetxattr (int filedes, const char *name, void *value, size_t size)
 {
-#if defined(HAVE_FGETXATTR)
+#if defined(HAVE_XATTR_XATTR)
 #ifndef XATTR_ADDITIONAL_OPTIONS
        return fgetxattr(filedes, name, value, size);
 #else
@@ -132,9 +132,9 @@ ssize_t rep_fgetxattr (int filedes, const char *name, void *value, size_t size)
        int options = 0;
        return fgetxattr(filedes, name, value, size, 0, options);
 #endif
-#elif defined(HAVE_FGETEA)
+#elif defined(HAVE_XATTR_EA)
        return fgetea(filedes, name, value, size);
-#elif defined(HAVE_EXTATTR_GET_FD)
+#elif defined(HAVE_XATTR_EXTATTR)
        ssize_t retval;
        int attrnamespace;
        const char *attrname;
@@ -162,7 +162,7 @@ ssize_t rep_fgetxattr (int filedes, const char *name, void *value, size_t size)
        }
 
        return -1;
-#elif defined(HAVE_ATTR_GETF)
+#elif defined(HAVE_XATTR_ATTR)
        int retval, flags = 0;
        int valuelength = (int)size;
        char *attrname = strchr(name,'.') + 1;
@@ -188,7 +188,7 @@ ssize_t rep_fgetxattr (int filedes, const char *name, void *value, size_t size)
 #endif
 }
 
-#if defined(HAVE_EXTATTR_LIST_FILE)
+#if defined(HAVE_XATTR_EXTATTR)
 
 #define EXTATTR_PREFIX(s)      (s), (sizeof((s))-1)
 
@@ -219,21 +219,15 @@ static ssize_t bsd_attr_list (int type, extattr_arg arg, char *list, size_t size
                        continue;
                }
                switch(type) {
-#if defined(HAVE_EXTATTR_LIST_FILE)
                        case 0:
                                list_size = extattr_list_file(arg.path, extattr[t].space, list, size);
                                break;
-#endif
-#if defined(HAVE_EXTATTR_LIST_LINK)
                        case 1:
                                list_size = extattr_list_link(arg.path, extattr[t].space, list, size);
                                break;
-#endif
-#if defined(HAVE_EXTATTR_LIST_FD)
                        case 2:
                                list_size = extattr_list_fd(arg.filedes, extattr[t].space, list, size);
                                break;
-#endif
                        default:
                                errno = ENOSYS;
                                return -1;
@@ -285,7 +279,7 @@ static ssize_t bsd_attr_list (int type, extattr_arg arg, char *list, size_t size
 
 #endif
 
-#if defined(HAVE_ATTR_LIST) && (defined(HAVE_SYS_ATTRIBUTES_H) || defined(HAVE_ATTR_ATTRIBUTES_H))
+#if defined(HAVE_XATTR_ATTR) && (defined(HAVE_SYS_ATTRIBUTES_H) || defined(HAVE_ATTR_ATTRIBUTES_H))
 static char attr_buffer[ATTR_MAX_VALUELEN];
 
 static ssize_t irix_attr_list(const char *path, int filedes, char *list, size_t size, int flags)
@@ -355,7 +349,7 @@ static ssize_t irix_attr_list(const char *path, int filedes, char *list, size_t
 
 ssize_t rep_listxattr (const char *path, char *list, size_t size)
 {
-#if defined(HAVE_LISTXATTR)
+#if defined(HAVE_XATTR_XATTR)
 #ifndef XATTR_ADDITIONAL_OPTIONS
        return listxattr(path, list, size);
 #else
@@ -364,13 +358,13 @@ ssize_t rep_listxattr (const char *path, char *list, size_t size)
        int options = 0;
        return listxattr(path, list, size, options);
 #endif
-#elif defined(HAVE_LISTEA)
+#elif defined(HAVE_XATTR_EA)
        return listea(path, list, size);
-#elif defined(HAVE_EXTATTR_LIST_FILE)
+#elif defined(HAVE_XATTR_EXTATTR)
        extattr_arg arg;
        arg.path = path;
        return bsd_attr_list(0, arg, list, size);
-#elif defined(HAVE_ATTR_LIST) && defined(HAVE_SYS_ATTRIBUTES_H)
+#elif defined(HAVE_XATTR_ATTR) && defined(HAVE_SYS_ATTRIBUTES_H)
        return irix_attr_list(path, 0, list, size, 0);
 #elif defined(HAVE_ATTROPEN)
        ssize_t ret = -1;
@@ -388,7 +382,7 @@ ssize_t rep_listxattr (const char *path, char *list, size_t size)
 
 ssize_t rep_flistxattr (int filedes, char *list, size_t size)
 {
-#if defined(HAVE_FLISTXATTR)
+#if defined(HAVE_XATTR_XATTR)
 #ifndef XATTR_ADDITIONAL_OPTIONS
        return flistxattr(filedes, list, size);
 #else
@@ -397,13 +391,13 @@ ssize_t rep_flistxattr (int filedes, char *list, size_t size)
        int options = 0;
        return flistxattr(filedes, list, size, options);
 #endif
-#elif defined(HAVE_FLISTEA)
+#elif defined(HAVE_XATTR_EA)
        return flistea(filedes, list, size);
-#elif defined(HAVE_EXTATTR_LIST_FD)
+#elif defined(HAVE_XATTR_EXTATTR)
        extattr_arg arg;
        arg.filedes = filedes;
        return bsd_attr_list(2, arg, list, size);
-#elif defined(HAVE_ATTR_LISTF)
+#elif defined(HAVE_XATTR_ATTR)
        return irix_attr_list(NULL, filedes, list, size, 0);
 #elif defined(HAVE_ATTROPEN)
        ssize_t ret = -1;
@@ -421,7 +415,7 @@ ssize_t rep_flistxattr (int filedes, char *list, size_t size)
 
 int rep_removexattr (const char *path, const char *name)
 {
-#if defined(HAVE_REMOVEXATTR)
+#if defined(HAVE_XATTR_XATTR)
 #ifndef XATTR_ADDITIONAL_OPTIONS
        return removexattr(path, name);
 #else
@@ -430,9 +424,9 @@ int rep_removexattr (const char *path, const char *name)
        int options = 0;
        return removexattr(path, name, options);
 #endif
-#elif defined(HAVE_REMOVEEA)
+#elif defined(HAVE_XATTR_EA)
        return removeea(path, name);
-#elif defined(HAVE_EXTATTR_DELETE_FILE)
+#elif defined(HAVE_XATTR_EXTATTR)
        int attrnamespace;
        const char *attrname;
 
@@ -448,7 +442,7 @@ int rep_removexattr (const char *path, const char *name)
        }
 
        return extattr_delete_file(path, attrnamespace, attrname);
-#elif defined(HAVE_ATTR_REMOVE)
+#elif defined(HAVE_XATTR_ATTR)
        int flags = 0;
        char *attrname = strchr(name,'.') + 1;
 
@@ -471,7 +465,7 @@ int rep_removexattr (const char *path, const char *name)
 
 int rep_fremovexattr (int filedes, const char *name)
 {
-#if defined(HAVE_FREMOVEXATTR)
+#if defined(HAVE_XATTR_XATTR)
 #ifndef XATTR_ADDITIONAL_OPTIONS
        return fremovexattr(filedes, name);
 #else
@@ -480,9 +474,9 @@ int rep_fremovexattr (int filedes, const char *name)
        int options = 0;
        return fremovexattr(filedes, name, options);
 #endif
-#elif defined(HAVE_FREMOVEEA)
+#elif defined(HAVE_XATTR_EA)
        return fremoveea(filedes, name);
-#elif defined(HAVE_EXTATTR_DELETE_FD)
+#elif defined(HAVE_XATTR_EXTATTR)
        int attrnamespace;
        const char *attrname;
 
@@ -498,7 +492,7 @@ int rep_fremovexattr (int filedes, const char *name)
        }
 
        return extattr_delete_fd(filedes, attrnamespace, attrname);
-#elif defined(HAVE_ATTR_REMOVEF)
+#elif defined(HAVE_XATTR_ATTR)
        int flags = 0;
        char *attrname = strchr(name,'.') + 1;
 
@@ -521,7 +515,7 @@ int rep_fremovexattr (int filedes, const char *name)
 
 int rep_setxattr (const char *path, const char *name, const void *value, size_t size, int flags)
 {
-#if defined(HAVE_SETXATTR)
+#if defined(HAVE_XATTR_XATTR)
 #ifndef XATTR_ADDITIONAL_OPTIONS
        return setxattr(path, name, value, size, flags);
 #else
@@ -530,9 +524,9 @@ int rep_setxattr (const char *path, const char *name, const void *value, size_t
        int options = 0;
        return setxattr(path, name, value, size, 0, options);
 #endif
-#elif defined(HAVE_SETEA)
+#elif defined(HAVE_XATTR_EA)
        return setea(path, name, value, size, flags);
-#elif defined(HAVE_EXTATTR_SET_FILE)
+#elif defined(HAVE_XATTR_EXTATTR)
        int retval = 0;
        int attrnamespace;
        const char *attrname;
@@ -569,7 +563,7 @@ int rep_setxattr (const char *path, const char *name, const void *value, size_t
        }
        retval = extattr_set_file(path, attrnamespace, attrname, value, size);
        return (retval < 0) ? -1 : 0;
-#elif defined(HAVE_ATTR_SET)
+#elif defined(HAVE_XATTR_ATTR)
        int myflags = 0;
        char *attrname = strchr(name,'.') + 1;
 
@@ -598,7 +592,7 @@ int rep_setxattr (const char *path, const char *name, const void *value, size_t
 
 int rep_fsetxattr (int filedes, const char *name, const void *value, size_t size, int flags)
 {
-#if defined(HAVE_FSETXATTR)
+#if defined(HAVE_XATTR_XATTR)
 #ifndef XATTR_ADDITIONAL_OPTIONS
        return fsetxattr(filedes, name, value, size, flags);
 #else
@@ -607,9 +601,9 @@ int rep_fsetxattr (int filedes, const char *name, const void *value, size_t size
        int options = 0;
        return fsetxattr(filedes, name, value, size, 0, options);
 #endif
-#elif defined(HAVE_FSETEA)
+#elif defined(HAVE_XATTR_EA)
        return fsetea(filedes, name, value, size, flags);
-#elif defined(HAVE_EXTATTR_SET_FD)
+#elif defined(HAVE_XATTR_EXTATTR)
        int retval = 0;
        int attrnamespace;
        const char *attrname;
@@ -646,7 +640,7 @@ int rep_fsetxattr (int filedes, const char *name, const void *value, size_t size
        }
        retval = extattr_set_fd(filedes, attrnamespace, attrname, value, size);
        return (retval < 0) ? -1 : 0;
-#elif defined(HAVE_ATTR_SETF)
+#elif defined(HAVE_XATTR_ATTR)
        int myflags = 0;
        char *attrname = strchr(name,'.') + 1;