1 /* vi: set sw=4 ts=4: */
7 static const char mt_usage[] = "mt [-f device] opcode value\n\n"
8 "Control magnetic tape drive operation\n";
15 /* missing: eod/seod, stoptions, stwrthreshold, densities */
16 static const struct mt_opcodes opcodes[] = {
21 {"datacompression", MTCOMPRESSION},
33 {"rewoffline", MTOFFL},
38 {"retension", MTRETEN},
42 {"setdensity", MTSETDENSITY},
43 {"drvbuffer", MTSETDRVBUFFER},
44 {"setpart", MTSETPART},
54 extern int mt_main(int argc, char **argv)
56 const char *file = "/dev/tape";
57 const struct mt_opcodes *code = opcodes;
61 if ((argc != 2 && argc != 3) || **(argv + 1) == '-') {
65 if (strcmp(argv[1], "-f") == 0) {
74 while (code->name != 0) {
75 if (strcmp(code->name, argv[1]) == 0)
80 if (code->name == 0) {
81 fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]);
85 op.mt_op = code->value;
87 op.mt_count = atoi(argv[2]);
89 op.mt_count = 1; /* One, not zero, right? */
91 if ((fd = open(file, O_RDONLY, 0)) < 0) {
96 if (ioctl(fd, MTIOCTOP, &op) != 0) {