1 $NetBSD: patch-cd,v 1.5 2009/08/09 16:00:53 drochner Exp $
3 --- interface/common_interface.c.orig 2008-08-21 18:08:54.000000000 +0200
4 +++ interface/common_interface.c
6 ******************************************************************/
9 +#if defined(__APPLE__) && defined(__MACH__)
10 +#include <sys/syslimits.h>
16 #include "low_interface.h"
21 #include <linux/hdreg.h>
24 /* Test for presence of a cdrom by pinging with the 'CDROMVOLREAD' ioctl() */
25 /* Also test using CDROM_GET_CAPABILITY (if available) as some newer DVDROMs will
26 reject CDROMVOLREAD ioctl for god-knows-what reason */
27 int ioctl_ping_cdrom(int fd){
29 struct cdrom_volctrl volctl;
30 if (ioctl(fd, CDROMVOLREAD, &volctl) &&
31 ioctl(fd, CDROM_GET_CAPABILITY, NULL)<0)
32 return(1); /* failure */
33 +#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
34 + struct ioc_vol volctl;
35 + if (ioctl(fd, CDIOCGETVOL, &volctl))
36 + return(1); /* failure */
45 /* Use the ioctl thingy above ping the cdrom; this will get model info */
46 char *atapi_drive_info(int fd){
47 /* Work around the fact that the struct grew without warning in
48 @@ -49,6 +65,7 @@ char *atapi_drive_info(int fd){
54 int data_bigendianp(cdrom_drive *d){
56 @@ -174,9 +191,12 @@ int data_bigendianp(cdrom_drive *d){
57 knows the leadout/leadin size. */
59 int FixupTOC(cdrom_drive *d,int tracks){
61 struct cdrom_multisession ms_str;
65 +#if !(defined(__APPLE__) && defined(__MACH__))
66 /* First off, make sure the 'starting sector' is >=0 */
68 for(j=0;j<tracks;j++){
69 @@ -211,14 +231,26 @@ int FixupTOC(cdrom_drive *d,int tracks){
70 /* For a scsi device, the ioctl must go to the specialized SCSI
71 CDROM device, not the generic device. */
73 +#if !defined(__FreeBSD__) && !defined(__DragonFly__)
74 if (d->ioctl_fd != -1) {
78 ms_str.addr_format = CDROM_LBA;
79 result = ioctl(d->ioctl_fd, CDROMMULTISESSION, &ms_str);
80 if (result == -1) return -1;
81 +# define ms_addr (ms_str.addr.lba)
87 + ms_addr = 0; /* last session */
88 + if (ioctl(d->ioctl_fd, CDIOREADMSADDR, &ms_addr) == -1)
92 - if (ms_str.addr.lba > 100) {
93 + if (ms_addr > 100) {
95 /* This is an odd little piece of code --Monty */
97 @@ -226,15 +258,17 @@ int FixupTOC(cdrom_drive *d,int tracks){
98 /* adjust end of last audio track to be in the first session */
99 for (j = tracks-1; j >= 0; j--) {
100 if (j > 0 && !IS_AUDIO(d,j) && IS_AUDIO(d,j-1)) {
101 - if ((d->disc_toc[j].dwStartSector > ms_str.addr.lba - 11400) &&
102 - (ms_str.addr.lba - 11400 > d->disc_toc[j-1].dwStartSector))
103 - d->disc_toc[j].dwStartSector = ms_str.addr.lba - 11400;
104 + if ((d->disc_toc[j].dwStartSector > ms_addr - 11400) &&
105 + (ms_addr - 11400 > d->disc_toc[j-1].dwStartSector))
106 + d->disc_toc[j].dwStartSector = ms_addr - 11400;