1 /* vi: set sw=4 ts=4: */
3 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
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 int mt_main(int argc, char **argv)
59 const char *file = "/dev/tape";
60 const struct mt_opcodes *code = opcodes;
62 struct mtpos position;
69 if (strcmp(argv[1], "-f") == 0) {
78 while (code->name != 0) {
79 if (strcmp(code->name, argv[1]) == 0)
84 if (code->name == 0) {
85 bb_error_msg("unrecognized opcode %s.", argv[1]);
89 op.mt_op = code->value;
91 op.mt_count = atoi(argv[2]);
93 op.mt_count = 1; /* One, not zero, right? */
95 switch (code->value) {
108 fd = bb_xopen3(file, mode, 0);
110 switch (code->value) {
112 if (ioctl(fd, MTIOCPOS, &position) < 0)
113 bb_perror_msg_and_die("%s", file);
114 printf ("At block %d.\n", (int) position.mt_blkno);
118 if (ioctl(fd, MTIOCTOP, &op) != 0)
119 bb_perror_msg_and_die("%s", file);