Add errno.h
[oweals/busybox.git] / mt.c
diff --git a/mt.c b/mt.c
index 304d664853953d21ac32a44c82a2ddbead68728f..70d03cca40177f3f02d9ca29d26faab33423f8f0 100644 (file)
--- a/mt.c
+++ b/mt.c
@@ -1,15 +1,9 @@
 /* vi: set sw=4 ts=4: */
-#include "internal.h"
+#include "busybox.h"
 #include <stdio.h>
 #include <sys/mtio.h>
 #include <sys/fcntl.h>
 
-static const char mt_usage[] = "mt [-f device] opcode value\n"
-#ifndef BB_FEATURE_TRIVIAL_HELP
-                       "\nControl magnetic tape drive operation\n"
-#endif
-                       ;
-
 struct mt_opcodes {
        char *name;
        short value;
@@ -61,7 +55,7 @@ extern int mt_main(int argc, char **argv)
        struct mtop op;
        int fd;
        
-       if ((argc != 2 && argc != 3) && **(argv + 1) != '-') {
+       if (argc < 2) {
                usage(mt_usage);
        }
 
@@ -81,8 +75,8 @@ extern int mt_main(int argc, char **argv)
        }
 
        if (code->name == 0) {
-               fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]);
-               exit (FALSE);
+               error_msg("unrecognized opcode %s.\n", argv[1]);
+               return EXIT_FAILURE;
        }
 
        op.mt_op = code->value;
@@ -91,15 +85,11 @@ extern int mt_main(int argc, char **argv)
        else
                op.mt_count = 1;                /* One, not zero, right? */
 
-       if ((fd = open(file, O_RDONLY, 0)) < 0) {
-               perror(file);
-               exit (FALSE);
-       }
+       if ((fd = open(file, O_RDONLY, 0)) < 0)
+               perror_msg_and_die("%s", file);
 
-       if (ioctl(fd, MTIOCTOP, &op) != 0) {
-               perror(file);
-               exit (FALSE);
-       }
+       if (ioctl(fd, MTIOCTOP, &op) != 0)
+               perror_msg_and_die("%s", file);
 
-       return (TRUE);
+       return EXIT_SUCCESS;
 }