summaryrefslogtreecommitdiff
path: root/audio/cdparanoia/patches/patch-cf
blob: 9c809695bd70448bddfcd50e585f94201b9dfb14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
$NetBSD: patch-cf,v 1.2 2000/06/22 00:41:18 wiz Exp $

--- interface/scan_devices.c.orig	Tue Dec 14 08:30:23 1999
+++ interface/scan_devices.c	Thu Jun 22 02:36:44 2000
@@ -17,6 +17,8 @@
 #include "common_interface.h"
 #include "utils.h"
 
+#ifdef __linux__
+
 #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};
@@ -28,10 +30,12 @@
 				/* "/dev/aztcd", timeout is too long */
 				"/dev/cm206cd",
 				"/dev/gscd","/dev/optcd",NULL};
+#endif
 
 /* Functions here look for a cdrom drive; full init of a drive type
    happens in interface.c */
 
+#ifdef __linux__
 cdrom_drive *cdda_find_a_cdrom(int messagedest,char **messages){
   /* Brute force... */
   
@@ -78,6 +82,16 @@
   }
   return(NULL);
 }
+#endif	/* __linux__ */
+
+#ifdef __NetBSD__
+
+cdrom_drive *cdda_find_a_cdrom(int messagedest,char **messages)
+{
+  errx(1, "cdda_find_a_cdrom: not implemented");
+  /* NOTREACHED */
+}
+#endif	/* __NetBSD__ */
 
 cdrom_drive *cdda_identify(const char *device, int messagedest,char **messages){
   struct stat st;
@@ -143,6 +157,7 @@
 cdrom_drive *cdda_identify_cooked(const char *dev, int messagedest,
 				  char **messages){
 
+#ifdef __linux__
   cdrom_drive *d=NULL;
   struct stat st;
   int fd=-1;
@@ -270,6 +285,12 @@
   idmessage(messagedest,messages,"\t\tCDROM sensed: %s\n",description);
   
   return(d);
+#endif
+
+#ifdef __NetBSD__
+  /* no kernel support for CD-DA */
+  return NULL;
+#endif
 }
 
 struct  sg_id {
@@ -289,12 +310,18 @@
 
 /* Even *this* isn't as simple as it bloody well should be :-P */
 static int get_scsi_id(int fd, scsiid *id){
+#ifdef __linux__
   struct sg_id argid;
+#endif
+#ifdef __NetBSD__
+  struct scsi_addr argid;
+#endif
   int busarg;
 
   /* get the host/id/lun */
 
   if(fd==-1)return(-1);
+#ifdef __linux__
   if(ioctl(fd,SCSI_IOCTL_GET_IDLUN,&argid))return(-1);
   id->bus=argid.l2; /* for now */
   id->id=argid.l1&0xff;
@@ -302,6 +329,13 @@
 
   if(ioctl(fd,SCSI_IOCTL_GET_BUS_NUMBER,&busarg)==0)
     id->bus=busarg;
+#endif
+#ifdef __NetBSD__
+  if(ioctl(fd,SCIOCIDENTIFY,&argid))return(-1);
+  id->bus=argid.addr.scsi.scbus;
+  id->id=argid.addr.scsi.target;
+  id->lun=argid.addr.scsi.lun;
+#endif
   
   return(0);
 }
@@ -410,6 +444,7 @@
 	       generic_device);
       return(NULL);
     }
+#ifdef __linux__
     if((int)(g_st.st_rdev>>8)!=SCSI_GENERIC_MAJOR){
       if((int)(g_st.st_rdev>>8)!=SCSI_CDROM_MAJOR){
 	idmessage(messagedest,messages,"\t\t%s is not a SCSI device",
@@ -421,6 +456,7 @@
 	ioctl_device=temp;
       }
     }
+#endif
   }
   if(ioctl_device){
     if(stat(ioctl_device,&i_st)){
@@ -428,6 +464,7 @@
 	       ioctl_device);
       return(NULL);
     }
+#ifdef __linux__
     if((int)(i_st.st_rdev>>8)!=SCSI_CDROM_MAJOR){
       if((int)(i_st.st_rdev>>8)!=SCSI_GENERIC_MAJOR){
 	idmessage(messagedest,messages,"\t\t%s is not a SCSI device",
@@ -439,6 +476,7 @@
 	ioctl_device=temp;
       }
     }
+#endif
   }
 
   /* we need to resolve any symlinks for the lookup code to work */
@@ -455,6 +493,7 @@
   }
 
   if(!generic_device || !ioctl_device){
+#ifdef __linux__
     if(generic_device){
       ioctl_device=scsi_match(generic_device,scsi_cdrom_prefixes,O_RDWR,
 			      O_RDONLY|O_NONBLOCK,
@@ -468,6 +507,9 @@
       if(!generic_device)	
 	goto cdda_identify_scsi_fail;
     }
+#else
+    goto cdda_identify_scsi_fail;
+#endif
   }
   
   idmessage(messagedest,messages,"\t\tgeneric device: %s",generic_device);
@@ -504,6 +546,7 @@
 
     type=(int)(i_st.st_rdev>>8);
 
+#ifdef __linux__
     if(type==SCSI_CDROM_MAJOR){
       if (!S_ISBLK(i_st.st_mode)) {
 	idmessage(messagedest,messages,"\t\tSCSI CDROM device %s not a "
@@ -515,8 +558,10 @@
 		"major number",ioctl_device);
       goto cdda_identify_scsi_fail;
     }
+#endif
   }
 
+#ifdef __linux__
   if((int)(g_st.st_rdev>>8)==SCSI_GENERIC_MAJOR){
     if (!S_ISCHR(g_st.st_mode)) {
       idmessage(messagedest,messages,"\t\tGeneric SCSI device %s not a "
@@ -528,6 +573,7 @@
 	      "major number",generic_device);
     goto cdda_identify_scsi_fail;
   }
+#endif
   
   d=calloc(1,sizeof(cdrom_drive));
 
@@ -564,7 +610,16 @@
 
   /* It would seem some TOSHIBA CDROM gets things wrong */
  
-  if (!strncmp (p + 8, "TOSHIBA", 7) &&
+#ifndef TYPE_DISK
+#define TYPE_DISK	0	/* direct */
+#endif
+#ifndef TYPE_WORM
+#define TYPE_WORM	4	/* write once, read many */
+#endif
+#ifndef TYPE_ROM
+#define TYPE_ROM	5	/* CD-ROM */
+#endif
+  if (p && !strncmp (p + 8, "TOSHIBA", 7) &&
       !strncmp (p + 16, "CD-ROM", 6) &&
       p[0] == TYPE_DISK) {
     p[0] = TYPE_ROM;