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
|
$NetBSD: patch-cd,v 1.4 2006/09/03 17:13:30 ben Exp $
--- interface/common_interface.c.orig 2000-04-19 15:41:04.000000000 -0700
+++ interface/common_interface.c
@@ -9,23 +9,39 @@
******************************************************************/
#include <math.h>
+#if defined(__APPLE__) && defined(__MACH__)
+#include <sys/syslimits.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <paths.h>
+#include <fcntl.h>
+#endif
#include "low_interface.h"
#include "utils.h"
#include "smallft.h"
+#ifdef __linux__
#include <linux/hdreg.h>
+#endif
/* Test for presence of a cdrom by pinging with the 'CDROMVOLREAD' ioctl() */
int ioctl_ping_cdrom(int fd){
+#ifdef __linux__
struct cdrom_volctrl volctl;
if (ioctl(fd, CDROMVOLREAD, &volctl))
return(1); /* failure */
+#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
+ struct ioc_vol volctl;
+ if (ioctl(fd, CDIOCGETVOL, &volctl))
+ return(1); /* failure */
+#endif
return(0);
/* success! */
}
+#ifdef __linux__
/* Use the ioctl thingy above ping the cdrom; this will get model info */
char *atapi_drive_info(int fd){
/* Work around the fact that the struct grew without warning in
@@ -46,6 +62,7 @@ char *atapi_drive_info(int fd){
free(id);
return(ret);
}
+#endif
int data_bigendianp(cdrom_drive *d){
float lsb_votes=0;
@@ -171,9 +188,12 @@ int data_bigendianp(cdrom_drive *d){
knows the leasoud/leadin size. */
int FixupTOC(cdrom_drive *d,int tracks){
+#ifdef __linux__
struct cdrom_multisession ms_str;
+#endif
int j;
+#if !(defined(__APPLE__) && defined(__MACH__))
/* First off, make sure the 'starting sector' is >=0 */
for(j=0;j<tracks;j++){
@@ -208,14 +228,26 @@ int FixupTOC(cdrom_drive *d,int tracks){
/* For a scsi device, the ioctl must go to the specialized SCSI
CDROM device, not the generic device. */
+#if !defined(__FreeBSD__) && !defined(__DragonFly__)
if (d->ioctl_fd != -1) {
+#ifdef __linux__
int result;
ms_str.addr_format = CDROM_LBA;
result = ioctl(d->ioctl_fd, CDROMMULTISESSION, &ms_str);
if (result == -1) return -1;
+# define ms_addr (ms_str.addr.lba)
+#endif
+
+#ifdef __NetBSD__
+ int ms_addr;
+
+ ms_addr = 0; /* last session */
+ if (ioctl(d->ioctl_fd, CDIOREADMSADDR, &ms_addr) == -1)
+ return -1;
+#endif
- if (ms_str.addr.lba > 100) {
+ if (ms_addr > 100) {
/* This is an odd little piece of code --Monty */
@@ -223,14 +255,16 @@ int FixupTOC(cdrom_drive *d,int tracks){
/* adjust end of last audio track to be in the first session */
for (j = tracks-1; j >= 0; j--) {
if (j > 0 && !IS_AUDIO(d,j) && IS_AUDIO(d,j-1)) {
- if (d->disc_toc[j].dwStartSector > ms_str.addr.lba - 11400)
- d->disc_toc[j].dwStartSector = ms_str.addr.lba - 11400;
+ if (d->disc_toc[j].dwStartSector > ms_addr - 11400)
+ d->disc_toc[j].dwStartSector = ms_addr - 11400;
break;
}
}
return 1;
}
}
+#endif
+#endif
return 0;
}
|