1 /* vi: set sw=4 ts=4: */
7 static const char mt_usage[] = "mt [-f device] opcode value\n"
8 #ifndef BB_FEATURE_TRIVIAL_HELP
9 "\nControl magnetic tape drive operation\n"
18 /* missing: eod/seod, stoptions, stwrthreshold, densities */
19 static const struct mt_opcodes opcodes[] = {
24 {"datacompression", MTCOMPRESSION},
36 {"rewoffline", MTOFFL},
41 {"retension", MTRETEN},
45 {"setdensity", MTSETDENSITY},
46 {"drvbuffer", MTSETDRVBUFFER},
47 {"setpart", MTSETPART},
57 extern int mt_main(int argc, char **argv)
59 const char *file = "/dev/tape";
60 const struct mt_opcodes *code = opcodes;
64 if ((argc != 2 && argc != 3) && **(argv + 1) != '-') {
68 if (strcmp(argv[1], "-f") == 0) {
77 while (code->name != 0) {
78 if (strcmp(code->name, argv[1]) == 0)
83 if (code->name == 0) {
84 errorMsg("unrecognized opcode %s.\n", argv[1]);
88 op.mt_op = code->value;
90 op.mt_count = atoi(argv[2]);
92 op.mt_count = 1; /* One, not zero, right? */
94 if ((fd = open(file, O_RDONLY, 0)) < 0) {
99 if (ioctl(fd, MTIOCTOP, &op) != 0) {