6 static const char mt_usage[] = "mt [-f device] opcode value\n";
13 /* missing: eod/seod, stoptions, stwrthreshold, densities */
14 static const struct mt_opcodes opcodes[] = {
19 { "datacompression", MTCOMPRESSION },
28 { "mkpart", MTMKPART },
31 { "rewoffline",MTOFFL },
36 { "retension", MTRETEN },
39 { "setblk", MTSETBLK },
40 { "setdensity", MTSETDENSITY },
41 { "drvbuffer", MTSETDRVBUFFER },
42 { "setpart", MTSETPART },
45 { "unload", MTUNLOAD },
46 { "unlock", MTUNLOCK },
53 mt_main(int argc, char** argv)
55 const char * file = "/dev/tape";
56 const struct mt_opcodes * code = opcodes;
60 if ( strcmp(argv[1], "-f") == 0 ) {
69 while ( code->name != 0 ) {
70 if ( strcmp(code->name, argv[1]) == 0 )
75 if ( code->name == 0 ) {
76 fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]);
80 op.mt_op = code->value;
82 op.mt_count = atoi(argv[2]);
84 op.mt_count = 1; /* One, not zero, right? */
86 if ( (fd = open(file, O_RDONLY, 0)) < 0 ) {
91 if ( ioctl(fd, MTIOCTOP, &op) != 0 ) {