From nobody Thu Feb 9 21:36:16 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PCVYF22w4z3nmwT; Thu, 9 Feb 2023 21:36:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PCVYF1GSCz4Fjs; Thu, 9 Feb 2023 21:36:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675978577; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CX2HkGdY36L/z5Rz3+VRVMXMqQUMCRluVEuG8xEczYg=; b=IqUD7MSY6g5AfS8OxjJ3/v2fS8fxoOQJ8hqk0kMTbkJvZc8E5asxtyNxIqYwPdpaIcKTh0 xuPPDc4Eo8PvmmACyIRjfEwxHelq2xGhOVMt9u7j72T3e+CZ89Rho1YiNx/DNU3OqkPgFo jGJUftLW+oyzEuK7PP7fbj3yskF8H4RYfm+fIRbTdBCqha5i01WlrVuLLwCrn4fIY00aNK SW8DQKx9jG3rx6qPKQlKF2jTHzFeionY6SdAudBxi4jq9yAtcHRo93Gvbl1cWmcPNtOfhs 7G1RwytzfHHzrWSWCCgjywoGyHF1FhZeBCSveqVIVqXQdvKKfw+6SwHqe/LHZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675978577; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CX2HkGdY36L/z5Rz3+VRVMXMqQUMCRluVEuG8xEczYg=; b=LymiuY2upAwR/Z9lyQZjqW0VqZdJeEbOzHxuUDPWO9wGIsWL6vXWvSda9I4LHwKxcPc44Z dW+O4ijV6r/piaqpXtZCAcuBQK/eFUyFD1800aCn5VagvS99p0ezo64keLJOqx+Oxh6Da7 phsh9HYjjk0Ep6ZXGqW93GCx1FJO/r7/YBh1DSSFFTqcmIUdJlPrkrgQVtO3frsSXSLzG0 YeyiRUobGUDWlxsIrUMYsz99Brd2k3a+xDCkXfmQMNOPzUl1HMs4neoWX0R9370muqK48B /M9pZB4yW+tJb/iY2Tk5ApXkKjtiaqz5zFfAsQV1b/uJPVAvEVllaUrierlSeA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675978577; a=rsa-sha256; cv=none; b=UpQb/Sdb6RERXKF0c9/zai9NKWEQWePjCYmwR/pYCU5hfmLzGG3+2p4C3ndsVXNGVUNCfN OAtnAQ8lTPP7vp/HdVbM27L0p10P4n9W1Z2t3kr9GNDa1OCCKkDu6uK/3a0eXhboGsWPu0 dy/swiY1pxqnLOLeMU3Hq358bWDDw8cO2K4AJSlkqg1t1jEmtLtkLTohw/xkRG14RTmimW LUcbcfi0oIZGBG4Vz6lsvFMLmAM23aE6TEL47f84Fhiuw6U9I1Tq1j/tvJxp4Z1PZ4YbYF gZXktnqxz+TUZRi7xQtcfWhjxveXYSvNk5I/aZ9x4iX91fIXCgETcj9cgOpY5Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PCVYF00pszsk0; Thu, 9 Feb 2023 21:36:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 319LaGtd072554; Thu, 9 Feb 2023 21:36:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 319LaGqL072553; Thu, 9 Feb 2023 21:36:16 GMT (envelope-from git) Date: Thu, 9 Feb 2023 21:36:16 GMT Message-Id: <202302092136.319LaGqL072553@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: =?utf-8?Q?Stefan=20E=C3=9Fer?= Subject: git: 6693d527a438 - stable/13 - usr.sbin/kbdcontrol.c: Add backwards compatibility functions List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: se X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 6693d527a43863ea67384b4616257a20794e8254 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by se: URL: https://cgit.FreeBSD.org/src/commit/?id=6693d527a43863ea67384b4616257a20794e8254 commit 6693d527a43863ea67384b4616257a20794e8254 Author: Stefan Eßer AuthorDate: 2023-02-06 22:56:44 +0000 Commit: Stefan Eßer CommitDate: 2023-02-09 21:36:09 +0000 usr.sbin/kbdcontrol.c: Add backwards compatibility functions This commit allows a kbdcontrol binary built with a version of kbio.h that supports Unicode characters in dead key maps to load and display keymaps including the dead key tables on a kernel built with a previous version of kbio.h (that only supported 8 bit characters in the dead key map). This commit is meant as a temporary compatibility shim that will be reverted when it can be assumed that all relevant systems have been upgraded to a kernel that uses the updated kbio.h. MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D38388 (cherry picked from commit b92f8e5c0dccd52ea194cabe835b7af0b5e91f09) --- sys/sys/kbio.h | 8 +++---- usr.sbin/kbdcontrol/kbdcontrol.c | 49 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/sys/sys/kbio.h b/sys/sys/kbio.h index daef8e474816..a129556d1ada 100644 --- a/sys/sys/kbio.h +++ b/sys/sys/kbio.h @@ -209,7 +209,7 @@ struct accentmap { }; typedef struct accentmap accentmap_t; -#ifdef _KERNEL +//#ifdef _KERNEL struct oacc_t { u_char accchar; u_char map[NUM_ACCENTCHARS][2]; @@ -220,7 +220,7 @@ struct oaccentmap { struct oacc_t acc[NUM_DEADKEYS]; }; typedef struct oaccentmap oaccentmap_t; -#endif /* _KERNEL */ +//#endif /* _KERNEL */ struct keyarg { u_short keynum; @@ -257,10 +257,10 @@ typedef struct fkeyarg fkeyarg_t; /* XXX: Should have accentmap_t as an argument, but that's too big for ioctl()! */ #define GIO_DEADKEYMAP _IO('k', 8) #define PIO_DEADKEYMAP _IO('k', 9) -#ifdef _KERNEL +//#ifdef _KERNEL #define OGIO_DEADKEYMAP _IOR('k', 8, oaccentmap_t) #define OPIO_DEADKEYMAP _IOW('k', 9, oaccentmap_t) -#endif /* _KERNEL */ +//#endif /* _KERNEL */ #define GIO_KEYMAPENT _IOWR('k', 10, keyarg_t) #define PIO_KEYMAPENT _IOW('k', 11, keyarg_t) diff --git a/usr.sbin/kbdcontrol/kbdcontrol.c b/usr.sbin/kbdcontrol/kbdcontrol.c index f4651acea840..725d62a7bfe6 100644 --- a/usr.sbin/kbdcontrol/kbdcontrol.c +++ b/usr.sbin/kbdcontrol/kbdcontrol.c @@ -818,11 +818,27 @@ add_keymap_path(const char *path) STAILQ_INSERT_TAIL(&pathlist, pe, next); } +static void +to_old_accentmap(accentmap_t *from, oaccentmap_t *to) +{ + int i, j; + + to->n_accs = from->n_accs; + for (i = 0; i < NUM_DEADKEYS; i++) { + for (j = 0; j < NUM_ACCENTCHARS; j++) { + to->acc[i].map[j][0] = from->acc[i].map[j][0]; + to->acc[i].map[j][1] = from->acc[i].map[j][1]; + to->acc[i].accchar = from->acc[i].accchar; + } + } +} + static void load_keymap(char *opt, int dumponly) { keymap_t keymap; accentmap_t accentmap; + oaccentmap_t oaccentmap; struct pathent *pe; FILE *file; int j; @@ -882,9 +898,27 @@ load_keymap(char *opt, int dumponly) } if ((accentmap.n_accs > 0) && (ioctl(0, PIO_DEADKEYMAP, &accentmap) < 0)) { - warn("setting accentmap"); - fclose(file); - return; + to_old_accentmap(&accentmap, &oaccentmap); + if (ioctl(0, OPIO_DEADKEYMAP, &oaccentmap) < 0) { + warn("setting accentmap"); + fclose(file); + return; + } + } +} + +static void +to_new_accentmap(oaccentmap_t *from, accentmap_t *to) +{ + int i, j; + + to->n_accs = from->n_accs; + for (i = 0; i < NUM_DEADKEYS; i++) { + for (j = 0; j < NUM_ACCENTCHARS; j++) { + to->acc[i].map[j][0] = from->acc[i].map[j][0]; + to->acc[i].map[j][1] = from->acc[i].map[j][1]; + to->acc[i].accchar = from->acc[i].accchar; + } } } @@ -893,12 +927,17 @@ print_keymap(void) { keymap_t keymap; accentmap_t accentmap; + oaccentmap_t oaccentmap; int i; if (ioctl(0, GIO_KEYMAP, &keymap) < 0) err(1, "getting keymap"); - if (ioctl(0, GIO_DEADKEYMAP, &accentmap) < 0) - memset(&accentmap, 0, sizeof(accentmap)); + if (ioctl(0, GIO_DEADKEYMAP, &accentmap) < 0) { + if (ioctl(0, OGIO_DEADKEYMAP, &oaccentmap) == 0) + to_new_accentmap(&oaccentmap, &accentmap); + else + memset(&accentmap, 0, sizeof(accentmap)); + } printf( "# alt\n" "# scan cntrl alt alt cntrl lock\n"