Another, less magical solution occurred to me after I sent the previous
mail. Since dvd_stat is not actually used for anything, it's possible to
just check the file readability/availibility using access(2).

Patch below. I also slightly adjusted the error message.


--- lsdvd.c.orig        2005-08-04 00:45:31.000000000 +0300
+++ lsdvd.c     2005-08-04 00:51:31.000000000 +0300
@@ -15,10 +15,10 @@
  */
 #include <dvdread/ifo_read.h>
 #include <string.h>
-#include <sys/stat.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <errno.h>
 #include "lsdvd.h"

 static struct { char code[3];  char name[20];}
@@ -192,7 +192,6 @@
        char *dvd_device = "/dev/dvd";
        int has_title = 0, ret = 0;
        int max_length = 0, max_track = 0;
-       struct stat dvd_stat;

        program_name = argv[0];

@@ -225,9 +224,9 @@

        if (argv[optind]) { dvd_device = argv[optind];  }

-       ret = stat(dvd_device, &dvd_stat);
+       ret = access(dvd_device, R_OK);
        if ( ret < 0 ) {
-               fprintf(stderr, "Can't find device %s\n", dvd_device);
+               fprintf(stderr, "Can't open device %s: %s\n", dvd_device, 
strerror(errno));
                return 1;
        }


-- 
olli helenius <[EMAIL PROTECTED]> | [EMAIL PROTECTED] | [EMAIL PROTECTED]



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to