2014-02-06 09:17:12 +01:00
|
|
|
---
|
2016-02-03 10:19:12 +01:00
|
|
|
rules/99-systemd.rules.in | 2 -
|
|
|
|
src/basic/terminal-util.c | 55 ++++++++++++++++++++++++++++++++++++++++++++--
|
2015-09-27 14:32:31 +02:00
|
|
|
src/basic/terminal-util.h | 1
|
2016-02-03 10:19:12 +01:00
|
|
|
src/core/manager.c | 24 +++++++++++++++-----
|
|
|
|
4 files changed, 74 insertions(+), 8 deletions(-)
|
2014-05-10 08:32:24 +02:00
|
|
|
|
2014-02-06 09:17:12 +01:00
|
|
|
|
2016-02-03 10:19:12 +01:00
|
|
|
Index: systemd-228/rules/99-systemd.rules.in
|
2015-03-27 09:39:40 +01:00
|
|
|
===================================================================
|
2016-02-03 10:19:12 +01:00
|
|
|
--- systemd-228.orig/rules/99-systemd.rules.in
|
|
|
|
+++ systemd-228/rules/99-systemd.rules.in
|
2014-02-06 09:17:12 +01:00
|
|
|
@@ -7,7 +7,7 @@
|
|
|
|
|
|
|
|
ACTION=="remove", GOTO="systemd_end"
|
|
|
|
|
2015-03-27 09:39:40 +01:00
|
|
|
-SUBSYSTEM=="tty", KERNEL=="tty[a-zA-Z]*|hvc*|xvc*|hvsi*|ttysclp*|sclp_line*|3270/tty[0-9]*", TAG+="systemd"
|
2014-02-06 09:17:12 +01:00
|
|
|
+SUBSYSTEM=="tty", KERNEL=="tty[a-zA-Z]*|hvc*|xvc*|hvsi*|ttysclp*|sclp_line*|3270/tty*", TAG+="systemd"
|
|
|
|
KERNEL=="vport*", TAG+="systemd"
|
|
|
|
|
2015-09-27 14:32:31 +02:00
|
|
|
SUBSYSTEM=="block", TAG+="systemd"
|
2016-02-03 10:19:12 +01:00
|
|
|
Index: systemd-228/src/basic/terminal-util.c
|
2015-03-27 09:39:40 +01:00
|
|
|
===================================================================
|
2016-02-03 10:19:12 +01:00
|
|
|
--- systemd-228.orig/src/basic/terminal-util.c
|
|
|
|
+++ systemd-228/src/basic/terminal-util.c
|
|
|
|
@@ -717,10 +717,47 @@ bool tty_is_vc_resolve(const char *tty)
|
2015-09-27 14:32:31 +02:00
|
|
|
return tty_is_vc(tty);
|
2015-03-27 09:39:40 +01:00
|
|
|
}
|
2014-05-02 20:51:24 +02:00
|
|
|
|
|
|
|
+bool ansi_console(int fd) {
|
|
|
|
+ static int cached_ansi_console = -1;
|
|
|
|
+
|
2015-09-27 14:32:31 +02:00
|
|
|
+ if (_likely_(cached_ansi_console >= 0))
|
|
|
|
+ return cached_ansi_console;
|
2014-05-02 20:51:24 +02:00
|
|
|
+
|
2015-09-27 14:32:31 +02:00
|
|
|
+ cached_ansi_console = isatty(fd) > 0;
|
|
|
|
+#if defined(__s390__) || defined(__s390x__)
|
|
|
|
+ if (cached_ansi_console) {
|
|
|
|
+ const char *e = getenv("TERM");
|
|
|
|
+ if (e != NULL && (streq(e, "dumb") || strneq(e, "ibm3", 4))) {
|
|
|
|
+ _cleanup_free_ char *mode = NULL;
|
|
|
|
+ int r = parse_env_file("/proc/cmdline", WHITESPACE,
|
|
|
|
+ "conmode", &mode, NULL);
|
|
|
|
+ if (r < 0 || mode == NULL || !streq(mode, "3270"))
|
|
|
|
+ cached_ansi_console = 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+#endif
|
2014-05-02 20:51:24 +02:00
|
|
|
+ return cached_ansi_console;
|
|
|
|
+}
|
|
|
|
+
|
2014-05-10 08:32:24 +02:00
|
|
|
const char *default_term_for_tty(const char *tty) {
|
|
|
|
assert(tty);
|
|
|
|
|
2015-03-27 09:39:40 +01:00
|
|
|
- return tty_is_vc_resolve(tty) ? "TERM=linux" : "TERM=vt220";
|
2014-05-10 08:32:24 +02:00
|
|
|
+ if (tty_is_vc_resolve(tty))
|
|
|
|
+ return "TERM=linux";
|
|
|
|
+ if (startswith(tty, "/dev/"))
|
|
|
|
+ tty += 5;
|
|
|
|
+#if defined (__s390__) || defined (__s390x__)
|
2015-09-27 14:32:31 +02:00
|
|
|
+ if (streq(tty, "ttyS0")) {
|
|
|
|
+ _cleanup_free_ char *mode = NULL;
|
|
|
|
+ int r = parse_env_file("/proc/cmdline", WHITESPACE, "conmode",
|
|
|
|
+ &mode, NULL);
|
|
|
|
+ if (r < 0 || mode == NULL || !streq(mode, "3270"))
|
2014-05-10 08:32:24 +02:00
|
|
|
+ return "TERM=dumb";
|
|
|
|
+ if (streq(mode, "3270"))
|
|
|
|
+ return "TERM=ibm327x";
|
2015-09-27 14:32:31 +02:00
|
|
|
+ }
|
2014-05-10 08:32:24 +02:00
|
|
|
+#endif
|
2015-03-27 09:39:40 +01:00
|
|
|
+ return "TERM=vt220";
|
2014-05-10 08:32:24 +02:00
|
|
|
}
|
|
|
|
|
2015-09-27 14:32:31 +02:00
|
|
|
int fd_columns(int fd) {
|
2016-02-03 10:19:12 +01:00
|
|
|
@@ -800,8 +837,22 @@ void columns_lines_cache_reset(int signu
|
2015-09-27 14:32:31 +02:00
|
|
|
bool on_tty(void) {
|
|
|
|
static int cached_on_tty = -1;
|
|
|
|
|
|
|
|
- if (_unlikely_(cached_on_tty < 0))
|
|
|
|
+ if (_unlikely_(cached_on_tty < 0)) {
|
|
|
|
cached_on_tty = isatty(STDOUT_FILENO) > 0;
|
|
|
|
+#if defined (__s390__) || defined (__s390x__)
|
|
|
|
+ if (cached_on_tty) {
|
|
|
|
+ const char *e = getenv("TERM");
|
|
|
|
+ if (!e)
|
|
|
|
+ return cached_on_tty;
|
|
|
|
+ if (streq(e, "dumb") || strneq(e, "ibm3", 4)) {
|
|
|
|
+ char *mode = NULL;
|
|
|
|
+ int r = parse_env_file("/proc/cmdline", WHITESPACE, "conmode", &mode, NULL);
|
|
|
|
+ if (r < 0 || !mode || !streq(mode, "3270"))
|
|
|
|
+ cached_on_tty = 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
+ }
|
|
|
|
|
|
|
|
return cached_on_tty;
|
|
|
|
}
|
2016-02-03 10:19:12 +01:00
|
|
|
Index: systemd-228/src/basic/terminal-util.h
|
2015-03-27 09:39:40 +01:00
|
|
|
===================================================================
|
2016-02-03 10:19:12 +01:00
|
|
|
--- systemd-228.orig/src/basic/terminal-util.h
|
|
|
|
+++ systemd-228/src/basic/terminal-util.h
|
|
|
|
@@ -78,6 +78,7 @@ unsigned lines(void);
|
2014-05-02 20:51:24 +02:00
|
|
|
void columns_lines_cache_reset(int _unused_ signum);
|
|
|
|
|
|
|
|
bool on_tty(void);
|
|
|
|
+bool ansi_console(int fd);
|
|
|
|
|
2016-02-03 10:19:12 +01:00
|
|
|
static inline const char *ansi_underline(void) {
|
|
|
|
return on_tty() ? ANSI_UNDERLINE : "";
|
|
|
|
Index: systemd-228/src/core/manager.c
|
2015-09-27 14:32:31 +02:00
|
|
|
===================================================================
|
2016-02-03 10:19:12 +01:00
|
|
|
--- systemd-228.orig/src/core/manager.c
|
|
|
|
+++ systemd-228/src/core/manager.c
|
|
|
|
@@ -126,7 +126,7 @@ static void manager_watch_jobs_in_progre
|
2015-09-27 14:32:31 +02:00
|
|
|
|
2016-02-03 10:19:12 +01:00
|
|
|
#define CYLON_BUFFER_EXTRA (2*(sizeof(ANSI_RED)-1) + sizeof(ANSI_HIGHLIGHT_RED)-1 + 2*(sizeof(ANSI_NORMAL)-1))
|
2015-09-27 14:32:31 +02:00
|
|
|
|
|
|
|
-static void draw_cylon(char buffer[], size_t buflen, unsigned width, unsigned pos) {
|
|
|
|
+static void draw_cylon(char buffer[], size_t buflen, unsigned width, unsigned pos, bool ansi_console) {
|
|
|
|
char *p = buffer;
|
|
|
|
|
|
|
|
assert(buflen >= CYLON_BUFFER_EXTRA + width + 1);
|
2016-02-03 10:19:12 +01:00
|
|
|
@@ -135,12 +135,14 @@ static void draw_cylon(char buffer[], si
|
2015-09-27 14:32:31 +02:00
|
|
|
if (pos > 1) {
|
|
|
|
if (pos > 2)
|
|
|
|
p = mempset(p, ' ', pos-2);
|
2016-02-03 10:19:12 +01:00
|
|
|
- p = stpcpy(p, ANSI_RED);
|
2015-09-27 14:32:31 +02:00
|
|
|
+ if (ansi_console)
|
2016-02-03 10:19:12 +01:00
|
|
|
+ p = stpcpy(p, ANSI_RED);
|
2015-09-27 14:32:31 +02:00
|
|
|
*p++ = '*';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pos > 0 && pos <= width) {
|
2016-02-03 10:19:12 +01:00
|
|
|
- p = stpcpy(p, ANSI_HIGHLIGHT_RED);
|
2015-09-27 14:32:31 +02:00
|
|
|
+ if (ansi_console)
|
2016-02-03 10:19:12 +01:00
|
|
|
+ p = stpcpy(p, ANSI_HIGHLIGHT_RED);
|
2015-09-27 14:32:31 +02:00
|
|
|
*p++ = '*';
|
|
|
|
}
|
|
|
|
|
2016-02-03 10:19:12 +01:00
|
|
|
@@ -151,7 +153,8 @@ static void draw_cylon(char buffer[], si
|
2015-09-27 14:32:31 +02:00
|
|
|
*p++ = '*';
|
|
|
|
if (pos < width-1)
|
|
|
|
p = mempset(p, ' ', width-1-pos);
|
2016-02-03 10:19:12 +01:00
|
|
|
- strcpy(p, ANSI_NORMAL);
|
2015-09-27 14:32:31 +02:00
|
|
|
+ if (ansi_console)
|
2016-02-03 10:19:12 +01:00
|
|
|
+ strcpy(p, ANSI_NORMAL);
|
2015-09-27 14:32:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-03 10:19:12 +01:00
|
|
|
@@ -168,6 +171,7 @@ void manager_flip_auto_status(Manager *m
|
2015-09-27 14:32:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void manager_print_jobs_in_progress(Manager *m) {
|
|
|
|
+ static int is_ansi_console = -1;
|
|
|
|
_cleanup_free_ char *job_of_n = NULL;
|
|
|
|
Iterator i;
|
|
|
|
Job *j;
|
2016-02-03 10:19:12 +01:00
|
|
|
@@ -193,10 +197,20 @@ static void manager_print_jobs_in_progre
|
2015-09-27 14:32:31 +02:00
|
|
|
assert(counter == print_nr + 1);
|
|
|
|
assert(j);
|
|
|
|
|
|
|
|
+ if (_unlikely_(is_ansi_console < 0)) {
|
|
|
|
+ int fd = open_terminal("/dev/console", O_RDONLY|O_NOCTTY|O_CLOEXEC);
|
|
|
|
+ if (fd < 0)
|
|
|
|
+ is_ansi_console = 0;
|
|
|
|
+ else {
|
|
|
|
+ is_ansi_console = (int)ansi_console(fd);
|
|
|
|
+ close(fd);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
cylon_pos = m->jobs_in_progress_iteration % 14;
|
|
|
|
if (cylon_pos >= 8)
|
|
|
|
cylon_pos = 14 - cylon_pos;
|
|
|
|
- draw_cylon(cylon, sizeof(cylon), 6, cylon_pos);
|
|
|
|
+ draw_cylon(cylon, sizeof(cylon), 6, cylon_pos, (bool)is_ansi_console);
|
|
|
|
|
|
|
|
m->jobs_in_progress_iteration++;
|
|
|
|
|