summaryrefslogtreecommitdiff
path: root/src/vconsole/vconsole-setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vconsole/vconsole-setup.c')
-rw-r--r--src/vconsole/vconsole-setup.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c
index 976dd825bc..d2bc3921d2 100644
--- a/src/vconsole/vconsole-setup.c
+++ b/src/vconsole/vconsole-setup.c
@@ -70,29 +70,19 @@ static int verify_vc_allocation_byfd(int fd) {
return verify_vc_allocation(vcs.v_active);
}
-static int verify_vc_kbmode(int fd) {
- int curr_mode;
-
- /*
- * Make sure we only adjust consoles in K_XLATE or K_UNICODE mode.
- * Otherwise we would (likely) interfere with X11's processing of the
- * key events.
- *
- * http://lists.freedesktop.org/archives/systemd-devel/2013-February/008573.html
- */
-
- if (ioctl(fd, KDGKBMODE, &curr_mode) < 0)
- return -errno;
-
- return IN_SET(curr_mode, K_XLATE, K_UNICODE) ? 0 : -EBUSY;
-}
-
static int toggle_utf8(const char *name, int fd, bool utf8) {
int r;
struct termios tc = {};
assert(name);
+ r = vt_verify_kbmode(fd);
+ if (r == -EBUSY) {
+ log_warning_errno(r, "Virtual console %s is not in K_XLATE or K_UNICODE: %m", name);
+ return 0;
+ } else if (r < 0)
+ return log_warning_errno(r, "Failed to verify kbdmode on %s: %m", name);
+
r = ioctl(fd, KDSKBMODE, utf8 ? K_UNICODE : K_XLATE);
if (r < 0)
return log_warning_errno(errno, "Failed to %s UTF-8 kbdmode on %s: %m", enable_disable(utf8), name);
@@ -290,7 +280,7 @@ static void setup_remaining_vcs(int src_fd, unsigned src_idx, bool utf8) {
continue;
}
- if (verify_vc_kbmode(fd_d) < 0)
+ if (vt_verify_kbmode(fd_d) < 0)
continue;
toggle_utf8(ttyname, fd_d, utf8);
@@ -365,7 +355,7 @@ static int find_source_vc(char **ret_path, unsigned *ret_idx) {
err = -fd;
continue;
}
- r = verify_vc_kbmode(fd);
+ r = vt_verify_kbmode(fd);
if (r < 0) {
if (!err)
err = -r;
@@ -398,7 +388,7 @@ static int verify_source_vc(char **ret_path, const char *src_vc) {
if (r < 0)
return log_error_errno(r, "Virtual console %s is not allocated: %m", src_vc);
- r = verify_vc_kbmode(fd);
+ r = vt_verify_kbmode(fd);
if (r < 0)
return log_error_errno(r, "Virtual console %s is not in K_XLATE or K_UNICODE: %m", src_vc);