X-Git-Url: https://git.distorted.org.uk/~mdw/dvdrip/blobdiff_plain/32c8d7758d8c321f3d8eb8ec960bbc900c8fb5d6..d6845ac396b1f7ec5bba96b2c0e76ee1e389c754:/dvd-sector-copy.c diff --git a/dvd-sector-copy.c b/dvd-sector-copy.c index ea34461..2017689 100644 --- a/dvd-sector-copy.c +++ b/dvd-sector-copy.c @@ -3,7 +3,7 @@ static void usage(FILE *fp) { fprintf(fp, - "usage: %s [-c] [-B PARAM=VALUE,...] [-R MAP]\n" + "usage: %s [-ci] [-B PARAM=VALUE,...] [-R MAP]\n" "\t[-b OUTMAP] [-r [START]-[END]] DEVICE OUTFILE\n", prog); } @@ -955,7 +955,8 @@ int main(int argc, char *argv[]) struct timeval tv0, tv1; double t, rate, tot; const char *rateunit, *totunit; - char timebuf[TIMESTRMAX]; + char timebuf[TIMESTRMAX], id_in[MAXIDSZ], id_out[MAXIDSZ]; + dvd_reader_t *dvd_out; struct stat st; #ifdef DEBUG const struct file *file; @@ -966,11 +967,12 @@ int main(int argc, char *argv[]) #define f_continue 2u #define f_fixup 4u #define f_stats 8u +#define f_checkid 16u #define f_write 256u set_prog(argv[0]); for (;;) { - opt = getopt(argc, argv, "hB:E:FR:X:b:cr:s"); if (opt < 0) break; + opt = getopt(argc, argv, "hB:E:FR:X:b:cir:s"); if (opt < 0) break; switch (opt) { case 'h': usage(stderr); exit(0); case 'B': @@ -1109,6 +1111,16 @@ int main(int argc, char *argv[]) bail("device `%s' volume size %"PRIu64" not a multiple of %d", device, volsz, SECTORSZ); + if (f&f_checkid) { + open_dvd(outfile, 0, &dvd_out); + if (dvd_id(id_in, dvd, DIF_MUSTIFOHASH, device) || + dvd_id(id_out, dvd_out, DIF_MUSTIFOHASH, device)) + exit(2); + if (STRCMP(id_in, !=, id_out)) + bail("DVD id mismatch: input `%s' is `%s'; output `%s' is `%s'", + device, id_in, outfile, id_out); + } + outfd = open(outfile, O_WRONLY | O_CREAT, 0666); if (outfd < 0) bail_syserr(errno, "failed to create output file `%s'", outfile);