From 73991ff9255f8db5e1f7ff4f9b01016b00e8b9e6 Mon Sep 17 00:00:00 2001 From: Matt Kraai Date: Mon, 21 May 2001 17:01:32 +0000 Subject: [PATCH] Fix tell support. --- miscutils/mt.c | 15 +++++++++++++-- mt.c | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/miscutils/mt.c b/miscutils/mt.c index cd926272e..da01eb23f 100644 --- a/miscutils/mt.c +++ b/miscutils/mt.c @@ -55,6 +55,7 @@ extern int mt_main(int argc, char **argv) const char *file = "/dev/tape"; const struct mt_opcodes *code = opcodes; struct mtop op; + struct mtpos position; int fd, mode; if (argc < 2) { @@ -103,8 +104,18 @@ extern int mt_main(int argc, char **argv) if ((fd = open(file, mode, 0)) < 0) perror_msg_and_die("%s", file); - if (ioctl(fd, MTIOCTOP, &op) != 0) - 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) + perror_msg_and_die("%s", file); + break; + } return EXIT_SUCCESS; } diff --git a/mt.c b/mt.c index cd926272e..da01eb23f 100644 --- a/mt.c +++ b/mt.c @@ -55,6 +55,7 @@ extern int mt_main(int argc, char **argv) const char *file = "/dev/tape"; const struct mt_opcodes *code = opcodes; struct mtop op; + struct mtpos position; int fd, mode; if (argc < 2) { @@ -103,8 +104,18 @@ extern int mt_main(int argc, char **argv) if ((fd = open(file, mode, 0)) < 0) perror_msg_and_die("%s", file); - if (ioctl(fd, MTIOCTOP, &op) != 0) - 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) + perror_msg_and_die("%s", file); + break; + } return EXIT_SUCCESS; } -- 2.25.1