valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

Blame SOURCES/0291-s390-add-personality-support.patch

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