X-Git-Url: https://git.distorted.org.uk/~mdw/dvdrip/blobdiff_plain/af3973a19d5a28956010b8aba83daedf8c3ef71b..604a495002ac9390d760fffefcbe27372337cc38:/dvd-sector-copy.c diff --git a/dvd-sector-copy.c b/dvd-sector-copy.c index fd15138..03c2a0c 100644 --- a/dvd-sector-copy.c +++ b/dvd-sector-copy.c @@ -524,7 +524,6 @@ static void recovered(secaddr bad_lo, secaddr bad_hi) } if (lseek(outfd, (off_t)(bad_hi - bad_lo)*SECTORSZ, SEEK_CUR) < 0) bail_syserr(errno, "failed to seek past bad sectors"); - status = 1; } struct recoverybuf { @@ -663,6 +662,7 @@ static ssize_t recovery_read(struct recoverybuf *r, n = r->pos + r->end - pos; if (!n && want) n = -1; + else if (n > want) n = want; end: #ifdef DEBUG @@ -712,6 +712,12 @@ static ssize_t find_good_sector(secaddr *pos_inout, secaddr end, bad_lo = pos; bad_hi = pos + 1; for (;;) { report_bad_blocks_progress(bad_lo, bad_hi, errno); +#ifdef DEBUG + debug_clear_progress(); + printf(";; bounding bad-block region: " + "%"PRIuSEC" ..%"PRIuSEC".. %"PRIuSEC"\n", + bad_lo, bad_hi - bad_lo, bad_hi); +#endif if (bad_hi >= end) { clear_progress(); moan("giving up on this extent"); @@ -722,7 +728,6 @@ static ssize_t find_good_sector(secaddr *pos_inout, secaddr end, want = run_length_wanted(pos, step, sz, end); n = recovery_read(&r, pos, want); #ifdef DEBUG - debug_clear_progress(); printf(";; [bound] try reading %"PRIuSEC" .. %"PRIuSEC" -> %zd\n", pos, pos + want, n); #endif @@ -734,12 +739,17 @@ static ssize_t find_good_sector(secaddr *pos_inout, secaddr end, good = pos; while (good > bad_hi) { report_bad_blocks_progress(bad_lo, bad_hi, errno); +#ifdef DEBUG + debug_clear_progress(); + printf(";; limiting bad-block region: " + "%"PRIuSEC" ..%"PRIuSEC".. %"PRIuSEC" ..%"PRIuSEC".. %"PRIuSEC"\n", + bad_lo, bad_hi - bad_lo, bad_hi, good - bad_hi, good); +#endif pos = bad_hi + (good - bad_hi)/2; step = pos - bad_lo; want = run_length_wanted(pos, step, sz, end); n = recovery_read(&r, pos, want); #ifdef DEBUG - debug_clear_progress(); printf(";; [limit] try reading %"PRIuSEC" .. %"PRIuSEC" -> %zd\n", pos, pos + want, n); #endif @@ -923,7 +933,7 @@ static int parse_range(const char *p, unsigned f, { rc = -1; goto end; } if (!(f&PRF_HYPHEN)) while (ISSPACE(*p)) p++; - if (*p && ((f&PRF_HYPHEN) || *p != '=')) { rc = -1; goto end; } + if (*p && ((f&PRF_HYPHEN) || *p != '#')) { rc = -1; goto end; } rc = 0; end: