if (!do_reset)
return 0;
- if ((tty_fd = open_terminal("/dev/console", O_WRONLY|O_NOCTTY|O_CLOEXEC)) < 0) {
+ tty_fd = open_terminal("/dev/console", O_WRONLY|O_NOCTTY|O_CLOEXEC);
+ if (tty_fd < 0) {
log_error("Failed to open /dev/console: %s", strerror(-tty_fd));
return -tty_fd;
}
- if ((r = reset_terminal_fd(tty_fd)) < 0)
+ /* We don't want to force text mode.
+ * plymouth may be showing pictures already from initrd. */
+ r = reset_terminal_fd(tty_fd, false);
+ if (r < 0)
log_error("Failed to reset /dev/console: %s", strerror(-r));
close_nointr_nofail(tty_fd);
}
}
-int reset_terminal_fd(int fd) {
+int reset_terminal_fd(int fd, bool switch_to_text) {
struct termios termios;
int r = 0;
ioctl(fd, TIOCNXCL);
/* Switch to text mode */
- ioctl(fd, KDSETMODE, KD_TEXT);
+ if (switch_to_text)
+ ioctl(fd, KDSETMODE, KD_TEXT);
/* Enable console unicode mode */
ioctl(fd, KDSKBMODE, K_UNICODE);
if (fd < 0)
return fd;
- r = reset_terminal_fd(fd);
+ r = reset_terminal_fd(fd, true);
close_nointr_nofail(fd);
return r;
if (notify >= 0)
close_nointr_nofail(notify);
- if ((r = reset_terminal_fd(fd)) < 0)
+ r = reset_terminal_fd(fd, true);
+ if (r < 0)
log_warning("Failed to reset terminal: %s", strerror(-r));
return fd;
int read_one_char(FILE *f, char *ret, usec_t timeout, bool *need_nl);
int ask(char *ret, const char *replies, const char *text, ...);
-int reset_terminal_fd(int fd);
+int reset_terminal_fd(int fd, bool switch_to_text);
int reset_terminal(const char *name);
int open_terminal(const char *name, int mode);