From: Franck Bui Date: Wed, 12 Dec 2018 12:46:32 +0000 (+0100) Subject: vconsole-setup: fonts copy will fail if the current terminal is in graphical mode X-Git-Tag: v240~74 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d610d2012532d6d2467600e2e914530c5edc63b1;p=thirdparty%2Fsystemd.git vconsole-setup: fonts copy will fail if the current terminal is in graphical mode If the terminal is in graphical mode, the kernel will refuse to copy the fonts and will return -EINVAL. Also having the graphical mode in effect probably indicates that the terminal is in used by another application and we shouldn't interfer in such cases. --- diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c index efaa8c28d39..ebdeba3e8e9 100644 --- a/src/vconsole/vconsole-setup.c +++ b/src/vconsole/vconsole-setup.c @@ -298,14 +298,28 @@ static void setup_remaining_vcs(int src_fd, unsigned src_idx, bool utf8) { r = ioctl(fd_d, KDFONTOP, &cfo); if (r < 0) { - log_warning_errno(errno, "KD_FONT_OP_SET failed, fonts will not be copied to tty%u: %m", i); + int last_errno, mode; + + /* The fonts couldn't have been copied. It might be due to the + * terminal being in graphical mode. In this case the kernel + * returns -EINVAL which is too generic for distinguishing this + * specific case. So we need to retrieve the terminal mode and if + * the graphical mode is in used, let's assume that something else + * is using the terminal and the failure was expected as we + * shouldn't have tried to copy the fonts. */ + + last_errno = errno; + if (ioctl(fd_d, KDGETMODE, &mode) >= 0 && mode != KD_TEXT) + log_debug("KD_FONT_OP_SET skipped: tty%u is not in text mode", i); + else + log_warning_errno(last_errno, "KD_FONT_OP_SET failed, fonts will not be copied to tty%u: %m", i); + continue; } /* - * copy unicode translation table - * unimapd is a ushort count and a pointer to an - * array of struct unipair { ushort, ushort } + * copy unicode translation table unimapd is a ushort count and a pointer + * to an array of struct unipair { ushort, ushort } */ r = ioctl(fd_d, PIO_UNIMAPCLR, &adv); if (r < 0) {