fix getxattr02 case with errno EPERM
Before kernel 3.0.0, getxattr02 will set errno with 'EPERM' when the file is
not a regular file and directory.
Refer to commit: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commit;h=55b23bde19c08f14127a27d461a4e079942c7258
Signed-off-by: Peng Haitao <penght@cn.fujitsu.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Reviewed-by: Eryu Guan <eguan@redhat.com>
diff --git a/testcases/kernel/syscalls/getxattr/getxattr02.c b/testcases/kernel/syscalls/getxattr/getxattr02.c
index 54d8949..eb48996 100644
--- a/testcases/kernel/syscalls/getxattr/getxattr02.c
+++ b/testcases/kernel/syscalls/getxattr/getxattr02.c
@@ -78,6 +78,7 @@
{
int lc;
int i;
+ int exp_eno;
char *msg;
char buf[BUFSIZ];
@@ -90,15 +91,24 @@
for (lc = 0; TEST_LOOPING(lc); lc++) {
Tst_count = 0;
+ /*
+ * Before kernel 3.0.0, getxattr(2) will set errno with 'EPERM'
+ * when the file is not a regular file and directory, refer to
+ * commitid 55b23bd
+ */
+ if (tst_kvercmp(3, 0, 0) >= 0)
+ exp_eno = ENODATA;
+ else
+ exp_eno = EPERM;
+
for (i = 0; i < TST_TOTAL; i++) {
TEST(getxattr(tc[0], XATTR_TEST_KEY, buf, BUFSIZ));
- if (TEST_RETURN == -1 && TEST_ERRNO == ENODATA) {
+ if (TEST_RETURN == -1 && TEST_ERRNO == exp_eno)
tst_resm(TPASS | TTERRNO, "expected behavior");
- } else {
+ else
tst_resm(TFAIL | TTERRNO, "unexpected behavior"
- " - expected errno %d - Got", ENODATA);
- }
+ " - expected errno %d - Got", exp_eno);
}
}