diff --git a/daemon/xattr.c b/daemon/xattr.c index af8bfd455..b84cf3d18 100644 --- a/daemon/xattr.c +++ b/daemon/xattr.c @@ -27,7 +27,15 @@ #include "actions.h" #include "optgroups.h" -#if defined(HAVE_ATTR_XATTR_H) || defined(HAVE_SYS_XATTR_H) +#if (defined(HAVE_ATTR_XATTR_H) || defined(HAVE_SYS_XATTR_H)) && \ + defined(HAVE_LISTXATTR) && defined(HAVE_LLISTXATTR) && \ + defined(HAVE_GETXATTR) && defined(HAVE_LGETXATTR) && \ + defined(HAVE_REMOVEXATTR) && defined(HAVE_LREMOVEXATTR) && \ + defined(HAVE_SETXATTR) && defined(HAVE_LSETXATTR) +# define HAVE_LINUX_XATTRS +#endif + +#ifdef HAVE_LINUX_XATTRS # ifdef HAVE_ATTR_XATTR_H # include @@ -50,67 +58,37 @@ static int _removexattr (const char *xattr, const char *path, int (*removexattr) guestfs_int_xattr_list * do_getxattrs (const char *path) { -#if defined(HAVE_LISTXATTR) && defined(HAVE_GETXATTR) return getxattrs (path, listxattr, getxattr); -#else - reply_with_error ("no support for listxattr and getxattr"); - return NULL; -#endif } guestfs_int_xattr_list * do_lgetxattrs (const char *path) { -#if defined(HAVE_LLISTXATTR) && defined(HAVE_LGETXATTR) return getxattrs (path, llistxattr, lgetxattr); -#else - reply_with_error ("no support for llistxattr and lgetxattr"); - return NULL; -#endif } int do_setxattr (const char *xattr, const char *val, int vallen, const char *path) { -#if defined(HAVE_SETXATTR) return _setxattr (xattr, val, vallen, path, setxattr); -#else - reply_with_error ("no support for setxattr"); - return -1; -#endif } int do_lsetxattr (const char *xattr, const char *val, int vallen, const char *path) { -#if defined(HAVE_LSETXATTR) return _setxattr (xattr, val, vallen, path, lsetxattr); -#else - reply_with_error ("no support for lsetxattr"); - return -1; -#endif } int do_removexattr (const char *xattr, const char *path) { -#if defined(HAVE_REMOVEXATTR) return _removexattr (xattr, path, removexattr); -#else - reply_with_error ("no support for removexattr"); - return -1; -#endif } int do_lremovexattr (const char *xattr, const char *path) { -#if defined(HAVE_LREMOVEXATTR) return _removexattr (xattr, path, lremovexattr); -#else - reply_with_error ("no support for lremovexattr"); - return -1; -#endif } static int @@ -277,7 +255,6 @@ _removexattr (const char *xattr, const char *path, guestfs_int_xattr_list * do_internal_lxattrlist (const char *path, char *const *names) { -#if defined(HAVE_LLISTXATTR) && defined(HAVE_LGETXATTR) guestfs_int_xattr_list *ret = NULL; size_t i, j; size_t k, m, nr_attrs; @@ -443,10 +420,6 @@ do_internal_lxattrlist (const char *path, char *const *names) free (ret); } return NULL; -#else - reply_with_error ("no support for llistxattr and lgetxattr"); - return NULL; -#endif } char * @@ -545,8 +518,8 @@ do_lgetxattr (const char *path, const char *name, size_t *size_r) return buf; /* caller frees */ } -#else /* no xattr.h */ +#else /* no HAVE_LINUX_XATTRS */ OPTGROUP_LINUXXATTRS_NOT_AVAILABLE -#endif /* no xattr.h */ +#endif /* no HAVE_LINUX_XATTRS */