anitazha / rpms / systemd

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