2014-01-31 15:28:44 +01:00
|
|
|
---
|
2014-05-07 11:24:23 +02:00
|
|
|
rules/99-systemd.rules.in | 2
|
|
|
|
src/core/manager.c | 24 ++++++++--
|
|
|
|
src/shared/util.c | 101 ++++++++++++++++++++++++++++++++++++++++++++--
|
2014-04-30 12:57:26 +02:00
|
|
|
src/shared/util.h | 1
|
2014-05-07 11:24:23 +02:00
|
|
|
4 files changed, 118 insertions(+), 10 deletions(-)
|
|
|
|
|
2014-01-31 15:28:44 +01:00
|
|
|
|
2015-02-13 10:43:21 +01:00
|
|
|
Index: systemd-218/rules/99-systemd.rules.in
|
|
|
|
===================================================================
|
|
|
|
--- systemd-218.orig/rules/99-systemd.rules.in
|
|
|
|
+++ systemd-218/rules/99-systemd.rules.in
|
2014-02-05 12:33:45 +01:00
|
|
|
@@ -7,7 +7,7 @@
|
|
|
|
|
|
|
|
ACTION=="remove", GOTO="systemd_end"
|
|
|
|
|
2015-02-13 10:43:21 +01:00
|
|
|
-SUBSYSTEM=="tty", KERNEL=="tty[a-zA-Z]*|hvc*|xvc*|hvsi*|ttysclp*|sclp_line*|3270/tty[0-9]*", TAG+="systemd"
|
2014-02-05 12:33:45 +01:00
|
|
|
+SUBSYSTEM=="tty", KERNEL=="tty[a-zA-Z]*|hvc*|xvc*|hvsi*|ttysclp*|sclp_line*|3270/tty*", TAG+="systemd"
|
|
|
|
|
|
|
|
KERNEL=="vport*", TAG+="systemd"
|
|
|
|
|
2015-02-13 10:43:21 +01:00
|
|
|
Index: systemd-218/src/core/manager.c
|
|
|
|
===================================================================
|
|
|
|
--- systemd-218.orig/src/core/manager.c
|
|
|
|
+++ systemd-218/src/core/manager.c
|
2014-04-30 12:57:26 +02:00
|
|
|
@@ -110,7 +110,7 @@ static int manager_watch_jobs_in_progres
|
|
|
|
|
|
|
|
#define CYLON_BUFFER_EXTRA (2*(sizeof(ANSI_RED_ON)-1) + sizeof(ANSI_HIGHLIGHT_RED_ON)-1 + 2*(sizeof(ANSI_HIGHLIGHT_OFF)-1))
|
|
|
|
|
|
|
|
-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);
|
|
|
|
@@ -119,12 +119,14 @@ static void draw_cylon(char buffer[], si
|
|
|
|
if (pos > 1) {
|
|
|
|
if (pos > 2)
|
|
|
|
p = mempset(p, ' ', pos-2);
|
|
|
|
- p = stpcpy(p, ANSI_RED_ON);
|
|
|
|
+ if (ansi_console)
|
|
|
|
+ p = stpcpy(p, ANSI_RED_ON);
|
|
|
|
*p++ = '*';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pos > 0 && pos <= width) {
|
|
|
|
- p = stpcpy(p, ANSI_HIGHLIGHT_RED_ON);
|
|
|
|
+ if (ansi_console)
|
|
|
|
+ p = stpcpy(p, ANSI_HIGHLIGHT_RED_ON);
|
|
|
|
*p++ = '*';
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -135,7 +137,8 @@ static void draw_cylon(char buffer[], si
|
|
|
|
*p++ = '*';
|
|
|
|
if (pos < width-1)
|
|
|
|
p = mempset(p, ' ', width-1-pos);
|
|
|
|
- strcpy(p, ANSI_HIGHLIGHT_OFF);
|
|
|
|
+ if (ansi_console)
|
|
|
|
+ strcpy(p, ANSI_HIGHLIGHT_OFF);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-13 10:43:21 +01:00
|
|
|
@@ -152,6 +155,7 @@ void manager_flip_auto_status(Manager *m
|
2014-04-30 12:57:26 +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;
|
2015-02-13 10:43:21 +01:00
|
|
|
@@ -176,10 +180,20 @@ static void manager_print_jobs_in_progre
|
2014-04-30 12:57:26 +02:00
|
|
|
assert(counter == print_nr + 1);
|
|
|
|
assert(j);
|
|
|
|
|
|
|
|
+ if (_unlikely_(is_ansi_console < 0)) {
|
2014-04-30 17:02:31 +02:00
|
|
|
+ int fd = open_terminal("/dev/console", O_RDONLY|O_NOCTTY|O_CLOEXEC);
|
2014-04-30 12:57:26 +02:00
|
|
|
+ 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++;
|
|
|
|
|
2015-02-13 10:43:21 +01:00
|
|
|
Index: systemd-218/src/shared/util.c
|
|
|
|
===================================================================
|
|
|
|
--- systemd-218.orig/src/shared/util.c
|
|
|
|
+++ systemd-218/src/shared/util.c
|
|
|
|
@@ -3182,6 +3182,7 @@ int status_vprintf(const char *status, b
|
2014-01-30 13:35:04 +01:00
|
|
|
struct iovec iovec[6] = {};
|
|
|
|
int n = 0;
|
|
|
|
static bool prev_ephemeral;
|
2014-04-30 12:57:26 +02:00
|
|
|
+ static int is_ansi_console = -1;
|
2014-01-30 13:35:04 +01:00
|
|
|
|
|
|
|
assert(format);
|
|
|
|
|
2015-02-13 10:43:21 +01:00
|
|
|
@@ -3195,6 +3196,41 @@ int status_vprintf(const char *status, b
|
2014-01-30 13:35:04 +01:00
|
|
|
if (fd < 0)
|
|
|
|
return fd;
|
|
|
|
|
2014-04-30 12:57:26 +02:00
|
|
|
+ if (_unlikely_(is_ansi_console < 0))
|
2015-02-13 10:43:21 +01:00
|
|
|
+ is_ansi_console = ansi_console(fd);
|
2014-01-30 13:35:04 +01:00
|
|
|
+
|
2014-04-30 12:57:26 +02:00
|
|
|
+ if (status && !is_ansi_console) {
|
2014-01-30 13:35:04 +01:00
|
|
|
+ const char *esc, *ptr;
|
|
|
|
+ esc = strchr(status, 0x1B);
|
|
|
|
+ if (esc && (ptr = strpbrk(esc, "SOFDTI*"))) {
|
|
|
|
+ switch(*ptr) {
|
|
|
|
+ case 'S':
|
|
|
|
+ status = " SKIP ";
|
|
|
|
+ break;
|
|
|
|
+ case 'O':
|
|
|
|
+ status = " OK ";
|
|
|
|
+ break;
|
|
|
|
+ case 'F':
|
|
|
|
+ status = "FAILED";
|
|
|
|
+ break;
|
|
|
|
+ case 'D':
|
|
|
|
+ status = "DEPEND";
|
|
|
|
+ break;
|
|
|
|
+ case 'T':
|
|
|
|
+ status = " TIME ";
|
|
|
|
+ break;
|
|
|
|
+ case 'I':
|
|
|
|
+ status = " INFO ";
|
|
|
|
+ break;
|
|
|
|
+ case '*':
|
|
|
|
+ status = " BUSY ";
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
if (ellipse) {
|
|
|
|
char *e;
|
|
|
|
size_t emax, sl;
|
2015-02-13 10:43:21 +01:00
|
|
|
@@ -3217,8 +3253,12 @@ int status_vprintf(const char *status, b
|
2014-01-30 13:35:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (prev_ephemeral)
|
|
|
|
- IOVEC_SET_STRING(iovec[n++], "\r" ANSI_ERASE_TO_END_OF_LINE);
|
|
|
|
+ if (prev_ephemeral) {
|
2014-04-30 12:57:26 +02:00
|
|
|
+ if (is_ansi_console)
|
2014-01-30 13:35:04 +01:00
|
|
|
+ IOVEC_SET_STRING(iovec[n++], "\r" ANSI_ERASE_TO_END_OF_LINE);
|
|
|
|
+ else
|
|
|
|
+ IOVEC_SET_STRING(iovec[n++], "\r");
|
|
|
|
+ }
|
|
|
|
prev_ephemeral = ephemeral;
|
|
|
|
|
|
|
|
if (status) {
|
2015-02-13 10:43:21 +01:00
|
|
|
@@ -3474,8 +3514,22 @@ void columns_lines_cache_reset(int signu
|
2014-01-30 13:35:04 +01: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;
|
2014-05-07 11:24:23 +02:00
|
|
|
+#if defined (__s390__) || defined (__s390x__)
|
2014-01-30 13:35:04 +01:00
|
|
|
+ if (cached_on_tty) {
|
|
|
|
+ const char *e = getenv("TERM");
|
2014-04-30 12:57:26 +02:00
|
|
|
+ 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;
|
|
|
|
+ }
|
2014-01-30 13:35:04 +01:00
|
|
|
+ }
|
2014-05-07 11:24:23 +02:00
|
|
|
+#endif
|
2014-01-30 13:35:04 +01:00
|
|
|
+ }
|
|
|
|
|
|
|
|
return cached_on_tty;
|
|
|
|
}
|
2015-02-13 10:43:21 +01:00
|
|
|
@@ -3493,6 +3547,27 @@ int files_same(const char *filea, const
|
|
|
|
a.st_ino == b.st_ino;
|
|
|
|
}
|
2014-04-30 12:57:26 +02:00
|
|
|
|
|
|
|
+bool ansi_console(int fd) {
|
|
|
|
+ static int cached_ansi_console = -1;
|
|
|
|
+
|
|
|
|
+ if (_unlikely_(cached_ansi_console < 0)) {
|
|
|
|
+ cached_ansi_console = isatty(fd) > 0;
|
2014-05-07 11:24:23 +02:00
|
|
|
+#if defined (__s390__) || defined (__s390x__)
|
2014-04-30 12:57:26 +02:00
|
|
|
+ if (cached_ansi_console) {
|
|
|
|
+ const char *e = getenv("TERM");
|
|
|
|
+ if (e && (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_ansi_console = 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
2014-05-07 11:24:23 +02:00
|
|
|
+#endif
|
2014-04-30 12:57:26 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return cached_ansi_console;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
int running_in_chroot(void) {
|
2015-02-13 10:43:21 +01:00
|
|
|
int ret;
|
2014-04-30 12:57:26 +02:00
|
|
|
|
2015-02-13 10:43:21 +01:00
|
|
|
@@ -3976,7 +4051,25 @@ bool tty_is_vc_resolve(const char *tty)
|
2014-05-07 11:24:23 +02:00
|
|
|
const char *default_term_for_tty(const char *tty) {
|
|
|
|
assert(tty);
|
|
|
|
|
|
|
|
- return tty_is_vc_resolve(tty) ? "TERM=linux" : "TERM=vt102";
|
|
|
|
+ if (tty_is_vc_resolve(tty))
|
|
|
|
+ return "TERM=linux";
|
|
|
|
+
|
|
|
|
+ if (startswith(tty, "/dev/"))
|
|
|
|
+ tty += 5;
|
|
|
|
+
|
|
|
|
+#if defined (__s390__) || defined (__s390x__)
|
|
|
|
+ if (streq(tty, "ttyS0")) {
|
|
|
|
+ char *mode = NULL;
|
|
|
|
+ int r = parse_env_file("/proc/cmdline", WHITESPACE, "conmode", &mode, NULL);
|
|
|
|
+ if (r < 0 || !mode || !streq(mode, "3270"))
|
|
|
|
+ return "TERM=dumb";
|
|
|
|
+ if (streq(mode, "3270"))
|
|
|
|
+ return "TERM=ibm327x";
|
|
|
|
+ }
|
|
|
|
+ if (streq(tty, "ttyS1"))
|
|
|
|
+ return "TERM=vt220";
|
|
|
|
+#endif
|
|
|
|
+ return "TERM=vt102";
|
|
|
|
}
|
|
|
|
|
|
|
|
bool dirent_is_file(const struct dirent *de) {
|
2015-02-13 10:43:21 +01:00
|
|
|
Index: systemd-218/src/shared/util.h
|
|
|
|
===================================================================
|
|
|
|
--- systemd-218.orig/src/shared/util.h
|
|
|
|
+++ systemd-218/src/shared/util.h
|
|
|
|
@@ -474,6 +474,7 @@ unsigned lines(void);
|
2014-04-30 12:57:26 +02:00
|
|
|
void columns_lines_cache_reset(int _unused_ signum);
|
|
|
|
|
|
|
|
bool on_tty(void);
|
|
|
|
+bool ansi_console(int fd);
|
|
|
|
|
|
|
|
static inline const char *ansi_highlight(void) {
|
|
|
|
return on_tty() ? ANSI_HIGHLIGHT_ON : "";
|