Blob Blame History Raw
commit 3c7a1372a2ff3bd40d05cfca56af54cd1ae12321
Author: Vaclav Dolezal <vdolezal@redhat.com>
Date:   Wed Mar 6 11:37:50 2019 +0100

    Use xattr functions from libc
    
    Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>

diff --git a/restore/xattr.c b/restore/xattr.c
index ddabfa2..a176e7e 100644
--- a/restore/xattr.c
+++ b/restore/xattr.c
@@ -36,6 +36,7 @@ static const char rcsid[] =
 #include <compatlfs.h>
 #include <compaterr.h>
 #include <sys/types.h>
+#include <sys/xattr.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -124,82 +125,6 @@ struct ext2_xattr_entry {
 		(entry)->e_value_offs + sizeof(struct ext3_xattr_ibody_header) : \
 		(entry)->e_value_offs))
 	
-/*
- * xattr syscalls do not exist yet in libc, get our own copy here,
- * taken from libattr.
- */
-#if defined (__i386__)
-# define HAVE_XATTR_SYSCALLS 1
-# define __NR_lsetxattr		227
-# define __NR_lgetxattr		230
-# define __NR_llistxattr	233
-#elif defined (__sparc__)
-# define HAVE_XATTR_SYSCALLS 1
-# define __NR_lsetxattr		170
-# define __NR_lgetxattr		173
-# define __NR_llistxattr	179
-#elif defined (__ia64__)
-# define HAVE_XATTR_SYSCALLS 1
-# define __NR_lsetxattr		1218
-# define __NR_lgetxattr		1221
-# define __NR_llistxattr	1224
-#elif defined (__powerpc__)
-# define HAVE_XATTR_SYSCALLS 1
-# define __NR_lsetxattr		210
-# define __NR_lgetxattr		213
-# define __NR_llistxattr	216
-#elif defined (__x86_64__)
-# define HAVE_XATTR_SYSCALLS 1
-# define __NR_lsetxattr		189
-# define __NR_lgetxattr		192
-# define __NR_llistxattr	195
-#elif defined (__s390__)
-# define HAVE_XATTR_SYSCALLS 1
-# define __NR_lsetxattr		225
-# define __NR_lgetxattr		228
-# define __NR_llistxattr	231
-#elif defined (__arm__)
-# define HAVE_XATTR_SYSCALLS 1
-# define __NR_SYSCALL_BASE 0x900000
-# define __NR_lsetxattr		(__NR_SYSCALL_BASE+227)
-# define __NR_lgetxattr		(__NR_SYSCALL_BASE+230)
-# define __NR_llistxattr	(__NR_SYSCALL_BASE+233)
-#elif defined (__mips64__)
-# define HAVE_XATTR_SYSCALLS 1
-# define __NR_Linux 5000
-# define __NR_lsetxattr		(__NR_Linux + 218)
-# define __NR_lgetxattr		(__NR_Linux + 221)
-# define __NR_llistxattr	(__NR_Linux + 224)
-#elif defined (__mips__)
-# define HAVE_XATTR_SYSCALLS 1
-# define __NR_Linux 4000
-# define __NR_lsetxattr		(__NR_Linux + 225)
-# define __NR_lgetxattr		(__NR_Linux + 228)
-# define __NR_llistxattr	(__NR_Linux + 231)
-#elif defined (__alpha__)
-# define HAVE_XATTR_SYSCALLS 1
-# define __NR_lsetxattr		383
-# define __NR_lgetxattr		386
-# define __NR_llistxattr	389
-#elif defined (__mc68000__)
-# define HAVE_XATTR_SYSCALLS 1
-# define __NR_lsetxattr		224
-# define __NR_lgetxattr		227
-# define __NR_llistxattr	230
-#else
-# warning "Extended attribute syscalls undefined for this architecture"
-# define HAVE_XATTR_SYSCALLS 0
-#endif
-
-#if HAVE_XATTR_SYSCALLS
-# define SYSCALL(args...)	syscall(args)
-#else
-# define SYSCALL(args...)	( errno = ENOSYS, -1 )
-#endif
-
-static int lsetxattr __P((const char *, const char *, void *, size_t, int));
-static ssize_t lgetxattr __P((const char *, const char *, void *, size_t));
-static ssize_t llistxattr __P((const char *, char *, size_t));
 static int xattr_cb_list __P((char *, char *, int, int, void *));
 static int xattr_cb_set __P((char *, char *, int, int, void *));
 static int xattr_cb_compare __P((char *, char *, int, int, void *));
@@ -207,24 +132,6 @@ static int xattr_verify __P((char *));
 static int xattr_count __P((char *, int *));
 static int xattr_walk __P((char *, int (*)(char *, char *, int, int, void *), void *));
 
-static int
-lsetxattr(const char *path, const char *name, void *value, size_t size, int flags)
-{
-	return SYSCALL(__NR_lsetxattr, path, name, value, size, flags);
-}
-
-static ssize_t
-lgetxattr(const char *path, const char *name, void *value, size_t size)
-{
-	return SYSCALL(__NR_lgetxattr, path, name, value, size);
-}
-
-static ssize_t
-llistxattr(const char *path, char *list, size_t size)
-{
-	return SYSCALL(__NR_llistxattr, path, list, size);
-}
-
 #define POSIX_ACL_XATTR_VERSION 0x0002
 
 #define ACL_UNDEFINED_ID        (-1)