@@@ dvdrip-upload: change settings while i'm stealing someone else's internet
[dvdrip] / chkdvdimg.c
index 05fa7e1..3a94463 100644 (file)
@@ -4,8 +4,10 @@ static int status = 0;
 static unsigned flags = 0;
 #define F_FIX 1u
 
+static void set_status(int st)
+  { if (st > status) status = st; }
 static void vgripe_syserr(int st, int err, const char *fmt, va_list ap)
-  { vmoan_syserr(err, fmt, ap); if (st > status) status = st; }
+  { vmoan_syserr(err, fmt, ap); set_status(st); }
 static void vgripe(int st, const char *fmt, va_list ap)
   { vgripe_syserr(st, 0, fmt, ap); }
 PRINTF_LIKE(3, 4)
@@ -102,7 +104,8 @@ static void check_img(const char *file)
   secaddr end;
   unsigned i, j;
 
-  open_dvd(file, (flags&F_FIX) ? O_RDWR : O_RDONLY, &fd, 0);
+  if (open_dvd(file, (flags&F_FIX) ? O_RDWR : O_RDONLY, &fd, 0))
+    { set_status(2); goto end; }
   blksz = SECTORSZ; volsz = device_size(fd, file, &blksz);
   if (SECTORSZ != 2048)
     { gripe(2, "device sector size %d /= 2048", blksz); goto end; }