Annotation of /tags/mkinitrd-6_3_1/busybox/console-tools/dumpkmap.c
Parent Directory | Revision Log
Revision 984 -
(hide annotations)
(download)
Sun May 30 11:32:42 2010 UTC (14 years, 3 months ago) by niro
Original Path: trunk/mkinitrd-magellan/busybox/console-tools/dumpkmap.c
File MIME type: text/plain
File size: 1600 byte(s)
Sun May 30 11:32:42 2010 UTC (14 years, 3 months ago) by niro
Original Path: trunk/mkinitrd-magellan/busybox/console-tools/dumpkmap.c
File MIME type: text/plain
File size: 1600 byte(s)
-updated to busybox-1.16.1 and enabled blkid/uuid support in default config
1 | niro | 532 | /* vi: set sw=4 ts=4: */ |
2 | /* | ||
3 | * Mini dumpkmap implementation for busybox | ||
4 | * | ||
5 | * Copyright (C) Arne Bernin <arne@matrix.loopback.org> | ||
6 | * | ||
7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | ||
8 | * | ||
9 | */ | ||
10 | niro | 816 | /* no options, no getopt */ |
11 | niro | 532 | |
12 | niro | 816 | #include "libbb.h" |
13 | niro | 532 | |
14 | /* From <linux/kd.h> */ | ||
15 | struct kbentry { | ||
16 | unsigned char kb_table; | ||
17 | unsigned char kb_index; | ||
18 | unsigned short kb_value; | ||
19 | }; | ||
20 | #define KDGKBENT 0x4B46 /* gets one entry in translation table */ | ||
21 | |||
22 | /* From <linux/keyboard.h> */ | ||
23 | #define NR_KEYS 128 | ||
24 | #define MAX_NR_KEYMAPS 256 | ||
25 | |||
26 | niro | 816 | int dumpkmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
27 | int dumpkmap_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | ||
28 | niro | 532 | { |
29 | struct kbentry ke; | ||
30 | int i, j, fd; | ||
31 | niro | 984 | RESERVE_CONFIG_BUFFER(flags, MAX_NR_KEYMAPS); |
32 | niro | 532 | |
33 | niro | 984 | /* bb_warn_ignoring_args(argv[1]);*/ |
34 | niro | 532 | |
35 | niro | 816 | fd = get_console_fd_or_die(); |
36 | niro | 532 | |
37 | niro | 816 | write(STDOUT_FILENO, "bkeymap", 7); |
38 | niro | 532 | |
39 | /* Here we want to set everything to 0 except for indexes: | ||
40 | * [0-2] [4-6] [8-10] [12] */ | ||
41 | memset(flags, 0x00, MAX_NR_KEYMAPS); | ||
42 | memset(flags, 0x01, 13); | ||
43 | flags[3] = flags[7] = flags[11] = 0; | ||
44 | |||
45 | /* dump flags */ | ||
46 | niro | 816 | write(STDOUT_FILENO, flags, MAX_NR_KEYMAPS); |
47 | niro | 532 | |
48 | for (i = 0; i < MAX_NR_KEYMAPS; i++) { | ||
49 | if (flags[i] == 1) { | ||
50 | for (j = 0; j < NR_KEYS; j++) { | ||
51 | ke.kb_index = j; | ||
52 | ke.kb_table = i; | ||
53 | niro | 816 | if (!ioctl_or_perror(fd, KDGKBENT, &ke, |
54 | "ioctl failed with %s, %s, %p", | ||
55 | niro | 532 | (char *)&ke.kb_index, |
56 | (char *)&ke.kb_table, | ||
57 | niro | 816 | &ke.kb_value) |
58 | ) { | ||
59 | write(STDOUT_FILENO, (void*)&ke.kb_value, 2); | ||
60 | niro | 532 | } |
61 | } | ||
62 | } | ||
63 | } | ||
64 | niro | 816 | if (ENABLE_FEATURE_CLEAN_UP) { |
65 | close(fd); | ||
66 | RELEASE_CONFIG_BUFFER(flags); | ||
67 | } | ||
68 | niro | 532 | return EXIT_SUCCESS; |
69 | } |