[xiph-cvs] cvs commit: paranoia-III/paranoia paranoia.c

Monty xiphmont at xiph.org
Sun Mar 25 21:44:02 PST 2001



xiphmont    01/03/25 21:44:02

  Modified:    interface low_interface.h scan_devices.c
               paranoia paranoia.c
  Log:
  That should do it for 9.8; we have correct /devfs scanning, with or
  without devfsd and with minimal change.
  
  Monty

Revision  Changes    Path
1.9       +2 -3      paranoia-III/interface/low_interface.h

Index: low_interface.h
===================================================================
RCS file: /usr/local/cvsroot/paranoia-III/interface/low_interface.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- low_interface.h	1999/12/02 07:19:53	1.8
+++ low_interface.h	2001/03/26 05:44:01	1.9
@@ -42,9 +42,8 @@
 #define CDROMAUDIOBUFSIZ        0x5382 /* set the audio buffer size */
 #endif
 
-/* easiest as many dists don't make proper symlinks */
-#include <linux/../scsi/sg.h>
-#include <linux/../scsi/scsi.h>
+#include <linux/scsi/sg.h>
+#include <linux/scsi/scsi.h>
 
 #include <linux/cdrom.h>
 #include <linux/major.h>

1.18      +59 -34    paranoia-III/interface/scan_devices.c

Index: scan_devices.c
===================================================================
RCS file: /usr/local/cvsroot/paranoia-III/interface/scan_devices.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- scan_devices.c	2001/03/26 03:44:51	1.17
+++ scan_devices.c	2001/03/26 05:44:01	1.18
@@ -6,8 +6,10 @@
  * 
  ******************************************************************/
 
+#include <limits.h>
 #include <stdio.h>
 #include <unistd.h>
+#include <stdlib.h>
 #include <ctype.h>
 #include <pwd.h>
 #include <sys/stat.h>
@@ -19,16 +21,34 @@
 
 #define MAX_DEV_LEN 20 /* Safe because strings only come from below */
 /* must be absolute paths! */
-static char *scsi_cdrom_prefixes[3]={"/dev/scd","/dev/sr",NULL};
-static char *scsi_generic_prefixes[2]={"/dev/sg",NULL};
-static char *cdrom_devices[]={"/dev/cdrom","/dev/hd?","/dev/sg?",
-				"/dev/cdroms/cdrom?",
-				"/dev/cdu31a","/dev/cdu535",
-				"/dev/sbpcd","/dev/sbpcd?","/dev/sonycd",
-				"/dev/mcd","/dev/sjcd",
-				/* "/dev/aztcd", timeout is too long */
-				"/dev/cm206cd",
-				"/dev/gscd","/dev/optcd",NULL};
+static char *scsi_cdrom_prefixes[]={
+  "/dev/scd",
+  "/dev/sr",
+  NULL};
+static char *scsi_generic_prefixes[]={
+  "/dev/sg",
+  NULL};
+
+static char *devfs_scsi_test="/dev/scsi/";
+static char *devfs_scsi_cd="cd";
+static char *devfs_scsi_generic="generic";
+
+static char *cdrom_devices[]={
+  "/dev/cdrom",
+  "/dev/cdroms/cdrom?",
+  "/dev/hd?",
+  "/dev/sg?",
+  "/dev/cdu31a",
+  "/dev/cdu535",
+  "/dev/sbpcd",
+  "/dev/sbpcd?",
+  "/dev/sonycd",
+  "/dev/mcd",
+  "/dev/sjcd",
+  /* "/dev/aztcd", timeout is too long */
+  "/dev/cm206cd",
+  "/dev/gscd",
+  "/dev/optcd",NULL};
 
 /* Functions here look for a cdrom drive; full init of a drive type
    happens in interface.c */
