From: Matt Kraai Date: Mon, 21 May 2001 17:01:32 +0000 (-0000) Subject: Fix tell support. X-Git-Tag: 0_52~154 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=73991ff9255f8db5e1f7ff4f9b01016b00e8b9e6;p=oweals%2Fbusybox.git Fix tell support. --- 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; }