diff -ru kbd-1.13.orig/man/man1/loadkeys.1.in kbd-1.13/man/man1/loadkeys.1.in --- kbd-1.13.orig/man/man1/loadkeys.1.in 2007-08-30 12:12:23 +0000 +++ kbd-1.13/man/man1/loadkeys.1.in 2007-08-30 12:12:50 +0000 @@ -5,6 +5,8 @@ .SH SYNOPSIS .B loadkeys [ +.I -b --bkeymap +] [ .I -c --clearcompose ] [ .I -C '' @@ -129,6 +131,17 @@ .I /usr/src/linux\%/drivers\%/char\%/defkeymap.c, specifying the default key bindings for a kernel (and does not modify the current keymap). +.SH "CREATE BINARY KEYMAP" +If the +.I -b +(or +.I --bkeymap +) option is given +.B loadkeys +prints to the standard output a file that may be used as a binary +keymap as expected by Busybox +.B loadkmap +command (and does not modify the current keymap). .SH "OTHER OPTIONS" .TP .B \-h \-\-help diff -ru kbd-1.13.orig/src/loadkeys.y kbd-1.13/src/loadkeys.y --- kbd-1.13.orig/src/loadkeys.y 2007-08-30 12:12:23 +0000 +++ kbd-1.13/src/loadkeys.y 2007-08-30 12:13:41 +0000 @@ -65,6 +65,7 @@ static void do_constant_key (int, u_short); static void loadkeys(char *console, int *warned); static void mktable(void); +static void bkeymap(void); static void strings_as_usual(void); /* static void keypad_as_usual(char *keyboard); */ /* static void function_keys_as_usual(char *keyboard); */ @@ -252,6 +253,7 @@ "\n" "valid options are:\n" "\n" +" -b --bkeymap output a binary keymap to stdout\n" " -c --clearcompose clear kernel compose table\n" " -C \n" " --console=<...> Indicate console device(s) to be used.\n" @@ -265,6 +267,7 @@ } char **args; +int optb = 0; int optd = 0; int optm = 0; int opts = 0; @@ -274,8 +277,9 @@ int main(unsigned int argc, char *argv[]) { - const char *short_opts = "cC:dhmsuqvV"; + const char *short_opts = "bcC:dhmsuqvV"; const struct option long_opts[] = { + { "bkeymap", no_argument, NULL, 'b' }, { "clearcompose", no_argument, NULL, 'c' }, { "console", 1, NULL, 'C' }, { "default", no_argument, NULL, 'd' }, @@ -297,6 +301,9 @@ while ((c = getopt_long(argc, argv, short_opts, long_opts, NULL)) != -1) { switch (c) { + case 'b': + optb = 1; + break; case 'c': nocompose = 1; break; @@ -339,9 +346,11 @@ exit(1); } do_constant(); - if(optm) + if(optb) { + bkeymap(); + } else if(optm) { mktable(); - else if (console) + } else if (console) { char *buf = strdup(console); /* make writable */ char *e, *s = buf; @@ -1263,3 +1272,28 @@ exit(0); } + +static void +bkeymap () { + int i, j; + + u_char *p; + char flag, magic[] = "bkeymap"; + unsigned short v; + + write(1, magic, 7); + for (i = 0; i < MAX_NR_KEYMAPS; i++) { + flag = key_map[i]? 1 : 0; + write(1, &flag, 1); + } + for (i = 0; i < MAX_NR_KEYMAPS; i++) { + if (key_map[i]) { + for (j = 0; j < NR_KEYS / 2; j++) { + v = key_map[i][j]; + write(1, &v, 2); + } + } + } + exit(0); +} +