summaryrefslogtreecommitdiff
path: root/usr.bin/cdio
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/cdio')
-rw-r--r--usr.bin/cdio/mmc.c8
-rw-r--r--usr.bin/cdio/rip.c20
2 files changed, 21 insertions, 7 deletions
diff --git a/usr.bin/cdio/mmc.c b/usr.bin/cdio/mmc.c
index 2e5e892b698..b0390c214ed 100644
--- a/usr.bin/cdio/mmc.c
+++ b/usr.bin/cdio/mmc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mmc.c,v 1.16 2006/08/28 02:36:43 mjc Exp $ */
+/* $OpenBSD: mmc.c,v 1.17 2007/07/31 21:21:11 deraadt Exp $ */
/*
* Copyright (c) 2006 Michael Coulter <mjc@openbsd.org>
@@ -223,7 +223,7 @@ writetrack(struct track_info *tr, int track)
again:
r = ioctl(fd, SCIOCCOMMAND, &scr);
if (r != 0) {
- printf("%60s\r", "");
+ printf("\r%60s", "");
warn("ioctl failed while attempting to write");
return (-1);
}
@@ -232,7 +232,7 @@ again:
goto again;
}
if (scr.retsts != SCCMD_OK) {
- printf("%60s\r", "");
+ printf("\r%60s", "");
warnx("ioctl returned bad status while "
"attempting to write: %d",
scr.retsts);
@@ -243,7 +243,7 @@ again:
gettimeofday(&tv, NULL);
if (lba == end_lba || timercmp(&tv, &otv, >)) {
fprintf(stderr,
- "track %02d '%c' %08u/%08u %3d%%\r",
+ "\rtrack %02d '%c' %08u/%08u %3d%%",
track, tr->type,
lba, end_lba, 100 * lba / end_lba);
timeradd(&tv, &atv, &otv);
diff --git a/usr.bin/cdio/rip.c b/usr.bin/cdio/rip.c
index db26a990e04..0d5997b4c94 100644
--- a/usr.bin/cdio/rip.c
+++ b/usr.bin/cdio/rip.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: rip.c,v 1.6 2007/07/31 21:21:11 deraadt Exp $ */
+
/*
* Copyright (c) 2007 Alexey Vatchenko <av@bsdua.org>
*
@@ -356,6 +358,7 @@ read_data_sector(u_int32_t lba, u_char *sec, u_int32_t secsize)
int
read_track(int fd, struct track_info *ti)
{
+ struct timeval tv, otv, atv;
u_int32_t i, blksize, n_sec;
u_char *sec;
int error;
@@ -366,9 +369,19 @@ read_track(int fd, struct track_info *ti)
if (sec == NULL)
return (-1);
+ timerclear(&otv);
+ atv.tv_sec = 1;
+ atv.tv_usec = 0;
+
for (i = 0; i < n_sec; ) {
- fprintf(stderr, "track %u '%c' %08u/%08u %3u%%\r", ti->track,
- (ti->isaudio) ? 'a' : 'd', i, n_sec, 100 * i / n_sec);
+ gettimeofday(&tv, NULL);
+ if (timercmp(&tv, &otv, >)) {
+ fprintf(stderr, "\rtrack %u '%c' %08u/%08u %3u%%",
+ ti->track,
+ (ti->isaudio) ? 'a' : 'd', i, n_sec,
+ 100 * i / n_sec);
+ timeradd(&tv, &atv, &otv);
+ }
error = read_data_sector(i + ti->start_lba, sec, blksize);
if (error == 0) {
@@ -388,7 +401,8 @@ read_track(int fd, struct track_info *ti)
}
free(sec);
- fprintf(stderr, "track %u '%c' %08u/%08u 100%%\n", ti->track,
+ fprintf(stderr, "\rtrack %u '%c' %08u/%08u 100%%\n",
+ ti->track,
(ti->isaudio) ? 'a' : 'd', i, n_sec);
return (0);
}