Fix tell support.

This commit is contained in:
Matt Kraai 2001-05-21 17:01:32 +00:00
parent ada18ff0f5
commit 73991ff925
2 changed files with 26 additions and 4 deletions

View File

@ -55,6 +55,7 @@ extern int mt_main(int argc, char **argv)
const char *file = "/dev/tape"; const char *file = "/dev/tape";
const struct mt_opcodes *code = opcodes; const struct mt_opcodes *code = opcodes;
struct mtop op; struct mtop op;
struct mtpos position;
int fd, mode; int fd, mode;
if (argc < 2) { if (argc < 2) {
@ -103,8 +104,18 @@ extern int mt_main(int argc, char **argv)
if ((fd = open(file, mode, 0)) < 0) if ((fd = open(file, mode, 0)) < 0)
perror_msg_and_die("%s", file); perror_msg_and_die("%s", file);
switch (code->value) {
case MTTELL:
if (ioctl(fd, MTIOCPOS, &position) < 0)
perror_msg_and_die("%s", file);
printf ("At block %d.\n", (int) position.mt_blkno);
break;
default:
if (ioctl(fd, MTIOCTOP, &op) != 0) if (ioctl(fd, MTIOCTOP, &op) != 0)
perror_msg_and_die("%s", file); perror_msg_and_die("%s", file);
break;
}
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

11
mt.c
View File

@ -55,6 +55,7 @@ extern int mt_main(int argc, char **argv)
const char *file = "/dev/tape"; const char *file = "/dev/tape";
const struct mt_opcodes *code = opcodes; const struct mt_opcodes *code = opcodes;
struct mtop op; struct mtop op;
struct mtpos position;
int fd, mode; int fd, mode;
if (argc < 2) { if (argc < 2) {
@ -103,8 +104,18 @@ extern int mt_main(int argc, char **argv)
if ((fd = open(file, mode, 0)) < 0) if ((fd = open(file, mode, 0)) < 0)
perror_msg_and_die("%s", file); perror_msg_and_die("%s", file);
switch (code->value) {
case MTTELL:
if (ioctl(fd, MTIOCPOS, &position) < 0)
perror_msg_and_die("%s", file);
printf ("At block %d.\n", (int) position.mt_blkno);
break;
default:
if (ioctl(fd, MTIOCTOP, &op) != 0) if (ioctl(fd, MTIOCTOP, &op) != 0)
perror_msg_and_die("%s", file); perror_msg_and_die("%s", file);
break;
}
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }