Subject: pkg/6391: cdd only supports cd0
To: None <gnats-bugs@gnats.netbsd.org>
From: None <rh@idle.trapdoor.vip.at>
List: netbsd-bugs
Date: 11/01/1998 21:22:08
>Number:         6391
>Category:       pkg
>Synopsis:       The cdd package currently only supports cd0
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Nov  1 12:35:00 1998
>Last-Modified:
>Originator:     Rene Hexel
>Organization:
	
>Release:        NetBSD-1.3.2
>Environment:
	
System: NetBSD idle 1.3.2 NetBSD 1.3.2 (IDLE) #60: Sun Oct 25 08:23:58 CET 1998 rh@idle:/usr/local/sys/src/sys/arch/i386/compile/IDLE i386


>Description:
	The current version of the cdd package (cdd-1.0myc2) only opens
/dev/rcd0d.  This is hardcoded in the source code.  Furthermore, 'cdd -h'
(help screen) only works if a cd is inserted in cd0.

>How-To-Repeat:
	# cd /usr/pkgsrc/audio/cdd
	# make install
	# rehash
	# cdd -h

>Fix:
	Drop in the following patch as patches/patch-ab ...


--- cdd.h.orig	Mon Jul 14 02:56:31 1997
+++ cdd.h	Sun Nov  1 19:18:58 1998
@@ -85,6 +85,7 @@
     int bequiet;
     int dostdout;
     int cddb;
+    char cddev[MAXPATHLEN];
     } OPTS;
 
 typedef struct tocentry


	... and the following patch as patches/patch-ac.  This fixes
both bugs.


--- cdd.c.orig	Mon Mar 30 21:40:59 1998
+++ cdd.c	Sun Nov  1 19:50:26 1998
@@ -73,6 +73,7 @@
 {
 CDTOC cdtoc;
 int count;
+char ctldev[MAXPATHLEN];
 
 strcpy(G_opts.workdir, "/tmp");
 G_opts.onlyaudio = FALSE;
@@ -83,27 +84,12 @@
 G_opts.bequiet = FALSE;
 G_opts.dostdout = FALSE;
 G_opts.cddb = FALSE;
+strcpy(G_opts.cddev, "cd0");
 
 signal(SIGINT, resetcd);
 signal(SIGBUS, resetcd);
 signal(SIGSEGV, resetcd);
 
-#ifdef __NetBSD__
-F_cdctlfd=scsi_open("/dev/rcd0d", O_RDWR);
-#else
-F_cdctlfd=scsi_open("/dev/rcd0.ctl", O_RDWR);
-#endif
-
-if(F_cdctlfd < 0)
-    {
-#ifdef __NetBSD__
-    fprintf(stderr,"Unable to open /dev/rcd0d [%d]\n", errno);
-#else
-    fprintf(stderr,"Unable to open /dev/rcd0.ctl [%d]\n", errno);
-#endif
-    exit(0);
-    }
-
 for(count=1;count<argc;count++)
     {
     if(argv[count][0] != '-') strcpy(G_opts.workdir, argv[count]);
@@ -126,7 +112,6 @@
         if(count+1 == argc)
             {
             fprintf(stderr,"Copy what track ?\n");
-            close(F_cdctlfd);
             exit(0);
             }
 
@@ -134,14 +119,27 @@
         count++;
         }
 
+    if(strncasecmp(argv[count],"-c", 2) == 0)
+        {
+        if(count+1 == argc)
+            {
+            fprintf(stderr,"Use which device ?\n");
+            exit(0);
+            }
+
+        strncpy(G_opts.cddev, argv[count+1], sizeof(G_opts.cddev)-1);
+        count++;
+        }
+
     if(strncasecmp(argv[count],"-h", 2) == 0) 
         {
         fprintf(stderr,"\nCDD v%s, Copyright (C) 1996, ", VERSION);
         fprintf(stderr,"Charles R. Henrich, All Rights Reserved.\n\n");
 
-        fprintf(stderr,"Usage: %s [-t #][-a][-d][-r][-n][-noed][-h]", argv[0]);
+        fprintf(stderr,"Usage: %s [-t #][-c <dev>][-a][-d][-r][-n][-noed][-h]", argv[0]);
         fprintf(stderr,"[-p][-q][destdir|-]\n\n");
         fprintf(stderr,"    -h      This help\n");
+        fprintf(stderr,"    -c dev  Use CD-ROM drive <dev> (default: %s)\n", G_opts.cddev);
         fprintf(stderr,"    -t #    Copy only Track #\n");
         fprintf(stderr,"    -a      Copy only AUDIO tracks\n");
         fprintf(stderr,"    -p      Play AUDIO during Copy\n");
@@ -155,11 +153,27 @@
         fprintf(stderr,"any error checking\n\n");
         fprintf(stderr,"Running CDD with no options will show the table of ");
         fprintf(stderr,"contents of the CD in the \ndrive\n\n");
-        close(F_cdctlfd);
         exit(0);
         }
     }
 
+#ifdef __NetBSD__
+if (G_opts.cddev[0] == '/')
+  strcpy(ctldev, G_opts.cddev);
+else
+  sprintf(ctldev, "/dev/r%sd", G_opts.cddev);
+#else
+sprintf(ctldev, "/dev/r%s.ctl", G_opts.cddev);
+#endif
+
+F_cdctlfd=scsi_open(ctldev, O_RDWR);
+
+if(F_cdctlfd < 0)
+    {
+    fprintf(stderr,"Unable to open %s [%d]\n", ctldev, errno);
+    exit(0);
+    }
+
 cdd_printf("\nCDD v%s, Copyright (C) 1996, ", VERSION);
 cdd_printf("Charles R. Henrich, All Rights Reserved.\n\n");
 
@@ -367,7 +381,8 @@
 #ifdef __NetBSD__
 ifd=dup(F_cdctlfd);
 #else
-ifd=open("/dev/rcd0c", O_RDONLY, 0600);
+sprintf(buffer, "/dev/r%sc", G_opts.cddev);
+ifd=open(buffer, O_RDONLY, 0600);
 #endif
 
 if(ifd < 0)
@@ -375,7 +390,7 @@
 #ifdef __NetBSD__
     fprintf(stderr,"Unable to dup descriptor\n");
 #else
-    fprintf(stderr,"Unable to open /dev/rcd0c\n");
+    fprintf(stderr,"Unable to open %s\n", buffer);
 #endif
     close(F_cdctlfd);
     exit(0);
@@ -435,7 +450,8 @@
 #ifdef __NetBSD__
 ifd=dup(F_cdctlfd);
 #else
-ifd=open("/dev/rcd0c", O_RDONLY);
+sprintf(buffer, "/dev/r%sc", G_opts.cddev);
+ifd=open(buffer, O_RDONLY);
 #endif
 
 if(ifd < 0)
@@ -443,7 +459,7 @@
 #ifdef __NetBSD__
     fprintf(stderr,"Unable to dup descriptor\n");
 #else
-    fprintf(stderr,"Unable to open /dev/rcd0c\n");
+    fprintf(stderr,"Unable to open %s\n", buffer);
 #endif
     close(F_cdctlfd);
     exit(0);
>Audit-Trail:
>Unformatted: