| @@ -1,62 +1,60 @@ | | | @@ -1,62 +1,60 @@ |
1 | $NetBSD: patch-ab,v 1.1 2009/07/07 17:44:51 drochner Exp $ | | 1 | $NetBSD: patch-ab,v 1.2 2013/06/16 09:58:48 shattered Exp $ |
2 | | | 2 | |
3 | --- src/disc_freebsd.c.orig 2008-01-12 12:41:51.000000000 +0100 | | 3 | --- src/disc_freebsd.c.orig 2013-04-12 11:46:44.000000000 +0000 |
4 | +++ src/disc_freebsd.c | | 4 | +++ src/disc_freebsd.c |
5 | @@ -45,6 +45,9 @@ | | 5 | @@ -47,11 +47,19 @@ |
| | | 6 | #define MB_DEFAULT_DEVICE "/dev/acd0" |
6 | | | 7 | |
7 | #define XA_INTERVAL ((60 + 90 + 2) * CD_FRAMES) | | 8 | #define XA_INTERVAL ((60 + 90 + 2) * CD_FRAMES) |
8 | | | 9 | - |
| | | 10 | + |
9 | +#ifdef __NetBSD__ | | 11 | +#ifdef __NetBSD__ |
10 | +#define CDIOREADTOCENTRY CDIOREADTOCENTRIES | | 12 | +#define CDIOREADTOCENTRY CDIOREADTOCENTRIES |
11 | +#endif | | 13 | +#endif |
12 | | | 14 | |
13 | /* TODO: make sure it's available */ | | | |
14 | int snprintf(char *str, size_t size, const char *format, ...); | | | |
15 | @@ -52,7 +55,12 @@ int snprintf(char *str, size_t size, con | | | |
16 | | | | |
17 | static int read_toc_header(int fd, int *first, int *last) { | | 15 | static int read_toc_header(int fd, int *first, int *last) { |
18 | struct ioc_toc_header th; | | 16 | struct ioc_toc_header th; |
19 | +#ifdef __NetBSD__ | | 17 | +#ifdef __NetBSD__ |
20 | + struct cd_toc_entry td; | | 18 | + struct cd_toc_entry td; |
21 | + struct ioc_read_toc_entry te; | | 19 | + struct ioc_read_toc_entry te; |
22 | +#else | | 20 | +#else |
23 | struct ioc_read_toc_single_entry te; | | 21 | struct ioc_read_toc_single_entry te; |
24 | +#endif | | 22 | +#endif |
25 | | | 23 | |
26 | int ret = ioctl(fd, CDIOREADTOCHEADER, &th); | | 24 | int ret = ioctl(fd, CDIOREADTOCHEADER, &th); |
27 | | | 25 | |
28 | @@ -68,10 +76,20 @@ static int read_toc_header(int fd, int * | | 26 | @@ -67,10 +75,20 @@ static int read_toc_header(int fd, int * |
29 | * session are handled correctly. | | 27 | * session are handled correctly. |
30 | */ | | 28 | */ |
31 | te.address_format = CD_LBA_FORMAT; | | 29 | te.address_format = CD_LBA_FORMAT; |
32 | +#ifdef __NetBSD__ | | 30 | +#ifdef __NetBSD__ |
33 | + te.starting_track = th.ending_track; | | 31 | + te.starting_track = th.ending_track; |
34 | + te.data_len = sizeof(td); | | 32 | + te.data_len = sizeof(td); |
35 | + te.data = &td; | | 33 | + te.data = &td; |
36 | +#else | | 34 | +#else |
37 | te.track = th.ending_track; | | 35 | te.track = th.ending_track; |
38 | +#endif | | 36 | +#endif |
39 | ret = ioctl(fd, CDIOREADTOCENTRY, &te); | | 37 | ret = ioctl(fd, CDIOREADTOCENTRY, &te); |
40 | | | 38 | |
41 | +#ifdef __NetBSD__ | | 39 | +#ifdef __NetBSD__ |
42 | + if (( td.control & CD_DATA_TRACK) != 0 ) | | 40 | + if (( td.control & CD_DATA_TRACK) != 0 ) |
43 | +#else | | 41 | +#else |
44 | if (( te.entry.control & CD_DATA_TRACK) != 0 ) | | 42 | if (( te.entry.control & CD_DATA_TRACK) != 0 ) |
45 | +#endif | | 43 | +#endif |
46 | (*last)--; | | 44 | (*last)--; |
47 | | | 45 | |
48 | return ret; | | 46 | return ret; |
49 | @@ -79,17 +97,32 @@ static int read_toc_header(int fd, int * | | 47 | @@ -78,17 +96,32 @@ static int read_toc_header(int fd, int * |
50 | | | 48 | |
51 | | | 49 | |
52 | static int read_toc_entry(int fd, int track_num, unsigned long *lba) { | | 50 | static int read_toc_entry(int fd, int track_num, unsigned long *lba) { |
53 | +#ifdef __NetBSD__ | | 51 | +#ifdef __NetBSD__ |
54 | + struct cd_toc_entry td; | | 52 | + struct cd_toc_entry td; |
55 | + struct ioc_read_toc_entry te; | | 53 | + struct ioc_read_toc_entry te; |
56 | +#else | | 54 | +#else |
57 | struct ioc_read_toc_single_entry te; | | 55 | struct ioc_read_toc_single_entry te; |
58 | +#endif | | 56 | +#endif |
59 | int ret; | | 57 | int ret; |
60 | | | 58 | |
61 | +#ifdef __NetBSD__ | | 59 | +#ifdef __NetBSD__ |
62 | + te.starting_track = track_num; | | 60 | + te.starting_track = track_num; |
| @@ -69,27 +67,27 @@ $NetBSD: patch-ab,v 1.1 2009/07/07 17:44 | | | @@ -69,27 +67,27 @@ $NetBSD: patch-ab,v 1.1 2009/07/07 17:44 |
69 | | | 67 | |
70 | ret = ioctl(fd, CDIOREADTOCENTRY, &te); | | 68 | ret = ioctl(fd, CDIOREADTOCENTRY, &te); |
71 | assert( te.address_format == CD_LBA_FORMAT ); | | 69 | assert( te.address_format == CD_LBA_FORMAT ); |
72 | | | 70 | |
73 | if ( ret == 0 ) | | 71 | if ( ret == 0 ) |
74 | +#ifdef __NetBSD__ | | 72 | +#ifdef __NetBSD__ |
75 | + *lba = td.addr.lba; | | 73 | + *lba = td.addr.lba; |
76 | +#else | | 74 | +#else |
77 | *lba = ntohl(te.entry.addr.lba); | | 75 | *lba = ntohl(te.entry.addr.lba); |
78 | +#endif | | 76 | +#endif |
79 | | | 77 | |
80 | return ret; | | 78 | return ret; |
81 | } | | 79 | } |
82 | @@ -97,16 +130,32 @@ static int read_toc_entry(int fd, int tr | | 80 | @@ -96,16 +129,32 @@ static int read_toc_entry(int fd, int tr |
83 | | | 81 | |
84 | static int read_leadout(int fd, unsigned long *lba) { | | 82 | static int read_leadout(int fd, unsigned long *lba) { |
85 | struct ioc_toc_header th; | | 83 | struct ioc_toc_header th; |
86 | +#ifdef __NetBSD__ | | 84 | +#ifdef __NetBSD__ |
87 | + struct cd_toc_entry td; | | 85 | + struct cd_toc_entry td; |
88 | + struct ioc_read_toc_entry te; | | 86 | + struct ioc_read_toc_entry te; |
89 | +#else | | 87 | +#else |
90 | struct ioc_read_toc_single_entry te; | | 88 | struct ioc_read_toc_single_entry te; |
91 | +#endif | | 89 | +#endif |
92 | int ret; | | 90 | int ret; |
93 | | | 91 | |
94 | ret = ioctl(fd, CDIOREADTOCHEADER, &th); | | 92 | ret = ioctl(fd, CDIOREADTOCHEADER, &th); |
95 | +#ifdef __NetBSD__ | | 93 | +#ifdef __NetBSD__ |