[LTP] [PATCH 6/11 v2] mmap/mmap12: Testcase failed for non-root user

Cui Bixuan cuibixuan@huawei.com
Tue Nov 3 09:01:22 CET 2015


Unprivileged user open /proc/self/pagemap fail so add check for it

Signed-off-by: Cui Bixuan <cuibixuan@huawei.com>
---
 testcases/kernel/syscalls/mmap/mmap12.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/mmap/mmap12.c b/testcases/kernel/syscalls/mmap/mmap12.c
index ba8c646..ebc44ae 100644
--- a/testcases/kernel/syscalls/mmap/mmap12.c
+++ b/testcases/kernel/syscalls/mmap/mmap12.c
@@ -108,8 +108,14 @@ static int page_check(void)
 	index = (vmstart / page_sz) * sizeof(uint64_t);

 	pm = open("/proc/self/pagemap", O_RDONLY);
-	if (pm == -1)
-		tst_brkm(TFAIL | TERRNO, NULL, "Open dev pagemap failed");
+	if (pm == -1) {
+		if ((0 != geteuid()) && (errno == EPERM))
+			tst_brkm(TCONF | TERRNO, NULL,
+				"don't have permission to open dev pagemap");
+		else
+			tst_brkm(TFAIL | TERRNO, NULL,
+				"Open dev pagemap failed");
+	}

 	offset = lseek(pm, index, SEEK_SET);
 	if (offset != index)
-- 
1.6.0.2


More information about the Ltp mailing list