summaryrefslogtreecommitdiff
path: root/console-tools/loadkmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'console-tools/loadkmap.c')
-rw-r--r--console-tools/loadkmap.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/console-tools/loadkmap.c b/console-tools/loadkmap.c
index bea5a77..28e53eb 100644
--- a/console-tools/loadkmap.c
+++ b/console-tools/loadkmap.c
@@ -26,28 +26,26 @@ struct kbentry {
#define MAX_NR_KEYMAPS 256
int loadkmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int loadkmap_main(int argc, char **argv ATTRIBUTE_UNUSED)
+int loadkmap_main(int ATTRIBUTE_UNUSED argc, char **argv ATTRIBUTE_UNUSED)
{
struct kbentry ke;
int i, j, fd;
uint16_t ibuff[NR_KEYS];
- char flags[MAX_NR_KEYMAPS];
- char buff[7];
+ RESERVE_CONFIG_BUFFER(flags,MAX_NR_KEYMAPS);
- if (argc != 1)
- bb_show_usage();
+/* bb_warn_ignoring_args(argc>=2);*/
fd = xopen(CURRENT_VC, O_RDWR);
- xread(0, buff, 7);
- if (strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
- bb_error_msg_and_die("this is not a valid binary keymap");
+ xread(STDIN_FILENO, flags, 7);
+ if (strncmp(flags, BINARY_KEYMAP_MAGIC, 7))
+ bb_error_msg_and_die("not a valid binary keymap");
- xread(0, flags, MAX_NR_KEYMAPS);
+ xread(STDIN_FILENO, flags, MAX_NR_KEYMAPS);
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
if (flags[i] == 1) {
- xread(0, ibuff, NR_KEYS * sizeof(uint16_t));
+ xread(STDIN_FILENO, ibuff, NR_KEYS * sizeof(uint16_t));
for (j = 0; j < NR_KEYS; j++) {
ke.kb_index = j;
ke.kb_table = i;
@@ -57,6 +55,9 @@ int loadkmap_main(int argc, char **argv ATTRIBUTE_UNUSED)
}
}
- if (ENABLE_FEATURE_CLEAN_UP) close(fd);
- return 0;
+ if (ENABLE_FEATURE_CLEAN_UP) {
+ close(fd);
+ RELEASE_CONFIG_BUFFER(flags);
+ }
+ return EXIT_SUCCESS;
}