Contents of /trunk/mkinitrd-magellan/busybox/console-tools/loadkmap.c
Parent Directory | Revision Log
Revision 532 -
(show annotations)
(download)
Sat Sep 1 22:45:15 2007 UTC (16 years, 9 months ago) by niro
File MIME type: text/plain
File size: 1257 byte(s)
Sat Sep 1 22:45:15 2007 UTC (16 years, 9 months ago) by niro
File MIME type: text/plain
File size: 1257 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd
1 | /* vi: set sw=4 ts=4: */ |
2 | /* |
3 | * Mini loadkmap implementation for busybox |
4 | * |
5 | * Copyright (C) 1998 Enrique Zanardi <ezanardi@ull.es> |
6 | * |
7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
8 | * |
9 | */ |
10 | |
11 | #include "busybox.h" |
12 | |
13 | #define BINARY_KEYMAP_MAGIC "bkeymap" |
14 | |
15 | /* From <linux/kd.h> */ |
16 | struct kbentry { |
17 | unsigned char kb_table; |
18 | unsigned char kb_index; |
19 | unsigned short kb_value; |
20 | }; |
21 | /* sets one entry in translation table */ |
22 | #define KDSKBENT 0x4B47 |
23 | |
24 | /* From <linux/keyboard.h> */ |
25 | #define NR_KEYS 128 |
26 | #define MAX_NR_KEYMAPS 256 |
27 | |
28 | int loadkmap_main(int argc, char **argv) |
29 | { |
30 | struct kbentry ke; |
31 | int i, j, fd; |
32 | uint16_t ibuff[NR_KEYS]; |
33 | char flags[MAX_NR_KEYMAPS]; |
34 | char buff[7]; |
35 | |
36 | if (argc != 1) |
37 | bb_show_usage(); |
38 | |
39 | fd = xopen(CURRENT_VC, O_RDWR); |
40 | |
41 | xread(0, buff, 7); |
42 | if (strncmp(buff, BINARY_KEYMAP_MAGIC, 7)) |
43 | bb_error_msg_and_die("this is not a valid binary keymap"); |
44 | |
45 | xread(0, flags, MAX_NR_KEYMAPS); |
46 | |
47 | for (i = 0; i < MAX_NR_KEYMAPS; i++) { |
48 | if (flags[i] == 1) { |
49 | xread(0, ibuff, NR_KEYS * sizeof(uint16_t)); |
50 | for (j = 0; j < NR_KEYS; j++) { |
51 | ke.kb_index = j; |
52 | ke.kb_table = i; |
53 | ke.kb_value = ibuff[j]; |
54 | ioctl(fd, KDSKBENT, &ke); |
55 | } |
56 | } |
57 | } |
58 | |
59 | if (ENABLE_FEATURE_CLEAN_UP) close(fd); |
60 | return 0; |
61 | } |