diff options
author | Ron Yorston <rmy@pobox.com> | 2012-03-22 13:56:39 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2012-03-22 13:56:39 +0000 |
commit | 811c449748d5bd0505f8510e5582892f94ac0cda (patch) | |
tree | 2640249cb2a9605c7cd59467b9861b205e9bcc8a /console-tools | |
parent | c0d4367d6b581eb5989c02815880cf0fa2851ae8 (diff) | |
parent | 19311bfa7b8e8c6effa9c375de9b0eb4338bee12 (diff) | |
download | busybox-w32-811c449748d5bd0505f8510e5582892f94ac0cda.tar.gz busybox-w32-811c449748d5bd0505f8510e5582892f94ac0cda.tar.bz2 busybox-w32-811c449748d5bd0505f8510e5582892f94ac0cda.zip |
Merge commit '19311bfa7b8e8c6effa9c375de9b0eb4338bee12' into merge
Conflicts:
coreutils/ls.c
shell/ash.c
Diffstat (limited to 'console-tools')
-rw-r--r-- | console-tools/Config.src | 26 | ||||
-rw-r--r-- | console-tools/openvt.c | 4 | ||||
-rw-r--r-- | console-tools/showkey.c | 37 |
3 files changed, 38 insertions, 29 deletions
diff --git a/console-tools/Config.src b/console-tools/Config.src index cdb26800e..c65704478 100644 --- a/console-tools/Config.src +++ b/console-tools/Config.src | |||
@@ -10,7 +10,7 @@ INSERT | |||
10 | config CHVT | 10 | config CHVT |
11 | bool "chvt" | 11 | bool "chvt" |
12 | default y | 12 | default y |
13 | depends on PLATFORM_LINUX | 13 | select PLATFORM_LINUX |
14 | help | 14 | help |
15 | This program is used to change to another terminal. | 15 | This program is used to change to another terminal. |
16 | Example: chvt 4 (change to terminal /dev/tty4) | 16 | Example: chvt 4 (change to terminal /dev/tty4) |
@@ -18,7 +18,7 @@ config CHVT | |||
18 | config FGCONSOLE | 18 | config FGCONSOLE |
19 | bool "fgconsole" | 19 | bool "fgconsole" |
20 | default y | 20 | default y |
21 | depends on PLATFORM_LINUX | 21 | select PLATFORM_LINUX |
22 | help | 22 | help |
23 | This program prints active (foreground) console number. | 23 | This program prints active (foreground) console number. |
24 | 24 | ||
@@ -31,14 +31,14 @@ config CLEAR | |||
31 | config DEALLOCVT | 31 | config DEALLOCVT |
32 | bool "deallocvt" | 32 | bool "deallocvt" |
33 | default y | 33 | default y |
34 | depends on PLATFORM_LINUX | 34 | select PLATFORM_LINUX |
35 | help | 35 | help |
36 | This program deallocates unused virtual consoles. | 36 | This program deallocates unused virtual consoles. |
37 | 37 | ||
38 | config DUMPKMAP | 38 | config DUMPKMAP |
39 | bool "dumpkmap" | 39 | bool "dumpkmap" |
40 | default y | 40 | default y |
41 | depends on PLATFORM_LINUX | 41 | select PLATFORM_LINUX |
42 | help | 42 | help |
43 | This program dumps the kernel's keyboard translation table to | 43 | This program dumps the kernel's keyboard translation table to |
44 | stdout, in binary format. You can then use loadkmap to load it. | 44 | stdout, in binary format. You can then use loadkmap to load it. |
@@ -46,21 +46,21 @@ config DUMPKMAP | |||
46 | config KBD_MODE | 46 | config KBD_MODE |
47 | bool "kbd_mode" | 47 | bool "kbd_mode" |
48 | default y | 48 | default y |
49 | depends on PLATFORM_LINUX | 49 | select PLATFORM_LINUX |
50 | help | 50 | help |
51 | This program reports and sets keyboard mode. | 51 | This program reports and sets keyboard mode. |
52 | 52 | ||
53 | config LOADFONT | 53 | config LOADFONT |
54 | bool "loadfont" | 54 | bool "loadfont" |
55 | default y | 55 | default y |
56 | depends on PLATFORM_LINUX | 56 | select PLATFORM_LINUX |
57 | help | 57 | help |
58 | This program loads a console font from standard input. | 58 | This program loads a console font from standard input. |
59 | 59 | ||
60 | config LOADKMAP | 60 | config LOADKMAP |
61 | bool "loadkmap" | 61 | bool "loadkmap" |
62 | default y | 62 | default y |
63 | depends on PLATFORM_LINUX | 63 | select PLATFORM_LINUX |
64 | help | 64 | help |
65 | This program loads a keyboard translation table from | 65 | This program loads a keyboard translation table from |
66 | standard input. | 66 | standard input. |
@@ -68,7 +68,7 @@ config LOADKMAP | |||
68 | config OPENVT | 68 | config OPENVT |
69 | bool "openvt" | 69 | bool "openvt" |
70 | default y | 70 | default y |
71 | depends on PLATFORM_LINUX | 71 | select PLATFORM_LINUX |
72 | help | 72 | help |
73 | This program is used to start a command on an unused | 73 | This program is used to start a command on an unused |
74 | virtual terminal. | 74 | virtual terminal. |
@@ -100,7 +100,7 @@ config FEATURE_RESIZE_PRINT | |||
100 | config SETCONSOLE | 100 | config SETCONSOLE |
101 | bool "setconsole" | 101 | bool "setconsole" |
102 | default y | 102 | default y |
103 | depends on PLATFORM_LINUX | 103 | select PLATFORM_LINUX |
104 | help | 104 | help |
105 | This program redirects the system console to another device, | 105 | This program redirects the system console to another device, |
106 | like the current tty while logged in via telnet. | 106 | like the current tty while logged in via telnet. |
@@ -115,7 +115,7 @@ config FEATURE_SETCONSOLE_LONG_OPTIONS | |||
115 | config SETFONT | 115 | config SETFONT |
116 | bool "setfont" | 116 | bool "setfont" |
117 | default y | 117 | default y |
118 | depends on PLATFORM_LINUX | 118 | select PLATFORM_LINUX |
119 | help | 119 | help |
120 | Allows to load console screen map. Useful for i18n. | 120 | Allows to load console screen map. Useful for i18n. |
121 | 121 | ||
@@ -137,7 +137,7 @@ config DEFAULT_SETFONT_DIR | |||
137 | config SETKEYCODES | 137 | config SETKEYCODES |
138 | bool "setkeycodes" | 138 | bool "setkeycodes" |
139 | default y | 139 | default y |
140 | depends on PLATFORM_LINUX | 140 | select PLATFORM_LINUX |
141 | help | 141 | help |
142 | This program loads entries into the kernel's scancode-to-keycode | 142 | This program loads entries into the kernel's scancode-to-keycode |
143 | map, allowing unusual keyboards to generate usable keycodes. | 143 | map, allowing unusual keyboards to generate usable keycodes. |
@@ -145,14 +145,14 @@ config SETKEYCODES | |||
145 | config SETLOGCONS | 145 | config SETLOGCONS |
146 | bool "setlogcons" | 146 | bool "setlogcons" |
147 | default y | 147 | default y |
148 | depends on PLATFORM_LINUX | 148 | select PLATFORM_LINUX |
149 | help | 149 | help |
150 | This program redirects the output console of kernel messages. | 150 | This program redirects the output console of kernel messages. |
151 | 151 | ||
152 | config SHOWKEY | 152 | config SHOWKEY |
153 | bool "showkey" | 153 | bool "showkey" |
154 | default y | 154 | default y |
155 | depends on PLATFORM_LINUX | 155 | select PLATFORM_LINUX |
156 | help | 156 | help |
157 | Shows keys pressed. | 157 | Shows keys pressed. |
158 | 158 | ||
diff --git a/console-tools/openvt.c b/console-tools/openvt.c index 6e0b589a0..56f50c6cd 100644 --- a/console-tools/openvt.c +++ b/console-tools/openvt.c | |||
@@ -144,9 +144,7 @@ int openvt_main(int argc UNUSED_PARAM, char **argv) | |||
144 | 144 | ||
145 | if (!argv[0]) { | 145 | if (!argv[0]) { |
146 | argv--; | 146 | argv--; |
147 | argv[0] = getenv("SHELL"); | 147 | argv[0] = (char *) get_shell_name(); |
148 | if (!argv[0]) | ||
149 | argv[0] = (char *) DEFAULT_SHELL; | ||
150 | /*argv[1] = NULL; - already is */ | 148 | /*argv[1] = NULL; - already is */ |
151 | } | 149 | } |
152 | 150 | ||
diff --git a/console-tools/showkey.c b/console-tools/showkey.c index e7834f702..06df68bfd 100644 --- a/console-tools/showkey.c +++ b/console-tools/showkey.c | |||
@@ -56,37 +56,45 @@ int showkey_main(int argc UNUSED_PARAM, char **argv) | |||
56 | // FIXME: aks are all mutually exclusive | 56 | // FIXME: aks are all mutually exclusive |
57 | getopt32(argv, "aks"); | 57 | getopt32(argv, "aks"); |
58 | 58 | ||
59 | // get keyboard settings | ||
60 | xioctl(STDIN_FILENO, KDGKBMODE, &kbmode); | ||
61 | printf("kb mode was %s\n\nPress any keys. Program terminates %s\n\n", | ||
62 | kbmode == K_RAW ? "RAW" : | ||
63 | (kbmode == K_XLATE ? "XLATE" : | ||
64 | (kbmode == K_MEDIUMRAW ? "MEDIUMRAW" : | ||
65 | (kbmode == K_UNICODE ? "UNICODE" : "UNKNOWN"))) | ||
66 | , (option_mask32 & OPT_a) ? "on EOF (ctrl-D)" : "10s after last keypress" | ||
67 | ); | ||
68 | |||
69 | // prepare for raw mode | 59 | // prepare for raw mode |
70 | xget1(&tio, &tio0); | 60 | xget1(&tio, &tio0); |
71 | // put stdin in raw mode | 61 | // put stdin in raw mode |
72 | xset1(&tio); | 62 | xset1(&tio); |
73 | 63 | ||
64 | #define press_keys "Press any keys, program terminates %s:\r\n\n" | ||
65 | |||
74 | if (option_mask32 & OPT_a) { | 66 | if (option_mask32 & OPT_a) { |
67 | // just read stdin char by char | ||
75 | unsigned char c; | 68 | unsigned char c; |
76 | 69 | ||
77 | // just read stdin char by char | 70 | printf(press_keys, "on EOF (ctrl-D)"); |
71 | |||
72 | // read and show byte values | ||
78 | while (1 == read(STDIN_FILENO, &c, 1)) { | 73 | while (1 == read(STDIN_FILENO, &c, 1)) { |
79 | printf("%3u 0%03o 0x%02x\r\n", c, c, c); | 74 | printf("%3u 0%03o 0x%02x\r\n", c, c, c); |
80 | if (04 /*CTRL-D*/ == c) | 75 | if (04 /*CTRL-D*/ == c) |
81 | break; | 76 | break; |
82 | } | 77 | } |
78 | |||
83 | } else { | 79 | } else { |
80 | // we assume a PC keyboard | ||
81 | xioctl(STDIN_FILENO, KDGKBMODE, &kbmode); | ||
82 | printf("Keyboard mode was %s.\r\n\n", | ||
83 | kbmode == K_RAW ? "RAW" : | ||
84 | (kbmode == K_XLATE ? "XLATE" : | ||
85 | (kbmode == K_MEDIUMRAW ? "MEDIUMRAW" : | ||
86 | (kbmode == K_UNICODE ? "UNICODE" : "UNKNOWN"))) | ||
87 | ); | ||
88 | |||
84 | // set raw keyboard mode | 89 | // set raw keyboard mode |
85 | xioctl(STDIN_FILENO, KDSKBMODE, (void *)(ptrdiff_t)((option_mask32 & OPT_k) ? K_MEDIUMRAW : K_RAW)); | 90 | xioctl(STDIN_FILENO, KDSKBMODE, (void *)(ptrdiff_t)((option_mask32 & OPT_k) ? K_MEDIUMRAW : K_RAW)); |
86 | 91 | ||
87 | // we should exit on any signal; signals should interrupt read | 92 | // we should exit on any signal; signals should interrupt read |
88 | bb_signals_recursive_norestart(BB_FATAL_SIGS, record_signo); | 93 | bb_signals_recursive_norestart(BB_FATAL_SIGS, record_signo); |
89 | 94 | ||
95 | // inform user that program ends after time of inactivity | ||
96 | printf(press_keys, "10s after last keypress"); | ||
97 | |||
90 | // read and show scancodes | 98 | // read and show scancodes |
91 | while (!bb_got_signal) { | 99 | while (!bb_got_signal) { |
92 | char buf[18]; | 100 | char buf[18]; |
@@ -94,6 +102,7 @@ int showkey_main(int argc UNUSED_PARAM, char **argv) | |||
94 | 102 | ||
95 | // setup 10s watchdog | 103 | // setup 10s watchdog |
96 | alarm(10); | 104 | alarm(10); |
105 | |||
97 | // read scancodes | 106 | // read scancodes |
98 | n = read(STDIN_FILENO, buf, sizeof(buf)); | 107 | n = read(STDIN_FILENO, buf, sizeof(buf)); |
99 | i = 0; | 108 | i = 0; |
@@ -121,11 +130,13 @@ int showkey_main(int argc UNUSED_PARAM, char **argv) | |||
121 | } | 130 | } |
122 | puts("\r"); | 131 | puts("\r"); |
123 | } | 132 | } |
133 | |||
134 | // restore keyboard mode | ||
135 | xioctl(STDIN_FILENO, KDSKBMODE, (void *)(ptrdiff_t)kbmode); | ||
124 | } | 136 | } |
125 | 137 | ||
126 | // restore keyboard and console settings | 138 | // restore console settings |
127 | xset1(&tio0); | 139 | xset1(&tio0); |
128 | xioctl(STDIN_FILENO, KDSKBMODE, (void *)(ptrdiff_t)kbmode); | ||
129 | 140 | ||
130 | return EXIT_SUCCESS; | 141 | return EXIT_SUCCESS; |
131 | } | 142 | } |