1 /* vi: set sw=4 ts=4: */
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 extern int mt_main(int argc, char **argv)
55 const char *file = "/dev/tape";
56 const struct mt_opcodes *code = opcodes;
58 struct mtpos position;
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 error_msg("unrecognized opcode %s.", 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 switch (code->value) {
104 if ((fd = open(file, mode, 0)) < 0)
105 perror_msg_and_die("%s", file);
107 switch (code->value) {
109 if (ioctl(fd, MTIOCPOS, &position) < 0)
110 perror_msg_and_die("%s", file);
111 printf ("At block %d.\n", (int) position.mt_blkno);
115 if (ioctl(fd, MTIOCTOP, &op) != 0)
116 perror_msg_and_die("%s", file);