naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
923a60
From 9435bd3d692c7b07e527b6a616018fa5620502e2 Mon Sep 17 00:00:00 2001
923a60
From: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
923a60
Date: Thu, 24 Sep 2015 12:47:22 +0200
923a60
Subject: [PATCH] s390: add personality support
923a60
923a60
Introduce personality support for Linux on z Systems to run
923a60
particular services with a 64-bit or 31-bit personality.
923a60
923a60
Cherry-picked from: 7517f51ef9921d3360453c8eec2c97256d320ceb
923a60
Resolves: #1300344
923a60
---
923a60
 Makefile.am                        |  1 +
923a60
 src/shared/util.c                  | 27 +++++++++++++++++++++++++++
923a60
 src/test/test-execute.c            |  8 ++++++--
923a60
 test/exec-personality-s390.service |  7 +++++++
923a60
 4 files changed, 41 insertions(+), 2 deletions(-)
923a60
 create mode 100644 test/exec-personality-s390.service
923a60
923a60
diff --git a/Makefile.am b/Makefile.am
923a60
index 255937643e..3af720bdae 100644
923a60
--- a/Makefile.am
923a60
+++ b/Makefile.am
923a60
@@ -1483,6 +1483,7 @@ EXTRA_DIST += \
923a60
 	test/exec-ignoresigpipe-yes.service \
923a60
 	test/exec-personality-x86-64.service \
923a60
 	test/exec-personality-x86.service \
923a60
+	test/exec-personality-s390.service \
923a60
 	test/exec-privatedevices-no.service \
923a60
 	test/exec-privatedevices-yes.service \
923a60
 	test/exec-privatetmp-no.service \
923a60
diff --git a/src/shared/util.c b/src/shared/util.c
923a60
index dc51852699..a24aa7f93a 100644
923a60
--- a/src/shared/util.c
923a60
+++ b/src/shared/util.c
923a60
@@ -6748,6 +6748,19 @@ unsigned long personality_from_string(const char *p) {
923a60
 
923a60
         if (streq(p, "x86"))
923a60
                 return PER_LINUX;
923a60
+
923a60
+#elif defined(__s390x__)
923a60
+
923a60
+        if (streq(p, "s390"))
923a60
+                return PER_LINUX32;
923a60
+
923a60
+        if (streq(p, "s390x"))
923a60
+                return PER_LINUX;
923a60
+
923a60
+#elif defined(__s390__)
923a60
+
923a60
+        if (streq(p, "s390"))
923a60
+                return PER_LINUX;
923a60
 #endif
923a60
 
923a60
         /* personality(7) documents that 0xffffffffUL is used for
923a60
@@ -6770,6 +6783,20 @@ const char* personality_to_string(unsigned long p) {
923a60
 
923a60
         if (p == PER_LINUX)
923a60
                 return "x86";
923a60
+
923a60
+#elif defined(__s390x__)
923a60
+
923a60
+        if (p == PER_LINUX)
923a60
+                return "s390x";
923a60
+
923a60
+        if (p == PER_LINUX32)
923a60
+                return "s390";
923a60
+
923a60
+#elif defined(__s390__)
923a60
+
923a60
+        if (p == PER_LINUX)
923a60
+                return "s390";
923a60
+
923a60
 #endif
923a60
 
923a60
         return NULL;
923a60
diff --git a/src/test/test-execute.c b/src/test/test-execute.c
923a60
index 91ccaf72b8..00f3607b49 100644
923a60
--- a/src/test/test-execute.c
923a60
+++ b/src/test/test-execute.c
923a60
@@ -77,10 +77,14 @@ static void test_exec_workingdirectory(Manager *m) {
923a60
 }
923a60
 
923a60
 static void test_exec_personality(Manager *m) {
923a60
-        test(m, "exec-personality-x86.service", 0, CLD_EXITED);
923a60
-
923a60
 #if defined(__x86_64__)
923a60
         test(m, "exec-personality-x86-64.service", 0, CLD_EXITED);
923a60
+
923a60
+#elif defined(__s390__)
923a60
+        test(m, "exec-personality-s390.service", 0, CLD_EXITED);
923a60
+
923a60
+#else
923a60
+        test(m, "exec-personality-x86.service", 0, CLD_EXITED);
923a60
 #endif
923a60
 }
923a60
 
923a60
diff --git a/test/exec-personality-s390.service b/test/exec-personality-s390.service
923a60
new file mode 100644
923a60
index 0000000000..f3c3b03e3d
923a60
--- /dev/null
923a60
+++ b/test/exec-personality-s390.service
923a60
@@ -0,0 +1,7 @@
923a60
+[Unit]
923a60
+Description=Test for Personality=s390
923a60
+
923a60
+[Service]
923a60
+ExecStart=/bin/sh -c 'echo $(uname -m); exit $(test $(uname -m) = "s390")'
923a60
+Type=oneshot
923a60
+Personality=s390