Blame SOURCES/0002-stress-shm-skip-stressor-if-dev-shm-is-not-mounted-w.patch

96132e
From f424f5b774b7cb0fd7939d28e68db6fa977baea1 Mon Sep 17 00:00:00 2001
96132e
From: Colin Ian King <colin.i.king@gmail.com>
96132e
Date: Mon, 21 Nov 2022 12:45:11 +0000
96132e
Subject: [PATCH 2/3] stress-shm: skip stressor if /dev/shm is not mounted with
96132e
 tmpfs on linux
96132e
96132e
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
96132e
---
96132e
 stress-shm.c | 12 ++++++++++++
96132e
 1 file changed, 12 insertions(+)
96132e
96132e
diff --git a/stress-shm.c b/stress-shm.c
96132e
index 91bcd961aeb1..4e6327ac97d4 100644
96132e
--- a/stress-shm.c
96132e
+++ b/stress-shm.c
96132e
@@ -122,6 +122,18 @@ static int stress_shm_posix_child(
96132e
 	const size_t page_size = args->page_size;
96132e
 	struct sigaction sa;
96132e
 
96132e
+#if defined(__linux__)
96132e
+	/*
96132e
+	 *  /dev/shm should be mounted with tmpfs and
96132e
+	 *  be writeable, if not shm_open will fail
96132e
+	 */
96132e
+	if (access("/dev/shm", W_OK) < 0) {
96132e
+		pr_inf("%s: cannot access /dev/shm for writes, errno=%d (%s) skipping stressor\n",
96132e
+			args->name, errno, strerror(errno));
96132e
+		return EXIT_NO_RESOURCE;
96132e
+	}
96132e
+#endif
96132e
+
96132e
 	addrs = calloc(shm_posix_objects, sizeof(*addrs));
96132e
 	if (!addrs) {
96132e
 		pr_fail("%s: calloc on addrs failed, out of memory\n", args->name);
96132e
-- 
96132e
2.38.1
96132e