Tue May 19 00:36:06 2009 UTC ()
Simplify previous. We don't need to call getrawpartition() to find out
whether to use /dev/rcd0c or /dev/rcd0d; we can just try both. This
avoids needing libutil in libcdda_interface.so. Fixes broken build of
mplayer (and others?) without needing a recursive revbump as adding
libutil would have. PKGREVISION++ (now 8).


(dholland)
diff -r1.26 -r1.27 pkgsrc/audio/cdparanoia/Makefile
diff -r1.21 -r1.22 pkgsrc/audio/cdparanoia/distinfo
diff -r1.8 -r1.9 pkgsrc/audio/cdparanoia/patches/patch-ab
diff -r1.6 -r1.7 pkgsrc/audio/cdparanoia/patches/patch-ca
diff -r1.9 -r1.10 pkgsrc/audio/cdparanoia/patches/patch-cf

cvs diff -r1.26 -r1.27 pkgsrc/audio/cdparanoia/Makefile (expand / switch to unified diff)

--- pkgsrc/audio/cdparanoia/Makefile 2009/05/17 21:29:33 1.26
+++ pkgsrc/audio/cdparanoia/Makefile 2009/05/19 00:36:06 1.27
@@ -1,19 +1,19 @@ @@ -1,19 +1,19 @@
1# $NetBSD: Makefile,v 1.26 2009/05/17 21:29:33 dholland Exp $ 1# $NetBSD: Makefile,v 1.27 2009/05/19 00:36:06 dholland Exp $
2# 2#
3 3
4DISTNAME= cdparanoia-III-alpha9.8 4DISTNAME= cdparanoia-III-alpha9.8
5PKGNAME= cdparanoia-3.0.9.8 5PKGNAME= cdparanoia-3.0.9.8
6PKGREVISION= 7 6PKGREVISION= 8
7CATEGORIES= audio 7CATEGORIES= audio
8MASTER_SITES= http://www.xiph.org/paranoia/download/ 8MASTER_SITES= http://www.xiph.org/paranoia/download/
9EXTRACT_SUFX= .src.tgz 9EXTRACT_SUFX= .src.tgz
10 10
11MAINTAINER= kim@tac.nyc.ny.us 11MAINTAINER= kim@tac.nyc.ny.us
12HOMEPAGE= http://www.xiph.org/paranoia/ 12HOMEPAGE= http://www.xiph.org/paranoia/
13COMMENT= CDDA reading utility with extra data verification features 13COMMENT= CDDA reading utility with extra data verification features
14 14
15ONLY_FOR_PLATFORM= FreeBSD-*-* NetBSD-*-* Linux-*-* DragonFly-*-* Darwin-*-* 15ONLY_FOR_PLATFORM= FreeBSD-*-* NetBSD-*-* Linux-*-* DragonFly-*-* Darwin-*-*
16 16
17PKG_INSTALLATION_TYPES= overwrite pkgviews 17PKG_INSTALLATION_TYPES= overwrite pkgviews
18PKG_DESTDIR_SUPPORT= user-destdir 18PKG_DESTDIR_SUPPORT= user-destdir
19 19

cvs diff -r1.21 -r1.22 pkgsrc/audio/cdparanoia/distinfo (expand / switch to unified diff)

