They're not really optional.
static void usage(FILE *fp)
{
fprintf(fp,
static void usage(FILE *fp)
{
fprintf(fp,
- "usage: %s [-c] [-D DEV] [-R MAP] "
- "[-b OUTMAP] [-o OUTFILE] [-r [START]-[END]]\n",
+ "usage: %s [-c] [-R MAP] [-b OUTMAP] [-r [START]-[END]]\n"
+ "\tDEVICE OUTFILE\n",
if (ferror(mapfp))
bail_syserr(errno, "error writing bad-sector map file");
}
if (ferror(mapfp))
bail_syserr(errno, "error writing bad-sector map file");
}
- if (outfd >= 0 &&
- lseek(outfd, (off_t)(bad_hi - bad_lo)*SECTORSZ, SEEK_CUR) < 0)
+ if (lseek(outfd, (off_t)(bad_hi - bad_lo)*SECTORSZ, SEEK_CUR) < 0)
bail_syserr(errno, "failed to seek past bad sectors");
status = 1;
}
bail_syserr(errno, "failed to seek past bad sectors");
status = 1;
}
off_t off;
secaddr start, end;
const struct event *ev;
off_t off;
secaddr start, end;
const struct event *ev;
- const char *device = "/dev/dvd", *outfile = 0;
+ const char *device, *outfile;
int opt, blksz;
unsigned n;
size_t i;
int opt, blksz;
unsigned n;
size_t i;
p = strrchr(argv[0], '/'); prog = p ? p + 1 : argv[0];
for (;;) {
p = strrchr(argv[0], '/'); prog = p ? p + 1 : argv[0];
for (;;) {
- opt = getopt(argc, argv, "hD:FR:b:co:r:"); if (opt < 0) break;
+ opt = getopt(argc, argv, "hFR:X:b:cr:"); if (opt < 0) break;
switch (opt) {
case 'h': usage(stderr); exit(0);
switch (opt) {
case 'h': usage(stderr); exit(0);
- case 'D': device = optarg; break;
case 'F': f |= f_fixup; break;
case 'R':
fp = fopen(optarg, "r");
case 'F': f |= f_fixup; break;
case 'R':
fp = fopen(optarg, "r");
mapfile = optarg;
break;
case 'c': f |= f_continue; break;
mapfile = optarg;
break;
case 'c': f |= f_continue; break;
- case 'o': outfile = optarg; break;
case 'r':
start = 0; end = -1;
if (parse_range(optarg, PRF_HYPHEN, &start, &end))
case 'r':
start = 0; end = -1;
if (parse_range(optarg, PRF_HYPHEN, &start, &end))
default: f |= f_bogus; break;
}
}
default: f |= f_bogus; break;
}
}
- if (optind < argc) f |= f_bogus;
+ if (argc - optind != 2) f |= f_bogus;
if (f&f_bogus) { usage(stderr); exit(2); }
if (f&f_bogus) { usage(stderr); exit(2); }
+ device = argv[optind]; outfile = argv[optind + 1];
+
dvdfd = open(device, O_RDONLY);
if (dvdfd < 0)
bail_syserr(errno, "failed to open device `%s'", device);
dvdfd = open(device, O_RDONLY);
if (dvdfd < 0)
bail_syserr(errno, "failed to open device `%s'", device);
- if (!outfile) bail("can't continue without output file");
off = lseek(outfd, 0, SEEK_END);
if (off < 0)
bail_syserr(errno, "failed to seek to end of output file `%s'",
off = lseek(outfd, 0, SEEK_END);
if (off < 0)
bail_syserr(errno, "failed to seek to end of output file `%s'",
break;
case EV_WRITE:
gettimeofday(&last_time, 0); last_pos = pos;
break;
case EV_WRITE:
gettimeofday(&last_time, 0); last_pos = pos;
- if (outfd >= 0 &&
- lseek(outfd, (off_t)ev->pos*SECTORSZ, SEEK_SET) < 0)
+ if (lseek(outfd, (off_t)ev->pos*SECTORSZ, SEEK_SET) < 0)
bail_syserr(errno,
"failed to seek to resume position "
"(sector %"PRIuSEC") in output file `%s'",
bail_syserr(errno,
"failed to seek to resume position "
"(sector %"PRIuSEC") in output file `%s'",
if (progresslen) putchar('\n');
if (progresslen) putchar('\n');
- if (outfd >= 0 && ftruncate(outfd, (off_t)limit*SECTORSZ) < 0)
+ if (ftruncate(outfd, (off_t)limit*SECTORSZ) < 0)
bail_syserr(errno, "failed to set output file `%s' length", outfile);
if (dvd) DVDClose(dvd);
bail_syserr(errno, "failed to set output file `%s' length", outfile);
if (dvd) DVDClose(dvd);
;;
nil)
if [ ! -f "$tmp/$tag/iso" ]; then
;;
nil)
if [ ! -f "$tmp/$tag/iso" ]; then
- run_setrc "$DVD_SECTOR_COPY" -D"$dev" -c -b"$tmp/$tag/badblocks" -o"$tmp/$tag/iso.new"
+ run_setrc "$DVD_SECTOR_COPY" -c -b"$tmp/$tag/badblocks" \
+ "$dev" "$tmp/$tag/iso.new"
case $rc in
0)
run mv "$tmp/$tag/iso.new" "$tmp/$tag/iso"
case $rc in
0)
run mv "$tmp/$tag/iso.new" "$tmp/$tag/iso"