chkdvdimg.c: Open the image file with `open_dvd'.
[dvdrip] / dvd-sector-copy.c
index 4c19389..6f14bb5 100644 (file)
@@ -730,16 +730,16 @@ static ssize_t find_good_sector(secaddr *pos_inout, secaddr end,
     if (n == want) good = pos;
     else bad_hi = pos + n + 1;
   }
-  recovered(bad_lo, bad_hi); *pos_inout = good;
-  if (good < r.pos + r.start || r.pos + r.end <= good)
+  recovered(bad_lo, bad_hi); *pos_inout = bad_hi;
+  if (bad_hi < r.pos + r.start || r.pos + r.end <= bad_hi)
     n = 0;
   else {
-    n = r.pos + r.end - good;
-    rearrange_sectors(&r, 0, good - r.pos, n);
+    n = r.pos + r.end - bad_hi;
+    rearrange_sectors(&r, 0, bad_hi - r.pos, n);
   }
 #ifdef DEBUG
   show_recovery_buffer_map(&r, "returning %zd good sectors at %"PRIuSEC"",
-                          n, good);
+                          n, bad_hi);
 #endif
   return (n);
 }
@@ -1099,7 +1099,7 @@ int main(int argc, char *argv[])
 #endif
   }
 
-  open_dvd(device, &dvdfd, &dvd);
+  open_dvd(device, O_RDONLY, &dvdfd, &dvd);
 
   blksz = SECTORSZ; volsz = device_size(dvdfd, device, &blksz);
   if (blksz != SECTORSZ)
@@ -1109,7 +1109,7 @@ int main(int argc, char *argv[])
         device, volsz, SECTORSZ);
 
   if (f&f_checkid) {
-    open_dvd(outfile, 0, &dvd_out);
+    open_dvd(outfile, O_RDONLY, 0, &dvd_out);
     if (dvd_id(id_in, dvd, DIF_MUSTIFOHASH, device) ||
        dvd_id(id_out, dvd_out, DIF_MUSTIFOHASH, device))
       exit(2);