[Pkg-libvirt-commits] [libguestfs] 19/233: daemon: xattr: simplify the enabling of the linuxxattrs features
Hilko Bengen
bengen at moszumanska.debian.org
Wed Feb 19 21:10:42 UTC 2014
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to branch experimental
in repository libguestfs.
commit 7630a7bbbdceee8e6aad08511e752f5fcb273416
Author: Pino Toscano <ptoscano at redhat.com>
Date: Thu Jan 9 18:59:19 2014 +0100
daemon: xattr: simplify the enabling of the linuxxattrs features
Instead of enable them when having one of the two headers for it but
still checking for the HAVE_* availability of each *xattr() function
used, just enable the linuxxattrs as a whole when having any of the
needed headers (like before) and all the needed functions.
This might cause the linuxxattrs to not be available anymore on systems
without the whole set of *xattr() functions implemented, but OTOH it
simplifies the xattr.c implementations.
---
daemon/xattr.c | 49 +++++++++++--------------------------------------
1 file changed, 11 insertions(+), 38 deletions(-)
diff --git a/daemon/xattr.c b/daemon/xattr.c
index af8bfd4..b84cf3d 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 <attr/xattr.h>
@@ -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 */
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git
More information about the Pkg-libvirt-commits
mailing list