aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2001-05-21 17:01:32 +0000
committerMatt Kraai <kraai@debian.org>2001-05-21 17:01:32 +0000
commit73991ff9255f8db5e1f7ff4f9b01016b00e8b9e6 (patch)
tree0bc9429a467468d7548aecc44e9c232c61866580
parentada18ff0f53f1b61073a843959e97c0f4206576e (diff)
downloadbusybox-73991ff9255f8db5e1f7ff4f9b01016b00e8b9e6.tar.gz
Fix tell support.
-rw-r--r--miscutils/mt.c15
-rw-r--r--mt.c15
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;
}