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
|
$NetBSD: patch-aa,v 1.2 2006/03/06 22:16:53 joerg Exp $
--- cdromlow.c.orig Sat Mar 23 19:48:00 2002
+++ cdromlow.c Sat Mar 23 20:10:30 2002
@@ -9,7 +9,7 @@
#include <fcntl.h>
#include <signal.h>
#include <unistd.h>
-#if !defined( __FreeBSD__) && !defined(__svr4__ )
+#if !defined( __FreeBSD__) && !defined(__svr4__ ) && !defined(__NetBSD__) && !defined(__DragonFly__)
# include <linux/cdrom.h>
#else
# include <sys/cdio.h>
@@ -37,7 +37,7 @@
/* we provide some macro mappings here. FreeBSD structs are a bit
* different to those used by Linux so we will use macros to compensate that */
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
/* Needed by FreeBSD */
# define CDROM_DATA_TRACK 4
@@ -46,19 +46,35 @@
# define CD_FRAMESIZE_RAW 2352
# define CDROM_LBA CD_LBA_FORMAT
# define CDROMREADTOCHDR CDIOREADTOCHEADER
+#ifdef __NetBSD__
+# define CDROMREADTOCENTRY CDIOREADTOCENTRIES
+#else
# define CDROMREADTOCENTRY CDIOREADTOCENTRY
+#endif
# define cdromlow_definecdromheader struct ioc_toc_header
+#ifdef __NetBSD__
+# define cdromlow_definecdromhentry struct ioc_read_toc_entry
+#else
# define cdromlow_definecdromhentry struct ioc_read_toc_single_entry
+#endif
/* referencing the TOC header */
# define cdromlow_tochdr_firstt starting_track
# define cdromlow_tochdr_lastt ending_track
/* referencing TOC entries */
+#ifdef __NetBSD__
+# define cdromlow_tocent_track starting_track
+#else
# define cdromlow_tocent_track track
+#endif
# define cdromlow_tocent_format address_format
+#ifdef __NetBSD__
+# define cdromlow_tocent_addr data->addr
+#else
# define cdromlow_tocent_addr entry.addr
+#endif
#elif __svr4__
# define CD_FRAMESIZE 2048
# define CD_FRAMESIZE_RAW 2352
@@ -138,6 +154,11 @@
int x;
int hasdatatrack=-1;
+#ifdef __NetBSD__
+ struct cd_toc_entry entrydata;
+ entry.data = &entrydata;
+ entry.data_len = sizeof(entrydata);
+#endif
if (info->filedescriptor!=-1)
{
@@ -148,7 +169,11 @@
entry.cdromlow_tocent_format=CDROM_LBA;
ioctl(info->filedescriptor,CDROMREADTOCENTRY,&entry);
-#ifndef __FreeBSD__
+#if !defined(__FreeBSD__) && !defined(__DragonFly__)
+#ifdef __NetBSD__
+ if (entry.data->control & CDROM_DATA_TRACK)
+#else
if (entry.cdte_ctrl&CDROM_DATA_TRACK)
+#endif
#else
if (entry.entry.control & CDROM_DATA_TRACK)
#endif
@@ -191,6 +216,11 @@
cdromlow_tochandle *info=(cdromlow_tochandle*)handle;
cdromlow_definecdromhentry entry;
int offset=-1;
+#ifdef __NetBSD__
+ struct cd_toc_entry entrydata;
+ entry.data = &entrydata;
+ entry.data_len = sizeof(entrydata);
+#endif
if (info->filedescriptor!=-1)
{
@@ -223,6 +253,13 @@
cdromlow_definecdromhentry tracknext;
int tracksize;
int ok=1;
+#ifdef __NetBSD__
+ struct cd_toc_entry trackdata, tracknextdata;
+ track.data = &trackdata;
+ track.data_len = sizeof(trackdata);
+ tracknext.data = &tracknextdata;
+ tracknext.data_len = sizeof(tracknextdata);
+#endif
tracksize=0;
if (info->filedescriptor!=-1)
@@ -278,6 +315,11 @@
cdromlow_definecdromhentry entry;
int x,secs;
int cddbnum=0;
+#ifdef __NetBSD__
+ struct cd_toc_entry entrydata;
+ entry.data = &entrydata;
+ entry.data_len = sizeof(entrydata);
+#endif
cddbnum=0;
if (info->filedescriptor!=-1)
@@ -317,6 +359,11 @@
cdromlow_definecdromhentry track;
int ok=1;
cdromlow_tracktype result=TRACKTYPE_UNKNOWN;
+#ifdef __NetBSD__
+ struct cd_toc_entry trackdata;
+ track.data = &trackdata;
+ track.data_len = sizeof(trackdata);
+#endif
if (info->filedescriptor!=-1)
{
@@ -325,7 +372,11 @@
if (ioctl(info->filedescriptor,CDROMREADTOCENTRY,&track)==-1)
ok=0;
-#ifndef __FreeBSD__
+#if !defined(__FreeBSD__) && !defined(__DragonFly__)
+#ifdef __NetBSD__
+ if (track.data->control & CDROM_DATA_TRACK)
+#else
if (track.cdte_ctrl&CDROM_DATA_TRACK)
+#endif
#else
if (track.entry.control & CDROM_DATA_TRACK)
#endif
|