[LTP] [PATCH 3/3] libltpswap: TCONF on EPERM

Petr Vorel pvorel@suse.cz
Wed Oct 11 18:08:22 CEST 2023


Although tests, which use tst_fibmap() should use .needs_root = 1
to avoid EPERM, let's add a sanity check in case it's not used.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 libs/libltpswap/libswap.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/libs/libltpswap/libswap.c b/libs/libltpswap/libswap.c
index a4427736f..4ef24ef5c 100644
--- a/libs/libltpswap/libswap.c
+++ b/libs/libltpswap/libswap.c
@@ -53,10 +53,14 @@ void is_swap_supported(const char *filename)
 
 	TEST(tst_syscall(__NR_swapon, filename, 0));
 	if (TST_RET == -1) {
-		if (fibmap == 1 && errno == EINVAL)
-			tst_brk(TCONF, "Swapfile on %s not implemented", fstype);
-		else
+		if (fibmap == 1) {
+			if (errno == EINVAL)
+				tst_brk(TCONF, "Swapfile on %s not implemented", fstype);
+			if (errno == EPERM)
+				tst_brk(TCONF, "No permission for swapon() on %s", fstype);
+		} else {
 			tst_brk(TFAIL | TTERRNO, "swapon on %s failed", fstype);
+		}
 	}
 
 	TEST(tst_syscall(__NR_swapoff, filename, 0));
-- 
2.42.0



More information about the ltp mailing list