Add tool to display emergency log message full-screen on boot failure.

This commit is contained in:
OMOJOLA JOSHUA
2023-08-04 00:24:54 +01:00
committed by Luca Boccassi
parent 5a087ba25c
commit fc7eb1325b
8 changed files with 505 additions and 35 deletions
+15
View File
@@ -1535,3 +1535,18 @@ void get_log_colors(int priority, const char **on, const char **off, const char
*highlight = ansi_highlight_red();
}
}
int set_terminal_cursor_position(int fd, unsigned int row, unsigned int column) {
int r;
char cursor_position[STRLEN("\x1B[") + DECIMAL_STR_MAX(int) * 2 + STRLEN(";H") + 1];
assert(fd >= 0);
xsprintf(cursor_position, "\x1B[%u;%uH", row, column);
r = loop_write(fd, cursor_position, SIZE_MAX, /* do_poll = */false);
if (r < 0)
return log_warning_errno(r, "Failed to set cursor position, ignoring: %m");
return 0;
}
+4
View File
@@ -68,6 +68,9 @@
#define ANSI_HIGHLIGHT_YELLOW_FALLBACK "\x1B[0;1;33m"
#define ANSI_HIGHLIGHT_YELLOW_FALLBACK_UNDERLINE "\x1B[0;1;4;33m"
/* Background colors */
#define ANSI_BACKGROUND_BLUE "\x1B[44m"
/* Reset/clear ANSI styles */
#define ANSI_NORMAL "\x1B[0m"
@@ -82,6 +85,7 @@
int reset_terminal_fd(int fd, bool switch_to_text);
int reset_terminal(const char *name);
int set_terminal_cursor_position(int fd, unsigned int row, unsigned int column);
int open_terminal(const char *name, int mode);