@@ -108,36 +128,19 @@
 }
 
 char *test_resolve_symlink(const char *file,int messagedest,char **messages){
+  char resolved[PATH_MAX];
   struct stat st;
   if(lstat(file,&st)){
     idperror(messagedest,messages,"\t\tCould not stat %s",file);
     return(NULL);
   }
-  if(S_ISLNK(st.st_mode)){
-    char buf[1024];
-    int status=readlink(file,buf,1023);
-    if(status==-1){
-      idperror(messagedest,messages,"\t\tCould not resolve symlink %s",file);
-      return(NULL);
-    }
-    buf[status]=0;
 
-    /* Uh, oh Clem... them rustlers might be RELATIVE! */
-    if(buf[0]!='/'){
-      /* Yupper. */
-      char *ret=copystring(file);
-      char *pos=strrchr(ret,'/');
-      if(pos){
-	pos[1]='\0';
-	ret=catstring(ret,buf);
-	return(ret);
-      }
-      free(ret);
-    }
-    return(copystring(buf));
+  if(realpath(file,resolved))
+    return(strdup(resolved));
 
-  }
-  return(copystring(file));
+  idperror(messagedest,messages,"\t\tCould not resolve symlink %s",file);
+  return(NULL);
+
 }
 
 cdrom_drive *cdda_identify_cooked(const char *dev, int messagedest,
@@ -305,12 +308,32 @@
 
 /* slightly wasteful, but a clean abstraction */
 static char *scsi_match(const char *device,char **prefixes,
+			char *devfs_test,
+			char *devfs_other,
                         char *prompt,int messagedest,char **messages){
   int dev=open(device,O_RDONLY|O_NONBLOCK);
   scsiid a,b;
 
   int i,j;
-  char buffer[80];
+  char buffer[200];
+
+  /* if we're running under /devfs, build the device name from the
+     device we already have */
+  if(!strncmp(device,devfs_test,strlen(devfs_test))){
+    char *pos;
+    strcpy(buffer,device);
+    pos=strrchr(buffer,'/');
+    if(pos){
+      int matchf;
+      sprintf(pos,"/%s",devfs_other);
+      matchf=open(buffer,O_RDONLY|O_NONBLOCK);
+      if(matchf!=-1){
+	close(matchf);
+	close(dev);
+	return(strdup(buffer));
+      }
+    }
+  }	
 
   /* get the host/id/lun */
   if(dev==-1){
@@ -485,11 +508,13 @@
     if(generic_device){
       ioctl_device=
         scsi_match(generic_device,scsi_cdrom_prefixes,
+		   devfs_scsi_test,devfs_scsi_cd,
                    "\t\tNo cdrom device found to match generic device %s",
                    messagedest,messages);
     }else{
       generic_device=
         scsi_match(ioctl_device,scsi_generic_prefixes,
+		   devfs_scsi_test,devfs_scsi_generic,
                    "\t\tNo generic SCSI device found to match CDROM device %s",
                    messagedest,messages);
       if(!generic_device)	

1.20      +15 -15    paranoia-III/paranoia/paranoia.c

Index: paranoia.c
===================================================================
RCS file: /usr/local/cvsroot/paranoia-III/paranoia/paranoia.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- paranoia.c	2001/03/24 01:15:47	1.19
+++ paranoia.c	2001/03/26 05:44:02	1.20
@@ -343,7 +343,7 @@
 
   while(ptr && ptr!=new){
 
-    (*callback)(cb(new),PARANOIA_CB_VERIFY);
+    if(callback)(*callback)(cb(new),PARANOIA_CB_VERIFY);
     i_iterate_stage1(p,ptr,new,callback);
 
     ptr=c_prev(ptr);
@@ -392,7 +392,7 @@
   if(min(fe(v)+p->dynoverlap,re(root))-
     max(fb(v)-p->dynoverlap,rb(root))<=0)return(0);
 
-  (*callback)(fb(v),PARANOIA_CB_VERIFY);
+  if(callback)(*callback)(fb(v),PARANOIA_CB_VERIFY);
 
   /* just a bit of v; determine the correct area */
   fbv=max(fb(v),rb(root)-p->dynoverlap);
@@ -421,7 +421,7 @@
         r->begin=matchbegin;
         r->end=matchend;
         r->offset=-offset;
-	if(offset)(*callback)(r->begin,PARANOIA_CB_FIXUP_EDGE);
+	if(offset)if(callback)(*callback)(r->begin,PARANOIA_CB_FIXUP_EDGE);
         return(1);
       }
     }
@@ -568,7 +568,7 @@
           /* a problem with root */
           if(matchA>0){
             /* dropped bytes; add back from v */
-	    (*callback)(begin+rb(root)-1,PARANOIA_CB_FIXUP_DROPPED);
+	    if(callback)(*callback)(begin+rb(root)-1,PARANOIA_CB_FIXUP_DROPPED);
             if(rb(root)+begin<p->root.returnedlimit)
               break;
             else{
@@ -580,7 +580,7 @@
             }
           }else{
             /* duplicate bytes; drop from root */
-	    (*callback)(begin+rb(root)-1,PARANOIA_CB_FIXUP_DUPED);
+	    if(callback)(*callback)(begin+rb(root)-1,PARANOIA_CB_FIXUP_DUPED);
             if(rb(root)+begin+matchA<p->root.returnedlimit) 
               break;
             else{
@@ -594,13 +594,13 @@
           /* a problem with the fragment */
           if(matchB>0){
             /* dropped bytes */
-	    (*callback)(begin+rb(root)-1,PARANOIA_CB_FIXUP_DROPPED);
+	    if(callback)(*callback)(begin+rb(root)-1,PARANOIA_CB_FIXUP_DROPPED);
             c_insert(l,beginL,rv(root)+begin-matchB,
                          matchB);
             offset+=matchB;
           }else{
             /* duplicate bytes */
-	    (*callback)(begin+rb(root)-1,PARANOIA_CB_FIXUP_DUPED);
+	    if(callback)(*callback)(begin+rb(root)-1,PARANOIA_CB_FIXUP_DUPED);
             c_remove(l,beginL+matchB,-matchB);
             offset+=matchB;
           }
@@ -658,13 +658,13 @@
           /* a problem with root */
           if(matchA>0){
             /* dropped bytes; add back from v */
-	    (*callback)(end+rb(root),PARANOIA_CB_FIXUP_DROPPED);
+	    if(callback)(*callback)(end+rb(root),PARANOIA_CB_FIXUP_DROPPED);
             if(end+rb(root)<p->root.returnedlimit)
               break;
             c_insert(rc(root),end,cv(l)+endL,matchA);
           }else{
             /* duplicate bytes; drop from root */
-	    (*callback)(end+rb(root),PARANOIA_CB_FIXUP_DUPED);
+	    if(callback)(*callback)(end+rb(root),PARANOIA_CB_FIXUP_DUPED);
             if(end+rb(root)<p->root.returnedlimit)
               break;
             c_remove(rc(root),end,-matchA);
@@ -673,11 +673,11 @@
           /* a problem with the fragment */
           if(matchB>0){
             /* dropped bytes */
-	    (*callback)(end+rb(root),PARANOIA_CB_FIXUP_DROPPED);
+	    if(callback)(*callback)(end+rb(root),PARANOIA_CB_FIXUP_DROPPED);
             c_insert(l,endL,rv(root)+end,matchB);
           }else{
             /* duplicate bytes */
-	    (*callback)(end+rb(root),PARANOIA_CB_FIXUP_DUPED);
+	    if(callback)(*callback)(end+rb(root),PARANOIA_CB_FIXUP_DUPED);
             c_remove(l,endL,-matchB);
           }
         }else if(matchC){
@@ -927,7 +927,7 @@
   }
   if(post==-1)post=0;
 
-  (*callback)(post,PARANOIA_CB_SKIP);
+  if(callback)(*callback)(post,PARANOIA_CB_SKIP);
   
   /* We want to add a sector.  Look for a c_block that spans,
      preferrably a verified area */
@@ -1139,7 +1139,7 @@
         /* Uhhh... right.  Make something up. But don't make us seek
            backward! */
 
-	(*callback)((adjread+thisread)*CD_FRAMEWORDS,PARANOIA_CB_READERR);  
+	if(callback)(*callback)((adjread+thisread)*CD_FRAMEWORDS,PARANOIA_CB_READERR);  
         memset(buffer+(sofar+thisread)*CD_FRAMEWORDS,0,
                CD_FRAMESIZE_RAW*(secread-thisread));
         if(flags)memset(flags+(sofar+thisread)*CD_FRAMEWORDS,2,
@@ -1160,7 +1160,7 @@
       if(adjread+secread-1==p->current_lastsector)
         new->lastsector=-1;
       
-      (*callback)((adjread+secread-1)*CD_FRAMEWORDS,PARANOIA_CB_READ);
+      if(callback)(*callback)((adjread+secread-1)*CD_FRAMEWORDS,PARANOIA_CB_READ);
       
       sofar+=secread;
       readat=adjread+secread; 
@@ -1299,7 +1299,7 @@
             p->dynoverlap*=1.5;
             if(p->dynoverlap>MAX_SECTOR_OVERLAP*CD_FRAMEWORDS)
               p->dynoverlap=MAX_SECTOR_OVERLAP*CD_FRAMEWORDS;
-	    (*callback)(p->dynoverlap,PARANOIA_CB_OVERLAP);
+	    if(callback)(*callback)(p->dynoverlap,PARANOIA_CB_OVERLAP);
           }
         }
       }

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list