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

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