Skip to contentSkip to conversation

Allow usage of <sys/xattr.h> header.

PATCH Superseded Dejan Jovicevic 3 participants 3 messages Sep 28, 2016 – Oct 3, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow usage of <sys/xattr.h> header.

<sys/xattr.h> is nowdays much more common than <attr/xattr.h>. Man pages also list <sys/xattr.h> as needed header for syscalls getxattr, setxattr, lgetxattr, llistxattr and removexattr.

Currently, related ltp tests are disabled if <attr/xattr.h> is not found during configuration process. This patch allows compilation if <attr/xattr.h> is not present, but <sys/xattr.h> is present. If <sys/xattr.h> is not present, configuration and compilation will remain unchanged.

Also, occurances of error code ENOATTR are replaced with ENODATA. They are defined as the same value in linux kernel source code, but ENODATA is visible to user mode application. For example, /include/uapi/asm-generic/errno.h defines ENODATA but not ENOATTR. Therefore, ENODATA is a better choice.

---
 configure.ac                                          |  1 +
 testcases/kernel/syscalls/getxattr/getxattr01.c       | 12 +++++++-----
 testcases/kernel/syscalls/getxattr/getxattr02.c       | 10 ++++++----
 testcases/kernel/syscalls/getxattr/getxattr03.c       | 10 ++++++----
 testcases/kernel/syscalls/lgetxattr/lgetxattr01.c     | 12 +++++++-----
 testcases/kernel/syscalls/lgetxattr/lgetxattr02.c     | 14 ++++++++------
 testcases/kernel/syscalls/llistxattr/llistxattr01.c   | 12 +++++++-----
 testcases/kernel/syscalls/llistxattr/llistxattr02.c   | 12 +++++++-----
 testcases/kernel/syscalls/llistxattr/llistxattr03.c   | 12 +++++++-----
 testcases/kernel/syscalls/open/open13.c               | 11 +++++++----
 testcases/kernel/syscalls/removexattr/removexattr01.c | 12 +++++++-----
 testcases/kernel/syscalls/removexattr/removexattr02.c | 12 +++++++-----
 testcases/kernel/syscalls/setxattr/setxattr01.c       | 12 +++++++-----
 testcases/kernel/syscalls/setxattr/setxattr02.c       | 10 ++++++----
 testcases/kernel/syscalls/setxattr/setxattr03.c       | 10 ++++++----
 15 files changed, 96 insertions(+), 66 deletions(-)