--- pkgsrc/audio/cdparanoia/distinfo 2009/05/17 21:29:33 1.21
+++ pkgsrc/audio/cdparanoia/distinfo 2009/05/19 00:36:06 1.22
@@ -1,25 +1,25 @@ @@ -1,25 +1,25 @@
1$NetBSD: distinfo,v 1.21 2009/05/17 21:29:33 dholland Exp $ 1$NetBSD: distinfo,v 1.22 2009/05/19 00:36:06 dholland Exp $
2 2
3SHA1 (cdparanoia-III-alpha9.8.src.tgz) = 04cc33a7d22d6255f6239e3e74195506b3bdde06 3SHA1 (cdparanoia-III-alpha9.8.src.tgz) = 04cc33a7d22d6255f6239e3e74195506b3bdde06
4RMD160 (cdparanoia-III-alpha9.8.src.tgz) = d9225165f83b5386c58db263d6918a7006df1481 4RMD160 (cdparanoia-III-alpha9.8.src.tgz) = d9225165f83b5386c58db263d6918a7006df1481
5Size (cdparanoia-III-alpha9.8.src.tgz) = 116591 bytes 5Size (cdparanoia-III-alpha9.8.src.tgz) = 116591 bytes
6SHA1 (patch-aa) = 29fd5767b37360fe804013bb171fc7e5f4d8311f 6SHA1 (patch-aa) = 29fd5767b37360fe804013bb171fc7e5f4d8311f
7SHA1 (patch-ab) = fcbeaf7f3e1318ef8bcc8742adec3a3a7efc937e 7SHA1 (patch-ab) = d02dd70c45ec97e859c024d11d7bc74c79d96f62
8SHA1 (patch-ac) = 6bd7ad7a0e8bcd1f8354c73706cafb0e789b8252 8SHA1 (patch-ac) = 6bd7ad7a0e8bcd1f8354c73706cafb0e789b8252
9SHA1 (patch-ad) = 9a1ea1b98b5f3810e1ccae57beb8c68b5e189716 9SHA1 (patch-ad) = 9a1ea1b98b5f3810e1ccae57beb8c68b5e189716
10SHA1 (patch-ae) = 59d74c0392d5bcc37299326efa8ba700722d5cf4 10SHA1 (patch-ae) = 59d74c0392d5bcc37299326efa8ba700722d5cf4
11SHA1 (patch-ba) = 51151796493c946e5bdafbd22005136ea7f27a09 11SHA1 (patch-ba) = 51151796493c946e5bdafbd22005136ea7f27a09
12SHA1 (patch-ca) = 433b7ddd7d1cf0123dadfdff8e550381eaf51f22 12SHA1 (patch-ca) = 9c35254c09a96b622cac44198443f66f7bc0e428
13SHA1 (patch-cb) = c19ee04017b836842bb0f2d2c77e8f35aad0f9bb 13SHA1 (patch-cb) = c19ee04017b836842bb0f2d2c77e8f35aad0f9bb
14SHA1 (patch-cc) = adea4fd9682c0543e5749c6f3fe73697d8663c6c 14SHA1 (patch-cc) = adea4fd9682c0543e5749c6f3fe73697d8663c6c
15SHA1 (patch-cd) = 81d31fb55db0f982959395cdecc3da826bf23bfb 15SHA1 (patch-cd) = 81d31fb55db0f982959395cdecc3da826bf23bfb
16SHA1 (patch-ce) = 3a4e9a83753e2eb6595bcb4e7a47c42b72ef5702 16SHA1 (patch-ce) = 3a4e9a83753e2eb6595bcb4e7a47c42b72ef5702
17SHA1 (patch-cf) = ae8c19f7df5dbb97c258ea808834c3e13809b185 17SHA1 (patch-cf) = 6236318d39f9d3d1e5f93a91048ec2777291dc63
18SHA1 (patch-cg) = c962cbc84f021e399b6f210d0e7a140fd7004222 18SHA1 (patch-cg) = c962cbc84f021e399b6f210d0e7a140fd7004222
19SHA1 (patch-ch) = 8d16dd8c80e8f1ee35ccc299ba927d685adde01c 19SHA1 (patch-ch) = 8d16dd8c80e8f1ee35ccc299ba927d685adde01c
20SHA1 (patch-ci) = 60db1d1d2e8ec9c6d446543762218b22c597d986 20SHA1 (patch-ci) = 60db1d1d2e8ec9c6d446543762218b22c597d986
21SHA1 (patch-cj) = e2420e2ccadd2d6ea30d6bf48af9c141dc395afc 21SHA1 (patch-cj) = e2420e2ccadd2d6ea30d6bf48af9c141dc395afc
22SHA1 (patch-ck) = 0232f8f42d98b49043f55cd6aaf1f50ab38fadfb 22SHA1 (patch-ck) = 0232f8f42d98b49043f55cd6aaf1f50ab38fadfb
23SHA1 (patch-cl) = f511570233524feac434db160e51099316618058 23SHA1 (patch-cl) = f511570233524feac434db160e51099316618058
24SHA1 (patch-cm) = 18001a6cf96dd6bfde8e1208be56a40fac9aa0d5 24SHA1 (patch-cm) = 18001a6cf96dd6bfde8e1208be56a40fac9aa0d5
25SHA1 (patch-cn) = b79db0b24a042a5801b47e6db5e20cbf07a53475 25SHA1 (patch-cn) = b79db0b24a042a5801b47e6db5e20cbf07a53475

cvs diff -r1.8 -r1.9 pkgsrc/audio/cdparanoia/patches/patch-ab (expand / switch to unified diff)

--- pkgsrc/audio/cdparanoia/patches/patch-ab 2009/05/17 21:29:34 1.8
+++ pkgsrc/audio/cdparanoia/patches/patch-ab 2009/05/19 00:36:06 1.9
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1$NetBSD: patch-ab,v 1.8 2009/05/17 21:29:34 dholland Exp $ 1$NetBSD: patch-ab,v 1.9 2009/05/19 00:36:06 dholland Exp $
2 2
3--- Makefile.in.orig 2001-03-27 17:46:58.000000000 -0500 3--- Makefile.in.orig 2001-03-27 17:46:58.000000000 -0500
4+++ Makefile.in 2009-05-17 17:21:32.000000000 -0400 4+++ Makefile.in 2009-05-17 17:21:32.000000000 -0400
5@@ -3,12 +3,12 @@ 5@@ -3,12 +3,12 @@
6 # DO NOT EDIT BELOW! ########################################################## 6 # DO NOT EDIT BELOW! ##########################################################
7 # (unless, of course, you know what you are doing :) ########################## 7 # (unless, of course, you know what you are doing :) ##########################
8  8
9-VERSION=9.8 9-VERSION=9.8
10+VERSION=98 10+VERSION=98
11 VPATH=@srcdir@ 11 VPATH=@srcdir@
12 srcdir=@srcdir@ 12 srcdir=@srcdir@
13  13
14 @SET_MAKE@ 14 @SET_MAKE@
@@ -22,31 +22,31 @@ $NetBSD: patch-ab,v 1.8 2009/05/17 21:29 @@ -22,31 +22,31 @@ $NetBSD: patch-ab,v 1.8 2009/05/17 21:29
22 OFILES = main.o report.o header.o buffering_write.o 22 OFILES = main.o report.o header.o buffering_write.o
23  23
24-export STATIC  24-export STATIC
25 export VERSION 25 export VERSION
26  26
27-ifeq ($(STATIC),TRUE) 27-ifeq ($(STATIC),TRUE)
28- LIBS = interface/libcdda_interface.a paranoia/libcdda_paranoia.a \ 28- LIBS = interface/libcdda_interface.a paranoia/libcdda_paranoia.a \
29- -static -lm 29- -static -lm
30- LIBDEP = interface/libcdda_interface.a paranoia/libcdda_paranoia.a 30- LIBDEP = interface/libcdda_interface.a paranoia/libcdda_paranoia.a
31-else 31-else
32- LIBS = -lcdda_interface -lcdda_paranoia -lm 32- LIBS = -lcdda_interface -lcdda_paranoia -lm
33- LIBDEP = interface/libcdda_interface.so paranoia/libcdda_paranoia.so 33- LIBDEP = interface/libcdda_interface.so paranoia/libcdda_paranoia.so
34-endif 34-endif
35+STLIBS = interface/libcdda_interface.a paranoia/libcdda_paranoia.a @LIBUTIL@ -lm 35+STLIBS = interface/libcdda_interface.a paranoia/libcdda_paranoia.a -lm
36+STLIBDEP = interface/libcdda_interface.a paranoia/libcdda_paranoia.a 36+STLIBDEP = interface/libcdda_interface.a paranoia/libcdda_paranoia.a
37  37
38+SHLIBDEP = interface/libcdda_interface.la paranoia/libcdda_paranoia.la 38+SHLIBDEP = interface/libcdda_interface.la paranoia/libcdda_paranoia.la
39+SHLIBS = $(SHLIBDEP) @LIBUTIL@ @EXTRA_LIBS@ -lm 39+SHLIBS = $(SHLIBDEP) @EXTRA_LIBS@ -lm
40  40
41-all:  41-all:
42+ 42+
43+all: 43+all:
44 cd interface && $(MAKE) all 44 cd interface && $(MAKE) all
45 cd paranoia && $(MAKE) all 45 cd paranoia && $(MAKE) all
46- $(MAKE) cdparanoia CFLAGS="$(OPT)"  46- $(MAKE) cdparanoia CFLAGS="$(OPT)"
47- strip cdparanoia 47- strip cdparanoia
48+ $(MAKE) cdparanoia CFLAGS="$(OPT)" LIBS="$(SHLIBS)" LIBDEP="$(SHLIBDEP)" 48+ $(MAKE) cdparanoia CFLAGS="$(OPT)" LIBS="$(SHLIBS)" LIBDEP="$(SHLIBDEP)"
49+ 49+
50+static: 50+static:
51+ cd interface && $(MAKE) lib 51+ cd interface && $(MAKE) lib
52+ cd paranoia && $(MAKE) lib 52+ cd paranoia && $(MAKE) lib

