From 78d4d8eeb241bfc6f0a9487894945886b3ee2b41 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Sun, 17 Jul 2011 08:19:19 +0000 Subject: Restore binary compatibility for GIO_KEYMAP and PIO_KEYMAP. Back in 2009 I changed the ABI of the GIO_KEYMAP and PIO_KEYMAP ioctls to support wide characters. I created a patch to add ABI compatibility for the old calls, but I didn't get any feedback to that. It seems now people are upgrading from 8 to 9 they experience this issue, so add it anyway. --- sys/dev/kbd/kbd.c | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) (limited to 'sys/dev/kbd') diff --git a/sys/dev/kbd/kbd.c b/sys/dev/kbd/kbd.c index 21818cb2d046..01e262e8825d 100644 --- a/sys/dev/kbd/kbd.c +++ b/sys/dev/kbd/kbd.c @@ -837,13 +837,12 @@ static int fkey_change_ok(fkeytab_t *, fkeyarg_t *, struct thread *); int genkbd_commonioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) { -#ifndef KBD_DISABLE_KEYMAP_LOAD keymap_t *mapp; -#endif + okeymap_t *omapp; keyarg_t *keyp; fkeyarg_t *fkeyp; int s; - int i; + int i, j; int error; s = spltty(); @@ -874,14 +873,39 @@ genkbd_commonioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) sizeof(keymap_t)); splx(s); return (error); + case OGIO_KEYMAP: /* get keyboard translation table (compat) */ + mapp = kbd->kb_keymap; + omapp = (okeymap_t *)arg; + omapp->n_keys = mapp->n_keys; + for (i = 0; i < NUM_KEYS; i++) { + for (j = 0; j < NUM_STATES; j++) + omapp->key[i].map[j] = + mapp->key[i].map[j]; + omapp->key[i].spcl = mapp->key[i].spcl; + omapp->key[i].flgs = mapp->key[i].flgs; + } + return (0); case PIO_KEYMAP: /* set keyboard translation table */ + case OPIO_KEYMAP: /* set keyboard translation table (compat) */ #ifndef KBD_DISABLE_KEYMAP_LOAD mapp = malloc(sizeof *mapp, M_TEMP, M_NOWAIT); - error = copyin(*(void **)arg, mapp, sizeof *mapp); - if (error != 0) { - splx(s); - free(mapp, M_TEMP); - return (error); + if (cmd == OPIO_KEYMAP) { + omapp = (okeymap_t *)arg; + mapp->n_keys = omapp->n_keys; + for (i = 0; i < NUM_KEYS; i++) { + for (j = 0; j < NUM_STATES; j++) + mapp->key[i].map[j] = + omapp->key[i].map[j]; + mapp->key[i].spcl = omapp->key[i].spcl; + mapp->key[i].flgs = omapp->key[i].flgs; + } + } else { + error = copyin(*(void **)arg, mapp, sizeof *mapp); + if (error != 0) { + splx(s); + free(mapp, M_TEMP); + return (error); + } } error = keymap_change_ok(kbd->kb_keymap, mapp, curthread); -- cgit v1.3