aboutsummaryrefslogtreecommitdiff
path: root/mt.c
diff options
context:
space:
mode:
Diffstat (limited to 'mt.c')
-rw-r--r--mt.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/mt.c b/mt.c
index 9791b64b2..cf20d1711 100644
--- a/mt.c
+++ b/mt.c
@@ -4,7 +4,8 @@
4#include <sys/mtio.h> 4#include <sys/mtio.h>
5#include <sys/fcntl.h> 5#include <sys/fcntl.h>
6 6
7static const char mt_usage[] = "mt [-f device] opcode value\n"; 7static const char mt_usage[] = "mt [-f device] opcode value\n\n"
8 "Control magnetic tape drive operation\n";
8 9
9struct mt_opcodes { 10struct mt_opcodes {
10 char *name; 11 char *name;
@@ -56,6 +57,10 @@ extern int mt_main(int argc, char **argv)
56 const struct mt_opcodes *code = opcodes; 57 const struct mt_opcodes *code = opcodes;
57 struct mtop op; 58 struct mtop op;
58 int fd; 59 int fd;
60
61 if ((argc != 2 && argc != 3) || **(argv + 1) == '-') {
62 usage(mt_usage);
63 }
59 64
60 if (strcmp(argv[1], "-f") == 0) { 65 if (strcmp(argv[1], "-f") == 0) {
61 if (argc < 4) { 66 if (argc < 4) {
@@ -74,7 +79,7 @@ extern int mt_main(int argc, char **argv)
74 79
75 if (code->name == 0) { 80 if (code->name == 0) {
76 fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]); 81 fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]);
77 return (FALSE); 82 exit (FALSE);
78 } 83 }
79 84
80 op.mt_op = code->value; 85 op.mt_op = code->value;
@@ -85,13 +90,13 @@ extern int mt_main(int argc, char **argv)
85 90
86 if ((fd = open(file, O_RDONLY, 0)) < 0) { 91 if ((fd = open(file, O_RDONLY, 0)) < 0) {
87 perror(file); 92 perror(file);
88 return (FALSE); 93 exit (FALSE);
89 } 94 }
90 95
91 if (ioctl(fd, MTIOCTOP, &op) != 0) { 96 if (ioctl(fd, MTIOCTOP, &op) != 0) {
92 perror(file); 97 perror(file);
93 return (FALSE); 98 exit (FALSE);
94 } 99 }
95 100
96 return (TRUE); 101 exit (TRUE);
97} 102}