#include "../src/guestfs_protocol.h"
#include "daemon.h"
#include "actions.h"
+#include "optgroups.h"
#if defined(HAVE_ATTR_XATTR_H) || defined(HAVE_SYS_XATTR_H)
-#ifdef HAVE_ATTR_XATTR_H
-#include <attr/xattr.h>
-#else
-#ifdef HAVE_SYS_XATTR_H
-#include <sys/xattr.h>
-#endif
-#endif
+# ifdef HAVE_ATTR_XATTR_H
+# include <attr/xattr.h>
+# else
+# ifdef HAVE_SYS_XATTR_H
+# include <sys/xattr.h>
+# endif
+# endif
+
+int
+optgroup_linuxxattrs_available (void)
+{
+ return 1;
+}
static guestfs_int_xattr_list *getxattrs (const char *path, ssize_t (*listxattr) (const char *path, char *list, size_t size), ssize_t (*getxattr) (const char *path, const char *name, void *value, size_t size));
static int _setxattr (const char *xattr, const char *val, int vallen, const char *path, int (*setxattr) (const char *path, const char *name, const void *value, size_t size, int flags));
#if defined(HAVE_LISTXATTR) && defined(HAVE_GETXATTR)
return getxattrs (path, listxattr, getxattr);
#else
- reply_with_error ("getxattrs: no support for listxattr and getxattr");
+ reply_with_error ("no support for listxattr and getxattr");
return NULL;
#endif
}
#if defined(HAVE_LLISTXATTR) && defined(HAVE_LGETXATTR)
return getxattrs (path, llistxattr, lgetxattr);
#else
- reply_with_error ("lgetxattrs: no support for llistxattr and lgetxattr");
+ reply_with_error ("no support for llistxattr and lgetxattr");
return NULL;
#endif
}
#if defined(HAVE_SETXATTR)
return _setxattr (xattr, val, vallen, path, setxattr);
#else
- reply_with_error ("setxattr: no support for setxattr");
+ reply_with_error ("no support for setxattr");
return -1;
#endif
}
#if defined(HAVE_LSETXATTR)
return _setxattr (xattr, val, vallen, path, lsetxattr);
#else
- reply_with_error ("lsetxattr: no support for lsetxattr");
+ reply_with_error ("no support for lsetxattr");
return -1;
#endif
}
#if defined(HAVE_REMOVEXATTR)
return _removexattr (xattr, path, removexattr);
#else
- reply_with_error ("removexattr: no support for removexattr");
+ reply_with_error ("no support for removexattr");
return -1;
#endif
}
#if defined(HAVE_LREMOVEXATTR)
return _removexattr (xattr, path, lremovexattr);
#else
- reply_with_error ("lremovexattr: no support for lremovexattr");
+ reply_with_error ("no support for lremovexattr");
return -1;
#endif
}
len = listxattr (path, NULL, 0);
CHROOT_OUT;
if (len == -1) {
- reply_with_perror ("listxattr");
+ reply_with_perror ("listxattr: %s", path);
goto error;
}
len = listxattr (path, buf, len);
CHROOT_OUT;
if (len == -1) {
- reply_with_perror ("listxattr");
+ reply_with_perror ("listxattr: %s", path);
goto error;
}
char *buf = NULL;
if (path_len >= PATH_MAX) {
- reply_with_perror ("lxattrlist: path longer than PATH_MAX");
+ reply_with_perror ("path longer than PATH_MAX");
goto error;
}
* outgoing struct list.
*/
if (path_len + strlen (names[k]) + 2 > PATH_MAX) {
- reply_with_perror ("lxattrlist: path and name longer than PATH_MAX");
+ reply_with_perror ("path and name longer than PATH_MAX");
goto error;
}
pathname[path_len] = '/';
}
return NULL;
#else
- reply_with_error ("lxattrlist: no support for llistxattr and lgetxattr");
+ reply_with_error ("no support for llistxattr and lgetxattr");
return NULL;
#endif
}
#else /* no xattr.h */
+int
+optgroup_linuxxattrs_available (void)
+{
+ return 0;
+}
guestfs_int_xattr_list *
do_getxattrs (const char *path)
{
- reply_with_error ("getxattrs: no support for xattrs");
- return NULL;
+ NOT_AVAILABLE (NULL);
}
guestfs_int_xattr_list *
do_lgetxattrs (const char *path)
{
- reply_with_error ("lgetxattrs: no support for xattrs");
- return NULL;
+ NOT_AVAILABLE (NULL);
}
int
do_setxattr (const char *xattr, const char *val, int vallen, const char *path)
{
- reply_with_error ("setxattr: no support for xattrs");
- return -1;
+ NOT_AVAILABLE (-1);
}
int
do_lsetxattr (const char *xattr, const char *val, int vallen, const char *path)
{
- reply_with_error ("lsetxattr: no support for xattrs");
- return -1;
+ NOT_AVAILABLE (-1);
}
int
do_removexattr (const char *xattr, const char *path)
{
- reply_with_error ("removexattr: no support for xattrs");
- return -1;
+ NOT_AVAILABLE (-1);
}
int
do_lremovexattr (const char *xattr, const char *path)
{
- reply_with_error ("lremovexattr: no support for xattrs");
- return -1;
+ NOT_AVAILABLE (-1);
}
guestfs_int_xattr_list *
do_lxattrlist (const char *path, char *const *names)
{
- reply_with_error ("lxattrlist: no support for xattrs");
- return NULL;
+ NOT_AVAILABLE (NULL);
}
#endif /* no xattr.h */