summaryrefslogtreecommitdiff
path: root/src/vconsole
diff options
context:
space:
mode:
authorFranck Bui <fbui@suse.com>2018-12-12 13:46:32 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-12-13 08:30:20 +0100
commitd610d2012532d6d2467600e2e914530c5edc63b1 (patch)
tree3ea0434baa164af060f2af1f1c4dec3355c7b0cc /src/vconsole
parent0c17c0043383f31170b8e3c1abd491f9e03c8ec7 (diff)
downloadsystemd-d610d2012532d6d2467600e2e914530c5edc63b1.tar.gz
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.
Diffstat (limited to 'src/vconsole')
-rw-r--r--src/vconsole/vconsole-setup.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c
index efaa8c28d3..ebdeba3e8e 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) {