summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gruenbacher <andreas.gruenbacher@gmail.com>2015-04-15 01:33:58 +0200
committerAndreas Gruenbacher <andreas.gruenbacher@gmail.com>2015-04-15 01:45:04 +0200
commit7921157890d07858d092f4003ca4c6bae9fd2c38 (patch)
treec0c152fb535e42d1d072021aa371b816e0d77df2
parent8d1263bca95722d66a6f8e83450f49d0956ea534 (diff)
downloadattr-7921157890d07858d092f4003ca4c6bae9fd2c38.tar.gz
Remove <attr/xattr.h> and the syscall wrappers
The xattr syscalls are provided by glibc since ages, so there is no need to use the indirect system call "syscall" anymore. This removes the need for the <attr/xattr.h> header; use <sys/xattr.h> instead.
-rw-r--r--include/Makemodule.am3
-rw-r--r--include/attributes.h4
-rw-r--r--include/xattr.h77
-rw-r--r--libattr/Makemodule.am3
-rw-r--r--libattr/attr_copy_fd.c5
-rw-r--r--libattr/attr_copy_file.c5
-rw-r--r--libattr/libattr.c6
-rw-r--r--libattr/libattr.h1
-rw-r--r--libattr/syscalls.c105
-rw-r--r--tools/getfattr.c2
-rw-r--r--tools/setfattr.c3
11 files changed, 16 insertions, 198 deletions
diff --git a/include/Makemodule.am b/include/Makemodule.am
index e2017c5..2ab600a 100644
--- a/include/Makemodule.am
+++ b/include/Makemodule.am
@@ -1,8 +1,7 @@
pkginclude_HEADERS += \
include/attributes.h \
include/error_context.h \
- include/libattr.h \
- include/xattr.h
+ include/libattr.h
noinst_HEADERS += \
include/misc.h \
diff --git a/include/attributes.h b/include/attributes.h
index 7e07f11..c5809eb 100644
--- a/include/attributes.h
+++ b/include/attributes.h
@@ -22,6 +22,10 @@
extern "C" {
#endif
+#ifndef ENOATTR
+# define ENOATTR ENODATA
+#endif
+
/*
* An almost-IRIX-compatible extended attributes API
* (the IRIX attribute "list" operation is missing, added ATTR_SECURE).
diff --git a/include/xattr.h b/include/xattr.h
deleted file mode 100644
index fd1f268..0000000
--- a/include/xattr.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2001-2002 Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-#ifndef __XATTR_H__
-#define __XATTR_H__
-
-#if defined(linux)
-#include <features.h>
-#endif
-
-/* Portability non glibc c++ build systems */
-#ifndef __THROW
-# if defined __cplusplus
-# define __THROW throw ()
-# else
-# define __THROW
-# endif
-#endif
-
-#include <errno.h>
-#ifndef ENOATTR
-# define ENOATTR ENODATA /* No such attribute */
-#endif
-
-#define XATTR_CREATE 0x1 /* set value, fail if attr already exists */
-#define XATTR_REPLACE 0x2 /* set value, fail if attr does not exist */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern int setxattr (const char *__path, const char *__name,
- const void *__value, size_t __size, int __flags) __THROW;
-extern int lsetxattr (const char *__path, const char *__name,
- const void *__value, size_t __size, int __flags) __THROW;
-extern int fsetxattr (int __filedes, const char *__name,
- const void *__value, size_t __size, int __flags) __THROW;
-
-extern ssize_t getxattr (const char *__path, const char *__name,
- void *__value, size_t __size) __THROW;
-extern ssize_t lgetxattr (const char *__path, const char *__name,
- void *__value, size_t __size) __THROW;
-extern ssize_t fgetxattr (int __filedes, const char *__name,
- void *__value, size_t __size) __THROW;
-
-extern ssize_t listxattr (const char *__path, char *__list,
- size_t __size) __THROW;
-extern ssize_t llistxattr (const char *__path, char *__list,
- size_t __size) __THROW;
-extern ssize_t flistxattr (int __filedes, char *__list,
- size_t __size) __THROW;
-
-extern int removexattr (const char *__path, const char *__name) __THROW;
-extern int lremovexattr (const char *__path, const char *__name) __THROW;
-extern int fremovexattr (int __filedes, const char *__name) __THROW;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __XATTR_H__ */
diff --git a/libattr/Makemodule.am b/libattr/Makemodule.am
index 5c888f0..a5a0cdd 100644
--- a/libattr/Makemodule.am
+++ b/libattr/Makemodule.am
@@ -15,8 +15,7 @@ libattr_la_SOURCES = \
libattr/attr_copy_fd.c \
libattr/attr_copy_file.c \
libattr/libattr.c \
- libattr/libattr.h \
- libattr/syscalls.c
+ libattr/libattr.h
libattr_la_CFLAGS = -include libattr/libattr.h
libattr_la_LDFLAGS = \
-Wl,--version-script,$(top_srcdir)/exports \
diff --git a/libattr/attr_copy_fd.c b/libattr/attr_copy_fd.c
index a21e8c2..af237c9 100644
--- a/libattr/attr_copy_fd.c
+++ b/libattr/attr_copy_fd.c
@@ -22,6 +22,7 @@
#endif
#include <sys/types.h>
+# include <sys/xattr.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
@@ -30,10 +31,6 @@
# include <alloca.h>
#endif
-#if defined(HAVE_ATTR_XATTR_H)
-# include <attr/xattr.h>
-#endif
-
#if defined(HAVE_ATTR_LIBATTR_H)
# include "attr/libattr.h"
#endif
diff --git a/libattr/attr_copy_file.c b/libattr/attr_copy_file.c
index 9132433..6cd8f81 100644
--- a/libattr/attr_copy_file.c
+++ b/libattr/attr_copy_file.c
@@ -22,6 +22,7 @@
#endif
#include <sys/types.h>
+# include <sys/xattr.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
@@ -30,10 +31,6 @@
# include <alloca.h>
#endif
-#if defined(HAVE_ATTR_XATTR_H)
-# include <attr/xattr.h>
-#endif
-
#if defined(HAVE_ATTR_LIBATTR_H)
# include "attr/libattr.h"
#endif
diff --git a/libattr/libattr.c b/libattr/libattr.c
index e68d3f6..0e8fffe 100644
--- a/libattr/libattr.c
+++ b/libattr/libattr.c
@@ -21,10 +21,14 @@
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
+#include <sys/xattr.h>
-#include <attr/xattr.h>
#include <attr/attributes.h>
+#ifndef ENOATTR
+# define ENOATTR ENODATA
+#endif
+
#undef MAXNAMELEN
#define MAXNAMELEN 256
#undef MAXLISTLEN
diff --git a/libattr/libattr.h b/libattr/libattr.h
index 8973b00..2330d4b 100644
--- a/libattr/libattr.h
+++ b/libattr/libattr.h
@@ -1,6 +1,5 @@
/* Features we provide ourself. */
-#define HAVE_ATTR_XATTR_H 1
#define HAVE_ATTR_LIBATTR_H 1
#define HAVE_CONFIG_H 1
diff --git a/libattr/syscalls.c b/libattr/syscalls.c
deleted file mode 100644
index 51fe98c..0000000
--- a/libattr/syscalls.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2001-2002 Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * The use of the syscall() function is an additional level of
- * indirection. This avoids the dependency on kernel sources.
- */
-
-#include <errno.h>
-#include <unistd.h>
-#include <sys/syscall.h>
-
-#if defined (__NR_setxattr)
-# define HAVE_XATTR_SYSCALLS 1
-#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
-
-int setxattr (const char *path, const char *name,
- void *value, size_t size, int flags)
-{
- return SYSCALL(__NR_setxattr, path, name, value, size, flags);
-}
-
-int lsetxattr (const char *path, const char *name,
- void *value, size_t size, int flags)
-{
- return SYSCALL(__NR_lsetxattr, path, name, value, size, flags);
-}
-
-int fsetxattr (int filedes, const char *name,
- void *value, size_t size, int flags)
-{
- return SYSCALL(__NR_fsetxattr, filedes, name, value, size, flags);
-}
-
-ssize_t getxattr (const char *path, const char *name,
- void *value, size_t size)
-{
- return SYSCALL(__NR_getxattr, path, name, value, size);
-}
-
-ssize_t lgetxattr (const char *path, const char *name,
- void *value, size_t size)
-{
- return SYSCALL(__NR_lgetxattr, path, name, value, size);
-}
-
-ssize_t fgetxattr (int filedes, const char *name,
- void *value, size_t size)
-{
- return SYSCALL(__NR_fgetxattr, filedes, name, value, size);
-}
-
-ssize_t listxattr (const char *path, char *list, size_t size)
-{
- return SYSCALL(__NR_listxattr, path, list, size);
-}
-
-ssize_t llistxattr (const char *path, char *list, size_t size)
-{
- return SYSCALL(__NR_llistxattr, path, list, size);
-}
-
-ssize_t flistxattr (int filedes, char *list, size_t size)
-{
- return SYSCALL(__NR_flistxattr, filedes, list, size);
-}
-
-int removexattr (const char *path, const char *name)
-{
- return SYSCALL(__NR_removexattr, path, name);
-}
-
-int lremovexattr (const char *path, const char *name)
-{
- return SYSCALL(__NR_lremovexattr, path, name);
-}
-
-int fremovexattr (int filedes, const char *name)
-{
- return SYSCALL(__NR_fremovexattr, filedes, name);
-}
diff --git a/tools/getfattr.c b/tools/getfattr.c
index 9ea44d5..cc55d5f 100644
--- a/tools/getfattr.c
+++ b/tools/getfattr.c
@@ -28,8 +28,8 @@
#include <regex.h>
#include <locale.h>
#include <libgen.h>
+#include <sys/xattr.h>
-#include <attr/xattr.h>
#include "config.h"
#include "walk_tree.h"
#include "misc.h"
diff --git a/tools/setfattr.c b/tools/setfattr.c
index e209b0d..9556c6c 100644
--- a/tools/setfattr.c
+++ b/tools/setfattr.c
@@ -27,8 +27,9 @@
#include <locale.h>
#include <ctype.h>
#include <libgen.h>
+#include <sys/xattr.h>
+#include <sys/errno.h>
-#include <attr/xattr.h>
#include "config.h"
#include "misc.h"