Use the correct buffer when calling dirname, improve an error message, and
[oweals/busybox.git] / dumpkmap.c
index b438ba2713333802e6f83e9c02400f2d274991de..22652a5e2b67167ce1ddc1cefd7da1b70e9607f2 100644 (file)
  *
  */
 
-#include "busybox.h"
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
 #include <sys/ioctl.h>
+#include "busybox.h"
 
 /* From <linux/kd.h> */
 struct kbentry {
@@ -45,12 +48,12 @@ int dumpkmap_main(int argc, char **argv)
        char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap";
 
        if (argc>=2 && *argv[1]=='-') {
-               usage(dumpkmap_usage);
+               show_usage();
        }
 
-       fd = open("/dev/tty0", O_RDWR);
+       fd = open(CURRENT_VC, O_RDWR);
        if (fd < 0) {
-               perror_msg("Error opening /dev/tty0");
+               perror_msg("Error opening " CURRENT_VC);
                return EXIT_FAILURE;
        }
 
@@ -78,7 +81,7 @@ int dumpkmap_main(int argc, char **argv)
                                ke.kb_table = i;
                                if (ioctl(fd, KDGKBENT, &ke) < 0) {
                                
-                                       error_msg("ioctl returned: %s, %s, %s, %xqq\n",strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
+                                       error_msg("ioctl returned: %s, %s, %s, %xqq", strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
                                        }
                                else {
                                        write(1,(void*)&ke.kb_value,2);