cvs diff -r1.6 -r1.7 pkgsrc/audio/cdparanoia/patches/patch-ca (expand / switch to unified diff)

--- pkgsrc/audio/cdparanoia/patches/patch-ca 2009/05/17 21:29:34 1.6
+++ pkgsrc/audio/cdparanoia/patches/patch-ca 2009/05/19 00:36:06 1.7
@@ -1,26 +1,17 @@ @@ -1,26 +1,17 @@
1$NetBSD: patch-ca,v 1.6 2009/05/17 21:29:34 dholland Exp $ 1$NetBSD: patch-ca,v 1.7 2009/05/19 00:36:06 dholland Exp $
2 2
3--- interface/Makefile.in.orig 1999-12-13 23:27:59.000000000 -0500 3--- interface/Makefile.in.orig 1999-12-13 20:27:59.000000000 -0800
4+++ interface/Makefile.in 2009-05-17 17:16:52.000000000 -0400 4+++ interface/Makefile.in
5@@ -7,7 +7,7 @@ VPATH=@srcdir@ 
6 srcdir=@srcdir@ 
7  
8 @SET_MAKE@ 
9-FLAGS=@SBPCD_H@ @UCDROM_H@ @TYPESIZES@ @CFLAGS@ 
10+FLAGS=@SBPCD_H@ @UCDROM_H@ @RAWPART@ @TYPESIZES@ @CFLAGS@ 
11 OPT=@OPT@ $(FLAGS) 
12 DEBUG=@DEBUG@ $(FLAGS) -DCDDA_TEST 
13 CC=@CC@ 
14@@ -18,12 +18,10 @@ RANLIB=@RANLIB@ 5@@ -18,12 +18,10 @@ RANLIB=@RANLIB@
15 LIBS = -lm 6 LIBS = -lm
16 CPPFLAGS+=-D_REENTRANT 7 CPPFLAGS+=-D_REENTRANT
17  8
18-OFILES = scan_devices.o common_interface.o cooked_interface.o interface.o\ 9-OFILES = scan_devices.o common_interface.o cooked_interface.o interface.o\
19- scsi_interface.o smallft.o toc.o test_interface.o 10- scsi_interface.o smallft.o toc.o test_interface.o
20+OFILES = scan_devices.o common_interface.o interface.o\ 11+OFILES = scan_devices.o common_interface.o interface.o\
21+ smallft.o toc.o test_interface.o @EXTRA_OBJS@ 12+ smallft.o toc.o test_interface.o @EXTRA_OBJS@
22  13
23-export VERSION 14-export VERSION
24- 15-
25-all: lib slib 16-all: lib slib
26+all: slib 17+all: slib

cvs diff -r1.9 -r1.10 pkgsrc/audio/cdparanoia/patches/patch-cf (expand / switch to unified diff)