configure.ac +1 -0
index 9901612..37ee6b9 100644
@@ -36,6 +36,7 @@ AC_CHECK_HEADERS([ \
     libaio.h \
     mm.h \
     pthread.h \
+    sys/xattr.h \
     attr/xattr.h \
     linux/genetlink.h \
     linux/mempolicy.h \
testcases/kernel/syscalls/getxattr/getxattr01.c +7 -5
index f99ed24..fe1f28c 100644
@@ -44,14 +44,16 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#ifdef HAVE_ATTR_XATTR_H
+#ifdef HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
+#elif HAVE_ATTR_XATTR_H
 #include <attr/xattr.h>
 #endif
 #include "test.h"
 
 char *TCID = "getxattr01";
 
-#ifdef HAVE_ATTR_XATTR_H
+#if defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H)
 #define XATTR_TEST_KEY "user.testkey"
 #define XATTR_TEST_VALUE "this is a test value"
 #define XATTR_TEST_VALUE_SIZE 20
@@ -75,7 +77,7 @@ struct test_case tc[] = {
 	 .key = "user.nosuchkey",
 	 .value = NULL,
 	 .size = BUFFSIZE - 1,
-	 .exp_err = ENOATTR,
+	 .exp_err = ENODATA,
 	 },
 	{			/* case 01, small value buffer */
 	 .fname = filename,
@@ -171,9 +173,9 @@ static void cleanup(void)
 {
 	tst_rmdir();
 }
-#else /* HAVE_ATTR_XATTR_H */
+#else /* HAVE_SYS_XATTR_H or HAVE_ATTR_XATTR_H */
 int main(int argc, char *argv[])
 {
-	tst_brkm(TCONF, NULL, "<attr/xattr.h> does not exist.");
+	tst_brkm(TCONF, NULL, "neither <sys/xattr.h> nor <attr/xattr.h> does not exist.");
 }
 #endif
testcases/kernel/syscalls/getxattr/getxattr02.c +6 -4
index 8c5be0f..742d743 100644
@@ -49,14 +49,16 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#ifdef HAVE_ATTR_XATTR_H
+#ifdef HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
+#elif HAVE_ATTR_XATTR_H
 #include <attr/xattr.h>
 #endif
 #include "test.h"
 
 char *TCID = "getxattr02";
 
-#ifdef HAVE_ATTR_XATTR_H
+#if defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H)
 #define XATTR_TEST_KEY "user.testkey"
 
 #define FIFO "getxattr02fifo"
@@ -160,9 +162,9 @@ static void cleanup(void)
 {
 	tst_rmdir();
 }
-#else /* HAVE_ATTR_XATTR_H */
+#else /* HAVE_SYS_XATTTR_H or HAVE_ATTR_XATTR_H */
 int main(int argc, char *argv[])
 {
-	tst_brkm(TCONF, NULL, "<attr/xattr.h> does not exist.");
+	tst_brkm(TCONF, NULL, "neither <sys/xattr.h> nor <attr/xattr.h> does not exist.");
 }
 #endif
testcases/kernel/syscalls/getxattr/getxattr03.c +6 -4
index 75339f7..1a09fb7 100644
@@ -38,14 +38,16 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#ifdef HAVE_ATTR_XATTR_H
+#ifdef HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
+#elif HAVE_ATTR_XATTR_H
 #include <attr/xattr.h>
 #endif
 #include "test.h"
 
 char *TCID = "getxattr03";
 
-#ifdef HAVE_ATTR_XATTR_H
+#if defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H)
 #define XATTR_TEST_KEY "user.testkey"
 #define XATTR_TEST_VALUE "test value"
 #define XATTR_TEST_VALUE_SIZE (sizeof(XATTR_TEST_VALUE) - 1)
@@ -110,9 +112,9 @@ static void cleanup(void)
 {
 	tst_rmdir();
 }
-#else /* HAVE_ATTR_XATTR_H */
+#else /* HAVE_SYS_XATTR_H or HAVE_ATTR_XATTR_H */
 int main(int argc, char *argv[])
 {
-	tst_brkm(TCONF, NULL, "<attr/xattr.h> does not exist.");
+	tst_brkm(TCONF, NULL, "neither <sys/xattr.h> nor <attr/xattr.h> does not exist.");
 }
 #endif
testcases/kernel/syscalls/lgetxattr/lgetxattr01.c +7 -5
index b9afc9a..c4e0b37 100644
@@ -29,13 +29,15 @@
 #include <sys/types.h>
 #include <string.h>
 
-#ifdef HAVE_ATTR_XATTR_H
-# include <attr/xattr.h>
+#ifdef HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
+#elif HAVE_ATTR_XATTR_H
+#include <attr/xattr.h>
 #endif
 
 #include "tst_test.h"
 
-#ifdef HAVE_ATTR_XATTR_H
+#if defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H)
 
 #define SECURITY_KEY1   "security.ltptest1"
 #define SECURITY_KEY2   "security.ltptest2"
@@ -113,5 +115,5 @@ static struct tst_test test = {
 };
 
 #else
-	TST_TEST_TCONF("<attr/xattr.h> does not exist.");
-#endif /* HAVE_ATTR_XATTR_H */
+	TST_TEST_TCONF("neither <sys/xattr.h> nor <attr/xattr.h> does not exist.");
+#endif /* HAVE_SYS_XATTR_H or HAVE_ATTR_XATTR_H */
testcases/kernel/syscalls/lgetxattr/lgetxattr02.c +8 -6
index 53b7f50..18f83fb 100644
@@ -35,13 +35,15 @@
 #include <sys/types.h>
 #include <string.h>
 
-#ifdef HAVE_ATTR_XATTR_H
-# include <attr/xattr.h>
+#ifdef HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
+#elif HAVE_ATTR_XATTR_H
+#include <attr/xattr.h>
 #endif
 
 #include "tst_test.h"
 
-#ifdef HAVE_ATTR_XATTR_H
+#if defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H)
 
 #define SECURITY_KEY	"security.ltptest"
 #define VALUE	"this is a test value"
@@ -51,7 +53,7 @@ static struct test_case {
 	size_t size;
 	int exp_err;
 } tcase[] = {
-	{"testfile", sizeof(VALUE), ENOATTR},
+	{"testfile", sizeof(VALUE), ENODATA},
 	{"symlink", 1, ERANGE},
 	{(char *)-1, sizeof(VALUE), EFAULT}
 };
@@ -103,6 +105,6 @@ static struct tst_test test = {
 	.setup = setup
 };
 
-#else /* HAVE_ATTR_XATTR_H */
-	TST_TEST_TCONF("<attr/xattr.h> does not exist.");
+#else /* HAVE_SYS_XATTR_H or HAVE_ATTR_XATTR_H */
+	TST_TEST_TCONF("neither <sys/xattr.h> nor <attr/xattr.h> does not exist.");
 #endif
testcases/kernel/syscalls/llistxattr/llistxattr01.c +7 -5
index f543a97..beb021d 100644
@@ -29,13 +29,15 @@
 #include <sys/types.h>
 #include <string.h>
 
-#ifdef HAVE_ATTR_XATTR_H
-# include <attr/xattr.h>
+#ifdef HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
+#elif HAVE_ATTR_XATTR_H
+#include <attr/xattr.h>
 #endif
 
 #include "tst_test.h"
 
-#ifdef HAVE_ATTR_XATTR_H
+#if defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H)
 
 #define SECURITY_KEY1	"security.ltptest1"
 #define SECURITY_KEY2	"security.ltptest2"
@@ -120,6 +122,6 @@ static struct tst_test test = {
 };
 
 #else
-	TST_TEST_TCONF("<attr/xattr.h> does not exist.");
-#endif /* HAVE_ATTR_XATTR_H */
+	TST_TEST_TCONF("neither <sys/xattr.h> nor <attr/xattr.h> does not exist.");
+#endif /* HAVE_SYS_XATTR_H or HAVE_ATTR_XATTR_H */
 
testcases/kernel/syscalls/llistxattr/llistxattr02.c +7 -5
index 6aede03..2287438 100644
@@ -33,13 +33,15 @@
 #include <errno.h>
 #include <sys/types.h>
 
-#ifdef HAVE_ATTR_XATTR_H
-# include <attr/xattr.h>
+#ifdef HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
+#elif HAVE_ATTR_XATTR_H
+#include <attr/xattr.h>
 #endif
 
 #include "tst_test.h"
 
-#ifdef HAVE_ATTR_XATTR_H
+#if defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H)
 
 #define SECURITY_KEY	"security.ltptest"
 #define VALUE	"test"
@@ -106,6 +108,6 @@ static struct tst_test test = {
 	.setup = setup,
 };
 
-#else /* HAVE_ATTR_XATTR_H */
-	TST_TEST_TCONF("<attr/xattr.h> does not exist.");
+#else /* HAVE_SYS_XATTR_H HAVE_ATTR_XATTR_H */
+	TST_TEST_TCONF("neither <sys/xattr.h> nor <attr/xattr.h> does not exist.");
 #endif
testcases/kernel/syscalls/llistxattr/llistxattr03.c +7 -5
index 5513019..7e07901 100644
@@ -27,13 +27,15 @@
 #include <errno.h>
 #include <sys/types.h>
 
-#ifdef HAVE_ATTR_XATTR_H
-# include <attr/xattr.h>
+#ifdef HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
+#elif HAVE_ATTR_XATTR_H
+#include <attr/xattr.h>
 #endif
 
 #include "tst_test.h"
 
-#ifdef HAVE_ATTR_XATTR_H
+#if defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H)
 
 #define SECURITY_KEY	"security.ltptest"
 #define VALUE	"test"
@@ -97,6 +99,6 @@ static struct tst_test test = {
 	.setup = setup,
 };
 
-#else /* HAVE_ATTR_XATTR_H */
-	TST_TEST_TCONF("<attr/xattr.h> does not exist.");
+#else /* HAVE_SYS_XATTR_H or HAVE_ATTR_XATTR_H */
+	TST_TEST_TCONF("neither <sys/xattr.h> nor <attr/xattr.h> does not exist.");
 #endif
testcases/kernel/syscalls/open/open13.c +7 -4
index 1342dc2..5eab950 100644
@@ -30,7 +30,10 @@
 #include "config.h"
 
 #include <errno.h>
-#ifdef HAVE_ATTR_XATTR_H
+#ifdef HAVE_SYS_XATTR_H
+#include <sys/types.h>
+#include <sys/xattr.h>
+#elif HAVE_ATTR_XATTR_H
 #include <sys/types.h>
 #include <attr/xattr.h>
 #endif
@@ -47,7 +50,7 @@ static void verify_read(void);
 static void verify_write(void);
 static void verify_fchmod(void);
 static void verify_fchown(void);
-#ifdef HAVE_ATTR_XATTR_H
+#if defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H)
 static void verify_fgetxattr(void);
 #endif
 static void check_result(const char *call_name);
@@ -60,7 +63,7 @@ static void (*test_func[])(void) = {
 	verify_write,
 	verify_fchmod,
 	verify_fchown,
-#ifdef HAVE_ATTR_XATTR_H
+#if defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H)
 	verify_fgetxattr
 #endif
 };
@@ -135,7 +138,7 @@ static void verify_fchown(void)
 	check_result("fchown(2)");
 }
 
-#ifdef HAVE_ATTR_XATTR_H
+#if defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H)
 static void verify_fgetxattr(void)
 {
 	TEST(fgetxattr(fd, "tkey", NULL, 1));
testcases/kernel/syscalls/removexattr/removexattr01.c +7 -5
index 224065a..2e7b200 100644
@@ -27,7 +27,9 @@
 #include <errno.h>
 #include <sys/types.h>
 
-#ifdef HAVE_ATTR_XATTR_H
+#ifdef HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
+#elif HAVE_ATTR_XATTR_H
 #include <attr/xattr.h>
 #endif
 
@@ -36,7 +38,7 @@
 
 char *TCID = "removexattr01";
 
-#ifdef HAVE_ATTR_XATTR_H
+#if defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H)
 #define USER_KEY	"user.test"
 #define VALUE	"test"
 #define VALUE_SIZE	(sizeof(VALUE) - 1)
@@ -93,7 +95,7 @@ static void verify_removexattr(void)
 		return;
 	}
 
-	if (errno != ENOATTR) {
+	if (errno != ENODATA) {
 		tst_resm(TFAIL | TTERRNO, "getxattr() failed unexpectedly");
 	} else {
 		tst_resm(TPASS, "removexattr() succeeded");
@@ -116,9 +118,9 @@ static void cleanup(void)
 	tst_rmdir();
 }
 
-#else /* HAVE_ATTR_XATTR_H */
+#else /* HAVE_SYS_XATTR_H or HAVE_ATTR_XATTR_H */
 int main(int ac, char **av)
 {
-	tst_brkm(TCONF, NULL, "<attr/xattr.h> does not exist.");
+	tst_brkm(TCONF, NULL, "neither <sys/xattr.h> nor <attr/xattr.h> does not exist.");
 }
 #endif
testcases/kernel/syscalls/removexattr/removexattr02.c +7 -5
index e811db2..07a26f3 100644
@@ -32,7 +32,9 @@
 #include <errno.h>
 #include <sys/types.h>
 
-#ifdef HAVE_ATTR_XATTR_H
+#ifdef HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
+#elif HAVE_ATTR_XATTR_H
 #include <attr/xattr.h>
 #endif
 
@@ -41,7 +43,7 @@
 
 char *TCID = "removexattr02";
 
-#ifdef HAVE_ATTR_XATTR_H
+#if defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H)
 
 static struct test_case {
 	const char *path;
@@ -49,7 +51,7 @@ static struct test_case {
 	int exp_err;
 } tc[] = {
 	/* test1 */
-	{"testfile", "user.test", ENOATTR},
+	{"testfile", "user.test", ENODATA},
 	/* test2 */
 	{"", "user.test", ENOENT},
 	/* test3 */
@@ -120,9 +122,9 @@ static void cleanup(void)
 	tst_rmdir();
 }
 
-#else /* HAVE_ATTR_XATTR_H */
+#else /* HAVE_SYS_XATTR_H or HAVE_ATTR_XATTR_H */
 int main(int ac, char **av)
 {
-	tst_brkm(TCONF, NULL, "<attr/xattr.h> does not exist.");
+	tst_brkm(TCONF, NULL, "neither <sys/xattr.h> nor <attr/xattr.h> does not exist.");
 }
 #endif
testcases/kernel/syscalls/setxattr/setxattr01.c +7 -5
index 9f3af6e..0d18bff 100644
@@ -54,14 +54,16 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#ifdef HAVE_ATTR_XATTR_H
+#ifdef HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
+#elif HAVE_ATTR_XATTR_H
 #include <attr/xattr.h>
 #endif
 #include "test.h"
 
 char *TCID = "setxattr01";
 
-#ifdef HAVE_ATTR_XATTR_H
+#if defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H)
 #define XATTR_NAME_MAX 255
 #define XATTR_NAME_LEN (XATTR_NAME_MAX + 2)
 #define XATTR_SIZE_MAX 65536
@@ -99,7 +101,7 @@ struct test_case tc[] = {
 	 .value = XATTR_TEST_VALUE,
 	 .size = XATTR_TEST_VALUE_SIZE,
 	 .flags = XATTR_REPLACE,
-	 .exp_err = ENOATTR,
+	 .exp_err = ENODATA,
 	 },
 	{			/* case 02, long key name, key will be set in setup() */
 	 .fname = filename,
@@ -221,9 +223,9 @@ static void cleanup(void)
 {
 	tst_rmdir();
 }
-#else /* HAVE_ATTR_XATTR_H */
+#else /* HAVE_SYS_XATTR_H or HAVE_ATTR_XATTR_H */
 int main(int argc, char *argv[])
 {
-	tst_brkm(TCONF, NULL, "<attr/xattr.h> does not exist.");
+	tst_brkm(TCONF, NULL, "neither <sys/xattr.h> nor <attr/xattr.h> does not exist.");
 }
 #endif
testcases/kernel/syscalls/setxattr/setxattr02.c +6 -4
index 0ae0b3f..762ce6b 100644
@@ -53,14 +53,16 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#ifdef HAVE_ATTR_XATTR_H
+#ifdef HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
+#elif HAVE_ATTR_XATTR_H
 #include <attr/xattr.h>
 #endif
 #include "test.h"
 
 char *TCID = "setxattr02";
 
-#ifdef HAVE_ATTR_XATTR_H
+#if defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H)
 #define XATTR_TEST_KEY "user.testkey"
 #define XATTR_TEST_VALUE "this is a test value"
 #define XATTR_TEST_VALUE_SIZE 20
@@ -234,9 +236,9 @@ static void cleanup(void)
 {
 	tst_rmdir();
 }
-#else /* HAVE_ATTR_XATTR_H */
+#else /* HAVE_SYS_XATTR_H or HAVE_ATTR_XATTR_H */
 int main(int argc, char *argv[])
 {
-	tst_brkm(TCONF, NULL, "<attr/xattr.h> does not exist.");
+	tst_brkm(TCONF, NULL, "neither <sys/xattr.h> nor <attr/xattr.h> does not exist.");
 }
 #endif
testcases/kernel/syscalls/setxattr/setxattr03.c +6 -4
index edf5c96..4c2595b 100644
@@ -44,7 +44,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#ifdef HAVE_ATTR_XATTR_H
+#ifdef HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
+#elif HAVE_ATTR_XATTR_H
 #include <attr/xattr.h>
 #endif
 #include <linux/fs.h>
@@ -53,7 +55,7 @@
 
 char *TCID = "setxattr03";
 
-#if defined HAVE_ATTR_XATTR_H && defined HAVE_FS_IOC_FLAGS
+#if (defined HAVE_ATTR_XATTR_H || defined HAVE_SYS_XATTR_H) && defined HAVE_FS_IOC_FLAGS
 #define XATTR_TEST_KEY "user.testkey"
 #define XATTR_TEST_VALUE "this is a test value"
 #define XATTR_TEST_VALUE_SIZE (sizeof(XATTR_TEST_VALUE) - 1)
@@ -213,7 +215,7 @@ static void cleanup(void)
 #else
 int main(void)
 {
-	tst_brkm(TCONF, NULL, "<attr/xattr.h> not present or FS_IOC_FLAGS "
+	tst_brkm(TCONF, NULL, "neither <sys/xattr.h> nor<attr/xattr.h> are not present or FS_IOC_FLAGS "
 		 "missing in <linux/fs.h>");
 }
-#endif /* defined HAVE_ATTR_XATTR_H && defined HAVE_FS_IOC_FLAGS */
+#endif /* (defined HAVE_ATTR_XATTR_H || defined HAVE_SYS_XATTR_H) && defined HAVE_FS_IOC_FLAGS */
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 Allow usage of <sys/xattr.h> header.

Hi!

Quoted 3 lines

<sys/xattr.h> is nowdays much more common than <attr/xattr.h>. Man pages also list <sys/xattr.h> as needed header for syscalls getxattr, setxattr, lgetxattr, llistxattr and removexattr.

Well it's not about being common, these headers are part of different libraries. The sys/xattr.h is glibc one while the attr/xattr.h is part of attr library[1].

[1] https://savannah.nongnu.org/projects/attr

And the only difference between these two headers is that the glibc one does not define ENOATTR.

Quoted 5 lines

Currently, related ltp tests are disabled if <attr/xattr.h> is not found during configuration process. This patch allows compilation if <attr/xattr.h> is not present, but <sys/xattr.h> is present. If <sys/xattr.h> is not present, configuration and compilation will remain unchanged.

Hmm, I wonder why we don't default to the glibc header since it's available since glibc 2.3.4 (that is more than ten years old).

And since we do not actually use -llibattr we link agains the glibc anyway. So I guess that the current code is buggy and that we should use the glibc header instead.

So what about to switing to sys/xattr.h instead of cluttering the code with more ifdefs?

Signature · 2 lines
Cyril Hrubis
[email protected]
#2 lore raw

PATCH 1/1 Allow usage of <sys/xattr.h> header.

----- Original Message -----

Quoted 20 lines

From: "Cyril Hrubis" <[email protected]>
To: "Dejan Jovicevic" <[email protected]>
Cc: [email protected]
Sent: Monday, 3 October, 2016 2:19:50 PM
Subject: Re: [LTP] [PATCH] Allow usage of <sys/xattr.h> header.

Hi!

Quoted 3 lines

<sys/xattr.h> is nowdays much more common than <attr/xattr.h>. Man pages also list <sys/xattr.h> as needed header for syscalls getxattr, setxattr, lgetxattr, llistxattr and removexattr.

Well it's not about being common, these headers are part of different libraries. The sys/xattr.h is glibc one while the attr/xattr.h is part of attr library[1].

[1] https://savannah.nongnu.org/projects/attr

And the only difference between these two headers is that the glibc one does not define ENOATTR.

Quoted 8 lines
Quoted 5 lines

Currently, related ltp tests are disabled if <attr/xattr.h> is not found during configuration process. This patch allows compilation if <attr/xattr.h> is not present, but <sys/xattr.h> is present. If <sys/xattr.h> is not present, configuration and compilation will remain unchanged.

Hmm, I wonder why we don't default to the glibc header since it's available since glibc 2.3.4 (that is more than ten years old).

I was wondering that too.

Quoted 7 lines

And since we do not actually use -llibattr we link agains the glibc anyway. So I guess that the current code is buggy and that we should use the glibc header instead.

So what about to switing to sys/xattr.h instead of cluttering the code with more ifdefs?

I ran submitted patch across RHEL5.6/6.0/7.3 on x86 and haven't run into any issues, compile or runtime.

Regards,
Jan

Quoted 8 lines

--
Cyril Hrubis
[email protected]

--
Mailing list info: https://lists.linux.it/listinfo/ltp