1 /* vi: set sw=4 ts=4: */
3 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
14 /* missing: eod/seod, stoptions, stwrthreshold, densities */
15 static const struct mt_opcodes opcodes[] = {
20 {"datacompression", MTCOMPRESSION},
32 {"rewoffline", MTOFFL},
37 {"retension", MTRETEN},
41 {"setdensity", MTSETDENSITY},
42 {"drvbuffer", MTSETDRVBUFFER},
43 {"setpart", MTSETPART},
53 int mt_main(int argc, char **argv);
54 int mt_main(int argc, char **argv)
56 const char *file = "/dev/tape";
57 const struct mt_opcodes *code = opcodes;
59 struct mtpos position;
66 if (strcmp(argv[1], "-f") == 0) {
75 while (code->name != 0) {
76 if (strcmp(code->name, argv[1]) == 0)
81 if (code->name == 0) {
82 bb_error_msg("unrecognized opcode %s", argv[1]);
86 op.mt_op = code->value;
88 op.mt_count = xatoi_u(argv[2]);
90 op.mt_count = 1; /* One, not zero, right? */
92 switch (code->value) {
105 fd = xopen(file, mode);
107 switch (code->value) {
109 ioctl_or_perror_and_die(fd, MTIOCPOS, &position, "%s", file);
110 printf("At block %d.\n", (int) position.mt_blkno);
114 ioctl_or_perror_and_die(fd, MTIOCTOP, &op, "%s", file);