--- pkgsrc/audio/cdparanoia/patches/patch-cf 2009/05/17 21:29:34 1.9
+++ pkgsrc/audio/cdparanoia/patches/patch-cf 2009/05/19 00:36:06 1.10
@@ -1,144 +1,115 @@ @@ -1,144 +1,115 @@
1$NetBSD: patch-cf,v 1.9 2009/05/17 21:29:34 dholland Exp $ 1$NetBSD: patch-cf,v 1.10 2009/05/19 00:36:06 dholland Exp $
2 2
3--- interface/scan_devices.c.orig 2001-03-26 00:44:01.000000000 -0500 3--- interface/scan_devices.c.orig 2001-03-26 00:44:01.000000000 -0500
4+++ interface/scan_devices.c 2009-05-17 16:47:49.000000000 -0400 4+++ interface/scan_devices.c 2009-05-18 20:11:24.000000000 -0400
5@@ -1,6 +1,8 @@ 5@@ -1,6 +1,8 @@
6 /****************************************************************** 6 /******************************************************************
7 * CopyPolicy: GNU Public License 2 applies 7 * CopyPolicy: GNU Public License 2 applies
8 * Copyright (C) 1998 Monty xiphmont@mit.edu 8 * Copyright (C) 1998 Monty xiphmont@mit.edu
9+ * FreeBSD porting (c) 2003 9+ * FreeBSD porting (c) 2003
10+ * Simon 'corecode' Schubert <corecode@corecode.ath.cx> 10+ * Simon 'corecode' Schubert <corecode@corecode.ath.cx>
11 *  11 *
12 * Autoscan for or verify presence of a cdrom device 12 * Autoscan for or verify presence of a cdrom device
13 *  13 *
14@@ -14,11 +16,18 @@ 14@@ -19,6 +21,8 @@
15 #include <pwd.h> 
16 #include <sys/stat.h> 
17 #include <sys/types.h> 
18+ 
19+#ifdef HAVE_GETRAWPARTITION 
20+#include <util.h> 
21+#endif 
22+ 
23 #include "cdda_interface.h" 
24 #include "low_interface.h" 
25 #include "common_interface.h" 15 #include "common_interface.h"
26 #include "utils.h" 16 #include "utils.h"
27  17
28+#ifdef __linux__ 18+#ifdef __linux__
29+ 19+
30 #define MAX_DEV_LEN 20 /* Safe because strings only come from below */ 20 #define MAX_DEV_LEN 20 /* Safe because strings only come from below */
31 /* must be absolute paths! */ 21 /* must be absolute paths! */
32 static char *scsi_cdrom_prefixes[]={ 22 static char *scsi_cdrom_prefixes[]={
33@@ -49,15 +58,43 @@ static char *cdrom_devices[]={ 23@@ -49,11 +53,30 @@ static char *cdrom_devices[]={
34 "/dev/cm206cd", 24 "/dev/cm206cd",
35 "/dev/gscd", 25 "/dev/gscd",
36 "/dev/optcd",NULL}; 26 "/dev/optcd",NULL};
37+#elif defined(__FreeBSD__) || defined(__DragonFly__) 27+#elif defined(__FreeBSD__) || defined(__DragonFly__)
38+static char *cdrom_devices[] = { 28+static char *cdrom_devices[] = {
39+ "/dev/cd?c", 29+ "/dev/cd?c",
40+ "/dev/acd?c", 30+ "/dev/acd?c",
41+ "/dev/wcd?c", 31+ "/dev/wcd?c",
42+ "/dev/mcd?c", NULL}; 32+ "/dev/mcd?c", NULL};
43+#elif defined(__NetBSD__) 33+#elif defined(__NetBSD__)
44+static char *cdrom_devices[] = { 34+static char *cdrom_devices[] = {
45+ "/dev/rcd?c", 35+ "/dev/rcd?c",
46+ "/dev/cd?c", NULL}; 36+ "/dev/rcd?d",
 37+ "/dev/cd?c",
 38+ "/dev/cd?d", NULL};
47+#endif 39+#endif
48  40
49 /* Functions here look for a cdrom drive; full init of a drive type 41 /* Functions here look for a cdrom drive; full init of a drive type
50 happens in interface.c */ 42 happens in interface.c */
51  43
52+#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || (defined(__APPLE__) && defined(__MACH__)) 44+#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || (defined(__APPLE__) && defined(__MACH__))
53 cdrom_drive *cdda_find_a_cdrom(int messagedest,char **messages){ 45 cdrom_drive *cdda_find_a_cdrom(int messagedest,char **messages){
54+#if defined(__APPLE__) && defined(__MACH__) 46+#if defined(__APPLE__) && defined(__MACH__)
55+ cdrom_drive *d = calloc(1, sizeof(cdrom_drive)); 47+ cdrom_drive *d = calloc(1, sizeof(cdrom_drive));
56+ d->interface = OSX_IOKIT; 48+ d->interface = OSX_IOKIT;
57+ return d; 49+ return d;
58+#else 50+#else
59 /* Brute force... */ 51 /* Brute force... */
60  52
61 int i=0; 53 int i=0;
62 cdrom_drive *d; 54@@ -75,10 +98,12 @@ cdrom_drive *cdda_find_a_cdrom(int messa
63+#ifdef __NetBSD__ 
64+ int rawpartition; 
65+#endif 
66+ 
67+#ifdef __NetBSD__ 
68+#ifdef HAVE_GETRAWPARTITION 
69+ rawpartition = getrawpartition(); 
70+#else 
71+ rawpartition = 'c' - 'a'; 
72+#endif 
73+#endif 
74  
75 while(cdrom_devices[i]!=NULL){ 
76  
77@@ -72,13 +109,18 @@ cdrom_drive *cdda_find_a_cdrom(int messa 
78 /* number, then letter */ 
79  
80 buffer[pos-(cdrom_devices[i])]=j+48; 
81+#ifdef __NetBSD__ 
82+ buffer[(pos+1)-(cdrom_devices[i])]='a'+rawpartition; 
83+#endif 
84 if((d=cdda_identify(buffer,messagedest,messages))) 55 if((d=cdda_identify(buffer,messagedest,messages)))
85 return(d); 56 return(d);
86 idmessage(messagedest,messages,"",NULL); 57 idmessage(messagedest,messages,"",NULL);
87+#ifdef __linux__ 58+#ifdef __linux__
88 buffer[pos-(cdrom_devices[i])]=j+97; 59 buffer[pos-(cdrom_devices[i])]=j+97;
89 if((d=cdda_identify(buffer,messagedest,messages))) 60 if((d=cdda_identify(buffer,messagedest,messages)))
90 return(d); 61 return(d);
91 idmessage(messagedest,messages,"",NULL); 62 idmessage(messagedest,messages,"",NULL);
92+#endif 63+#endif
93 } 64 }
94 }else{ 65 }else{
95 /* Name. Go for it. */ 66 /* Name. Go for it. */
96@@ -97,8 +139,11 @@ cdrom_drive *cdda_find_a_cdrom(int messa 67@@ -97,8 +122,11 @@ cdrom_drive *cdda_find_a_cdrom(int messa
97 temp->pw_name); 68 temp->pw_name);
98 } 69 }
99 return(NULL); 70 return(NULL);
100+#endif 71+#endif
101 } 72 }
102+#endif /* __linux__ */ 73+#endif /* __linux__ */
103  74
104+#if !(defined(__APPLE__) && defined(__MACH__)) 75+#if !(defined(__APPLE__) && defined(__MACH__))
105 cdrom_drive *cdda_identify(const char *device, int messagedest,char **messages){ 76 cdrom_drive *cdda_identify(const char *device, int messagedest,char **messages){
106 struct stat st; 77 struct stat st;
107 cdrom_drive *d=NULL; 78 cdrom_drive *d=NULL;
108@@ -117,8 +162,14 @@ cdrom_drive *cdda_identify(const char *d 79@@ -117,8 +145,14 @@ cdrom_drive *cdda_identify(const char *d
109 } 80 }
110 #endif 81 #endif
111  82
112+#if defined(__linux__) || defined(__NetBSD__) 83+#if defined(__linux__) || defined(__NetBSD__)
113 d=cdda_identify_cooked(device,messagedest,messages); 84 d=cdda_identify_cooked(device,messagedest,messages);
114 if(!d)d=cdda_identify_scsi(device,NULL,messagedest,messages); 85 if(!d)d=cdda_identify_scsi(device,NULL,messagedest,messages);
115+#elif defined(__FreeBSD__) || defined(__DragonFly__) 86+#elif defined(__FreeBSD__) || defined(__DragonFly__)
116+ d = cdda_identify_scsi(device, NULL, messagedest, messages); 87+ d = cdda_identify_scsi(device, NULL, messagedest, messages);
117+ if (d == NULL) 88+ if (d == NULL)
118+ d = cdda_identify_cooked(device, messagedest, messages); 89+ d = cdda_identify_cooked(device, messagedest, messages);
119+#endif 90+#endif
120  91
121 #ifdef CDDA_TEST 92 #ifdef CDDA_TEST
122 if(!d)d=cdda_identify_test(device,messagedest,messages); 93 if(!d)d=cdda_identify_test(device,messagedest,messages);
123@@ -146,6 +197,7 @@ char *test_resolve_symlink(const char *f 94@@ -146,6 +180,7 @@ char *test_resolve_symlink(const char *f
124 cdrom_drive *cdda_identify_cooked(const char *dev, int messagedest, 95 cdrom_drive *cdda_identify_cooked(const char *dev, int messagedest,
125 char **messages){ 96 char **messages){
126  97
127+#ifdef __linux__ 98+#ifdef __linux__
128 cdrom_drive *d=NULL; 99 cdrom_drive *d=NULL;
129 struct stat st; 100 struct stat st;
130 int fd=-1; 101 int fd=-1;
131@@ -273,8 +325,60 @@ cdrom_drive *cdda_identify_cooked(const  102@@ -273,8 +308,60 @@ cdrom_drive *cdda_identify_cooked(const
132 idmessage(messagedest,messages,"\t\tCDROM sensed: %s\n",description); 103 idmessage(messagedest,messages,"\t\tCDROM sensed: %s\n",description);
133  104
134 return(d); 105 return(d);
135+#elif defined(__NetBSD__) 106+#elif defined(__NetBSD__)
136+ /* no kernel support for CD-DA */ 107+ /* no kernel support for CD-DA */
137+ return NULL; 108+ return NULL;
138+#elif defined(__FreeBSD__) || defined(__DragonFly__) 109+#elif defined(__FreeBSD__) || defined(__DragonFly__)
139+ cdrom_drive *d; 110+ cdrom_drive *d;
140+ struct stat st; 111+ struct stat st;
141+ 112+
142+ if (stat(dev, &st)) { 113+ if (stat(dev, &st)) {
143+ idperror(messagedest, messages, "\t\tCould not stat %s", dev); 114+ idperror(messagedest, messages, "\t\tCould not stat %s", dev);
144+ return NULL; 115+ return NULL;
@@ -179,202 +150,202 @@ $NetBSD: patch-cf,v 1.9 2009/05/17 21:29 @@ -179,202 +150,202 @@ $NetBSD: patch-cf,v 1.9 2009/05/17 21:29
179+ if (d != NULL) { 150+ if (d != NULL) {
180+ if (d->ioctl_fd != -1) 151+ if (d->ioctl_fd != -1)
181+ close(d->ioctl_fd); 152+ close(d->ioctl_fd);
182+ free(d); 153+ free(d);
183+ } 154+ }
184+ return NULL; 155+ return NULL;
185+#endif 156+#endif
186 } 157 }
187  158
188+#if !defined(__FreeBSD__) || defined(__DragonFly__) 159+#if !defined(__FreeBSD__) || defined(__DragonFly__)
189 struct sg_id { 160 struct sg_id {
190 long l1; /* target | lun << 8 | channel << 16 | low_ino << 24 */ 161 long l1; /* target | lun << 8 | channel << 16 | low_ino << 24 */
191 long l2; /* Unique id */ 162 long l2; /* Unique id */
192@@ -289,12 +393,18 @@ typedef struct scsiid{ 163@@ -289,12 +376,18 @@ typedef struct scsiid{
193 /* Even *this* isn't as simple as it bloody well should be :-P */ 164 /* Even *this* isn't as simple as it bloody well should be :-P */
194 /* SG has an easy interface, but SCSI overall does not */ 165 /* SG has an easy interface, but SCSI overall does not */
195 static int get_scsi_id(int fd, scsiid *id){ 166 static int get_scsi_id(int fd, scsiid *id){
196+#ifdef __linux__ 167+#ifdef __linux__
197 struct sg_id argid; 168 struct sg_id argid;
198+#endif 169+#endif
199+#ifdef __NetBSD__ 170+#ifdef __NetBSD__
200+ struct scsi_addr argid; 171+ struct scsi_addr argid;
201+#endif 172+#endif
202 int busarg; 173 int busarg;
203  174
204 /* get the host/id/lun */ 175 /* get the host/id/lun */
205  176
206 if(fd==-1)return(-1); 177 if(fd==-1)return(-1);
207+#ifdef __linux__ 178+#ifdef __linux__
208 if(ioctl(fd,SCSI_IOCTL_GET_IDLUN,&argid))return(-1); 179 if(ioctl(fd,SCSI_IOCTL_GET_IDLUN,&argid))return(-1);
209 id->bus=argid.l2; /* for now */ 180 id->bus=argid.l2; /* for now */
210 id->id=argid.l1&0xff; 181 id->id=argid.l1&0xff;
211@@ -302,6 +412,13 @@ static int get_scsi_id(int fd, scsiid *i 182@@ -302,6 +395,13 @@ static int get_scsi_id(int fd, scsiid *i
212  183
213 if(ioctl(fd,SCSI_IOCTL_GET_BUS_NUMBER,&busarg)==0) 184 if(ioctl(fd,SCSI_IOCTL_GET_BUS_NUMBER,&busarg)==0)
214 id->bus=busarg; 185 id->bus=busarg;
215+#endif 186+#endif
216+#ifdef __NetBSD__ 187+#ifdef __NetBSD__
217+ if(ioctl(fd,SCIOCIDENTIFY,&argid))return(-1); 188+ if(ioctl(fd,SCIOCIDENTIFY,&argid))return(-1);
218+ id->bus=argid.addr.scsi.scbus; 189+ id->bus=argid.addr.scsi.scbus;
219+ id->id=argid.addr.scsi.target; 190+ id->id=argid.addr.scsi.target;
220+ id->lun=argid.addr.scsi.lun; 191+ id->lun=argid.addr.scsi.lun;
221+#endif 192+#endif
222  193
223 return(0); 194 return(0);
224 } 195 }
225@@ -390,6 +507,7 @@ matchfail: 196@@ -390,6 +490,7 @@ matchfail:
226 if(dev!=-1)close(dev); 197 if(dev!=-1)close(dev);
227 return(NULL); 198 return(NULL);
228 } 199 }
229+#endif 200+#endif
230  201
231 void strscat(char *a,char *b,int n){ 202 void strscat(char *a,char *b,int n){
232 int i; 203 int i;
233@@ -401,6 +519,7 @@ void strscat(char *a,char *b,int n){ 204@@ -401,6 +502,7 @@ void strscat(char *a,char *b,int n){
234 strcat(a," "); 205 strcat(a," ");
235 } 206 }
236  207
237+#ifdef __linux__ 208+#ifdef __linux__
238 /* At this point, we're going to punt compatability before SG2, and 209 /* At this point, we're going to punt compatability before SG2, and
239 allow only SG2 and SG3 */ 210 allow only SG2 and SG3 */
240 static int verify_SG_version(cdrom_drive *d,int messagedest, 211 static int verify_SG_version(cdrom_drive *d,int messagedest,
241@@ -430,7 +549,9 @@ static int verify_SG_version(cdrom_drive 212@@ -430,7 +532,9 @@ static int verify_SG_version(cdrom_drive
242 idmessage(messagedest,messages,buffer,""); 213 idmessage(messagedest,messages,buffer,"");
243 return(major); 214 return(major);
244 } 215 }
245+#endif 216+#endif
246  217
247+#if defined(__linux__) || defined(__NetBSD__) 218+#if defined(__linux__) || defined(__NetBSD__)
248 cdrom_drive *cdda_identify_scsi(const char *generic_device,  219 cdrom_drive *cdda_identify_scsi(const char *generic_device,
249 const char *ioctl_device, int messagedest, 220 const char *ioctl_device, int messagedest,
250 char **messages){ 221 char **messages){
251@@ -460,6 +581,7 @@ cdrom_drive *cdda_identify_scsi(const ch 222@@ -460,6 +564,7 @@ cdrom_drive *cdda_identify_scsi(const ch
252 generic_device); 223 generic_device);
253 return(NULL); 224 return(NULL);
254 } 225 }
255+#ifdef __linux__ 226+#ifdef __linux__
256 if((int)(g_st.st_rdev>>8)!=SCSI_GENERIC_MAJOR){ 227 if((int)(g_st.st_rdev>>8)!=SCSI_GENERIC_MAJOR){
257 if((int)(g_st.st_rdev>>8)!=SCSI_CDROM_MAJOR){ 228 if((int)(g_st.st_rdev>>8)!=SCSI_CDROM_MAJOR){
258 idmessage(messagedest,messages,"\t\t%s is not a SCSI device", 229 idmessage(messagedest,messages,"\t\t%s is not a SCSI device",
259@@ -471,6 +593,7 @@ cdrom_drive *cdda_identify_scsi(const ch 230@@ -471,6 +576,7 @@ cdrom_drive *cdda_identify_scsi(const ch
260 ioctl_device=temp; 231 ioctl_device=temp;
261 } 232 }
262 } 233 }
263+#endif 234+#endif
264 } 235 }
265 if(ioctl_device){ 236 if(ioctl_device){
266 if(stat(ioctl_device,&i_st)){ 237 if(stat(ioctl_device,&i_st)){
267@@ -478,6 +601,7 @@ cdrom_drive *cdda_identify_scsi(const ch 238@@ -478,6 +584,7 @@ cdrom_drive *cdda_identify_scsi(const ch
268 ioctl_device); 239 ioctl_device);
269 return(NULL); 240 return(NULL);
270 } 241 }
271+#ifdef __linux__ 242+#ifdef __linux__
272 if((int)(i_st.st_rdev>>8)!=SCSI_CDROM_MAJOR){ 243 if((int)(i_st.st_rdev>>8)!=SCSI_CDROM_MAJOR){
273 if((int)(i_st.st_rdev>>8)!=SCSI_GENERIC_MAJOR){ 244 if((int)(i_st.st_rdev>>8)!=SCSI_GENERIC_MAJOR){
274 idmessage(messagedest,messages,"\t\t%s is not a SCSI device", 245 idmessage(messagedest,messages,"\t\t%s is not a SCSI device",
275@@ -489,6 +613,7 @@ cdrom_drive *cdda_identify_scsi(const ch 246@@ -489,6 +596,7 @@ cdrom_drive *cdda_identify_scsi(const ch
276 ioctl_device=temp; 247 ioctl_device=temp;
277 } 248 }
278 } 249 }
279+#endif 250+#endif
280 } 251 }
281  252
282 /* we need to resolve any symlinks for the lookup code to work */ 253 /* we need to resolve any symlinks for the lookup code to work */
283@@ -505,6 +630,7 @@ cdrom_drive *cdda_identify_scsi(const ch 254@@ -505,6 +613,7 @@ cdrom_drive *cdda_identify_scsi(const ch
284 } 255 }
285  256
286 if(!generic_device || !ioctl_device){ 257 if(!generic_device || !ioctl_device){
287+#ifdef __linux__ 258+#ifdef __linux__
288 if(generic_device){ 259 if(generic_device){
289 ioctl_device= 260 ioctl_device=
290 scsi_match(generic_device,scsi_cdrom_prefixes, 261 scsi_match(generic_device,scsi_cdrom_prefixes,
291@@ -520,6 +646,12 @@ cdrom_drive *cdda_identify_scsi(const ch 262@@ -520,6 +629,12 @@ cdrom_drive *cdda_identify_scsi(const ch
292 if(!generic_device)  263 if(!generic_device)
293 goto cdda_identify_scsi_fail; 264 goto cdda_identify_scsi_fail;
294 } 265 }
295+#else 266+#else
296+ if(!generic_device) 267+ if(!generic_device)
297+ generic_device = strdup(ioctl_device); 268+ generic_device = strdup(ioctl_device);
298+ else 269+ else
299+ ioctl_device = strdup(generic_device); 270+ ioctl_device = strdup(generic_device);
300+#endif 271+#endif
301 } 272 }
302  273
303 idmessage(messagedest,messages,"\t\tgeneric device: %s",generic_device); 274 idmessage(messagedest,messages,"\t\tgeneric device: %s",generic_device);
304@@ -556,6 +688,7 @@ cdrom_drive *cdda_identify_scsi(const ch 275@@ -556,6 +671,7 @@ cdrom_drive *cdda_identify_scsi(const ch
305  276
306 type=(int)(i_st.st_rdev>>8); 277 type=(int)(i_st.st_rdev>>8);
307  278
308+#ifdef __linux__ 279+#ifdef __linux__
309 if(type==SCSI_CDROM_MAJOR){ 280 if(type==SCSI_CDROM_MAJOR){
310 if (!S_ISBLK(i_st.st_mode)) { 281 if (!S_ISBLK(i_st.st_mode)) {
311 idmessage(messagedest,messages,"\t\tSCSI CDROM device %s not a " 282 idmessage(messagedest,messages,"\t\tSCSI CDROM device %s not a "
312@@ -567,8 +700,10 @@ cdrom_drive *cdda_identify_scsi(const ch 283@@ -567,8 +683,10 @@ cdrom_drive *cdda_identify_scsi(const ch
313 "major number",ioctl_device); 284 "major number",ioctl_device);
314 goto cdda_identify_scsi_fail; 285 goto cdda_identify_scsi_fail;
315 } 286 }
316+#endif 287+#endif
317 } 288 }
318  289
319+#ifdef __linux__ 290+#ifdef __linux__
320 if((int)(g_st.st_rdev>>8)==SCSI_GENERIC_MAJOR){ 291 if((int)(g_st.st_rdev>>8)==SCSI_GENERIC_MAJOR){
321 if (!S_ISCHR(g_st.st_mode)) { 292 if (!S_ISCHR(g_st.st_mode)) {
322 idmessage(messagedest,messages,"\t\tGeneric SCSI device %s not a " 293 idmessage(messagedest,messages,"\t\tGeneric SCSI device %s not a "
323@@ -580,6 +715,7 @@ cdrom_drive *cdda_identify_scsi(const ch 294@@ -580,6 +698,7 @@ cdrom_drive *cdda_identify_scsi(const ch
324 "major number",generic_device); 295 "major number",generic_device);
325 goto cdda_identify_scsi_fail; 296 goto cdda_identify_scsi_fail;
326 } 297 }
327+#endif 298+#endif
328  299
329  300
330 d=calloc(1,sizeof(cdrom_drive)); 301 d=calloc(1,sizeof(cdrom_drive));
331@@ -590,6 +726,7 @@ cdrom_drive *cdda_identify_scsi(const ch 302@@ -590,6 +709,7 @@ cdrom_drive *cdda_identify_scsi(const ch
332 d->bigendianp=-1; /* We don't know yet... */ 303 d->bigendianp=-1; /* We don't know yet... */
333 d->nsectors=-1; 304 d->nsectors=-1;
334  305
335+#ifdef __linux__ 306+#ifdef __linux__
336 version=verify_SG_version(d,messagedest,messages); 307 version=verify_SG_version(d,messagedest,messages);
337 switch(version){ 308 switch(version){
338 case -1:case 0:case 1: 309 case -1:case 0:case 1:
339@@ -599,6 +736,9 @@ cdrom_drive *cdda_identify_scsi(const ch 310@@ -599,6 +719,9 @@ cdrom_drive *cdda_identify_scsi(const ch
340 d->interface=GENERIC_SCSI; 311 d->interface=GENERIC_SCSI;
341 break; 312 break;
342 } 313 }
343+#else 314+#else
344+ d->interface=GENERIC_SCSI; 315+ d->interface=GENERIC_SCSI;
345+#endif 316+#endif
346  317
347 /* malloc our big buffer for scsi commands */ 318 /* malloc our big buffer for scsi commands */
348 d->sg=malloc(MAX_BIG_BUFF_SIZE); 319 d->sg=malloc(MAX_BIG_BUFF_SIZE);
349@@ -617,7 +757,16 @@ cdrom_drive *cdda_identify_scsi(const ch 320@@ -617,7 +740,16 @@ cdrom_drive *cdda_identify_scsi(const ch
350  321
351 /* It would seem some TOSHIBA CDROMs gets things wrong */ 322 /* It would seem some TOSHIBA CDROMs gets things wrong */
352  323
353- if (!strncmp (p + 8, "TOSHIBA", 7) && 324- if (!strncmp (p + 8, "TOSHIBA", 7) &&
354+#ifndef TYPE_DISK 325+#ifndef TYPE_DISK
355+#define TYPE_DISK 0 /* direct */ 326+#define TYPE_DISK 0 /* direct */
356+#endif 327+#endif
357+#ifndef TYPE_WORM 328+#ifndef TYPE_WORM
358+#define TYPE_WORM 4 /* write once, read many */ 329+#define TYPE_WORM 4 /* write once, read many */
359+#endif 330+#endif
360+#ifndef TYPE_ROM 331+#ifndef TYPE_ROM
361+#define TYPE_ROM 5 /* CD-ROM */ 332+#define TYPE_ROM 5 /* CD-ROM */
362+#endif 333+#endif
363+ if (p && !strncmp (p + 8, "TOSHIBA", 7) && 334+ if (p && !strncmp (p + 8, "TOSHIBA", 7) &&
364 !strncmp (p + 16, "CD-ROM", 6) && 335 !strncmp (p + 16, "CD-ROM", 6) &&
365 p[0] == TYPE_DISK) { 336 p[0] == TYPE_DISK) {
366 p[0] = TYPE_ROM; 337 p[0] = TYPE_ROM;
367@@ -653,6 +802,88 @@ cdda_identify_scsi_fail: 338@@ -653,6 +785,88 @@ cdda_identify_scsi_fail:
368 if(g_fd!=-1)close(g_fd); 339 if(g_fd!=-1)close(g_fd);
369 return(NULL); 340 return(NULL);
370 } 341 }
371+#elif defined(__FreeBSD__) || defined(__DragonFly__) 342+#elif defined(__FreeBSD__) || defined(__DragonFly__)
372+cdrom_drive *cdda_identify_scsi(const char *device, 343+cdrom_drive *cdda_identify_scsi(const char *device,
373+ const char *dummy, 344+ const char *dummy,
374+ int messagedest, 345+ int messagedest,
375+ char **messages) 346+ char **messages)
376+{ 347+{
377+ char *devname; 348+ char *devname;
378+ cdrom_drive *d = NULL; 349+ cdrom_drive *d = NULL;
379+ 350+
380+ if (device == NULL) { 351+ if (device == NULL) {
@@ -443,18 +414,18 @@ $NetBSD: patch-cf,v 1.9 2009/05/17 21:29 @@ -443,18 +414,18 @@ $NetBSD: patch-cf,v 1.9 2009/05/17 21:29
443+ if (d) { 414+ if (d) {
444+ if (d->ccb) 415+ if (d->ccb)
445+ cam_freeccb(d->ccb); 416+ cam_freeccb(d->ccb);
446+ if (d->dev) 417+ if (d->dev)
447+ cam_close_device(d->dev); 418+ cam_close_device(d->dev);
448+ free(d); 419+ free(d);
449+ } 420+ }
450+ return NULL; 421+ return NULL;
451+} 422+}
452+#endif 423+#endif
453  424
454 #ifdef CDDA_TEST 425 #ifdef CDDA_TEST
455  426
456@@ -702,3 +933,4 @@ cdrom_drive *cdda_identify_test(const ch 427@@ -702,3 +916,4 @@ cdrom_drive *cdda_identify_test(const ch
457 } 428 }
458  429
459 #endif 430 #endif
460+#endif /* __APPLE__ && __MACH__ */ 431+#endif /* __APPLE__ && __MACH__ */