Skip to contentSkip to conversation

syscalls/fgetxattr02.c: Fix errno EPERM on older kernels

PATCH New Xiao Yang 2 participants 2 messages Aug 10, 2018 – Aug 16, 2018

lore
Share & tools
lore

Xiao Yang

author
#0 lore raw

PATCH 1/1 syscalls/fgetxattr02.c: Fix errno EPERM on older kernels

According to commit 3d2ae5e in LTP, fgetxattr()/getxattr() will set errno to 'EPERM' when fd/file is not a regular file and directory before kernel 3.0.0. This errno is changed to ENODATA by commit 55b23bd in kernel, so we accept EPERM in older kernels.

---
 testcases/kernel/syscalls/fgetxattr/fgetxattr02.c | 8 ++++++++
 1 file changed, 8 insertions(+)
testcases/kernel/syscalls/fgetxattr/fgetxattr02.c +8 -0
index 98a141b..888e29a 100644
@@ -185,6 +185,14 @@ static void verify_fgetxattr(unsigned int i)
 				tc[i].fname + OFFSET);
 	}
 
+	/*
+	 * Before kernel 3.0.0, fgetxattr(2) will set errno with 'EPERM'
+	 * when the file is not a regular file and directory, refer to
+	 * commitid 55b23bd
+	 */
+	if (tc[i].exp_err == ENODATA && tst_kvercmp(3, 0, 0) < 0)
+		tc[i].exp_err = EPERM;
+
 	if (tc[i].exp_err == TST_ERR) {
 		tst_res(TPASS | TTERRNO, "fgetxattr(2) on %s passed",
 				tc[i].fname + OFFSET);
Signature · 1 line
1.8.3.1