mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-20 14:03:39 +03:00
Merge pull request #13109 from poettering/revert-kbd-mode
Revert of #12378 ("VT kbd reset check")
This commit is contained in:
commit
ad3f86e6a4
@ -1260,36 +1260,12 @@ int vt_default_utf8(void) {
|
|||||||
return parse_boolean(b);
|
return parse_boolean(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
int vt_verify_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;
|
|
||||||
}
|
|
||||||
|
|
||||||
int vt_reset_keyboard(int fd) {
|
int vt_reset_keyboard(int fd) {
|
||||||
int kb, r;
|
int kb;
|
||||||
|
|
||||||
/* If we can't read the default, then default to unicode. It's 2017 after all. */
|
/* If we can't read the default, then default to unicode. It's 2017 after all. */
|
||||||
kb = vt_default_utf8() != 0 ? K_UNICODE : K_XLATE;
|
kb = vt_default_utf8() != 0 ? K_UNICODE : K_XLATE;
|
||||||
|
|
||||||
r = vt_verify_kbmode(fd);
|
|
||||||
if (r == -EBUSY) {
|
|
||||||
log_debug_errno(r, "Keyboard is not in XLATE or UNICODE mode, not resetting: %m");
|
|
||||||
return 0;
|
|
||||||
} else if (r < 0)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
if (ioctl(fd, KDSKBMODE, kb) < 0)
|
if (ioctl(fd, KDSKBMODE, kb) < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
|
@ -158,7 +158,6 @@ int openpt_allocate_in_namespace(pid_t pid, int flags, char **ret_slave);
|
|||||||
int open_terminal_in_namespace(pid_t pid, const char *name, int mode);
|
int open_terminal_in_namespace(pid_t pid, const char *name, int mode);
|
||||||
|
|
||||||
int vt_default_utf8(void);
|
int vt_default_utf8(void);
|
||||||
int vt_verify_kbmode(int fd);
|
|
||||||
int vt_reset_keyboard(int fd);
|
int vt_reset_keyboard(int fd);
|
||||||
int vt_restore(int fd);
|
int vt_restore(int fd);
|
||||||
int vt_release(int fd, bool restore_vt);
|
int vt_release(int fd, bool restore_vt);
|
||||||
|
@ -70,18 +70,29 @@ static int verify_vc_allocation_byfd(int fd) {
|
|||||||
return verify_vc_allocation(vcs.v_active);
|
return verify_vc_allocation(vcs.v_active);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int toggle_utf8(const char *name, int fd, bool utf8) {
|
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_vc(const char *name, int fd, bool utf8) {
|
||||||
int r;
|
int r;
|
||||||
struct termios tc = {};
|
struct termios tc = {};
|
||||||
|
|
||||||
assert(name);
|
assert(name);
|
||||||
|
assert(fd >= 0);
|
||||||
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);
|
r = ioctl(fd, KDSKBMODE, utf8 ? K_UNICODE : K_XLATE);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
@ -280,10 +291,10 @@ static void setup_remaining_vcs(int src_fd, unsigned src_idx, bool utf8) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vt_verify_kbmode(fd_d) < 0)
|
if (verify_vc_kbmode(fd_d) < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
toggle_utf8(ttyname, fd_d, utf8);
|
(void) toggle_utf8_vc(ttyname, fd_d, utf8);
|
||||||
|
|
||||||
if (cfo.op != KD_FONT_OP_SET)
|
if (cfo.op != KD_FONT_OP_SET)
|
||||||
continue;
|
continue;
|
||||||
@ -355,7 +366,7 @@ static int find_source_vc(char **ret_path, unsigned *ret_idx) {
|
|||||||
err = -fd;
|
err = -fd;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
r = vt_verify_kbmode(fd);
|
r = verify_vc_kbmode(fd);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
if (!err)
|
if (!err)
|
||||||
err = -r;
|
err = -r;
|
||||||
@ -388,7 +399,7 @@ static int verify_source_vc(char **ret_path, const char *src_vc) {
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Virtual console %s is not allocated: %m", src_vc);
|
return log_error_errno(r, "Virtual console %s is not allocated: %m", src_vc);
|
||||||
|
|
||||||
r = vt_verify_kbmode(fd);
|
r = verify_vc_kbmode(fd);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Virtual console %s is not in K_XLATE or K_UNICODE: %m", src_vc);
|
return log_error_errno(r, "Virtual console %s is not in K_XLATE or K_UNICODE: %m", src_vc);
|
||||||
|
|
||||||
@ -448,7 +459,7 @@ int main(int argc, char **argv) {
|
|||||||
log_warning_errno(r, "Failed to read /proc/cmdline: %m");
|
log_warning_errno(r, "Failed to read /proc/cmdline: %m");
|
||||||
|
|
||||||
(void) toggle_utf8_sysfs(utf8);
|
(void) toggle_utf8_sysfs(utf8);
|
||||||
(void) toggle_utf8(vc, fd, utf8);
|
(void) toggle_utf8_vc(vc, fd, utf8);
|
||||||
|
|
||||||
r = font_load_and_wait(vc, vc_font, vc_font_map, vc_font_unimap);
|
r = font_load_and_wait(vc, vc_font, vc_font_map, vc_font_unimap);
|
||||||
keyboard_ok = keyboard_load_and_wait(vc, vc_keymap, vc_keymap_toggle, utf8) == 0;
|
keyboard_ok = keyboard_load_and_wait(vc, vc_keymap, vc_keymap_toggle, utf8) == 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user