annotate stream/vcd_read_nbsd.h @ 21656:32c50eb3ff18

in STREAM_WRITE mode open the stream with O_RDWR|O_CREAT, S_IRUSR|S_IWUSR and disable seek_forward for pipes
author nicodvb
date Mon, 18 Dec 2006 20:53:40 +0000
parents 64d82a45a05d
children 773e6c50d1b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
1
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
2 #include <sys/types.h>
12797
b2419eef04da OpenBSD portability patches from the OpenBSD ports tree
diego
parents: 9887
diff changeset
3 #ifdef __NetBSD__
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
4 #include <sys/inttypes.h>
12797
b2419eef04da OpenBSD portability patches from the OpenBSD ports tree
diego
parents: 9887
diff changeset
5 #endif
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
6 #include <sys/cdio.h>
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
7 #include <sys/scsiio.h>
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
8
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
9 #define CDROM_LEADOUT 0xAA
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
10
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
11 typedef struct mp_vcd_priv_st {
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
12 int fd;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
13 struct ioc_read_toc_entry entry;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
14 struct cd_toc_entry entry_data;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
15 } mp_vcd_priv_t;
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
16
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
17 static inline void
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
18 vcd_set_msf(mp_vcd_priv_t* vcd, unsigned int sect)
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
19 {
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
20 vcd->entry_data.addr.msf.frame = sect % 75;
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
21 sect = sect / 75;
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
22 vcd->entry_data.addr.msf.second = sect % 60;
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
23 sect = sect / 60;
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
24 vcd->entry_data.addr.msf.minute = sect;
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
25 }
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
26
8532
9688aa033083 fix VCD playback - this is a patch from the netbsd pkgsrc tree,
arpi
parents: 7406
diff changeset
27 static inline void
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
28 vcd_inc_msf(mp_vcd_priv_t* vcd)
8532
9688aa033083 fix VCD playback - this is a patch from the netbsd pkgsrc tree,
arpi
parents: 7406
diff changeset
29 {
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
30 vcd->entry_data.addr.msf.frame++;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
31 if (vcd->entry_data.addr.msf.frame==75){
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
32 vcd->entry_data.addr.msf.frame=0;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
33 vcd->entry_data.addr.msf.second++;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
34 if (vcd->entry_data.addr.msf.second==60){
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
35 vcd->entry_data.addr.msf.second=0;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
36 vcd->entry_data.addr.msf.minute++;
8532
9688aa033083 fix VCD playback - this is a patch from the netbsd pkgsrc tree,
arpi
parents: 7406
diff changeset
37 }
9688aa033083 fix VCD playback - this is a patch from the netbsd pkgsrc tree,
arpi
parents: 7406
diff changeset
38 }
9688aa033083 fix VCD playback - this is a patch from the netbsd pkgsrc tree,
arpi
parents: 7406
diff changeset
39 }
9688aa033083 fix VCD playback - this is a patch from the netbsd pkgsrc tree,
arpi
parents: 7406
diff changeset
40
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
41 static inline unsigned int
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
42 vcd_get_msf(mp_vcd_priv_t* vcd)
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
43 {
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
44 return vcd->entry_data.addr.msf.frame +
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
45 (vcd->entry_data.addr.msf.second +
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
46 vcd->entry_data.addr.msf.minute * 60) * 75;
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
47 }
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
48
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
49 int
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
50 vcd_seek_to_track(mp_vcd_priv_t* vcd, int track)
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
51 {
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
52 vcd->entry.address_format = CD_MSF_FORMAT;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
53 vcd->entry.starting_track = track;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
54 vcd->entry.data_len = sizeof(struct cd_toc_entry);
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
55 vcd->entry.data = &vcd->entry_data;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
56 if (ioctl(vcd->fd, CDIOREADTOCENTRIES, &vcd->entry)) {
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
57 mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif1: %s\n",strerror(errno));
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
58 return -1;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
59 }
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
60 return VCD_SECTOR_DATA * vcd_get_msf(vcd);
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
61 }
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
62
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
63 int
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
64 vcd_get_track_end(mp_vcd_priv_t* vcd, int track)
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
65 {
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
66 struct ioc_toc_header tochdr;
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
67 if (ioctl(vcd->fd, CDIOREADTOCHEADER, &tochdr) == -1) {
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
68 mp_msg(MSGT_STREAM,MSGL_ERR,"read CDROM toc header: %s\n",strerror(errno));
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
69 return -1;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
70 }
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
71 vcd->entry.address_format = CD_MSF_FORMAT;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
72 vcd->entry.starting_track = track < tochdr.ending_track ? (track + 1) : CDROM_LEADOUT;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
73 vcd->entry.data_len = sizeof(struct cd_toc_entry);
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
74 vcd->entry.data = &vcd->entry_data;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
75 if (ioctl(vcd->fd, CDIOREADTOCENTRYS, &vcd->entry)) {
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
76 mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif2: %s\n",strerror(errno));
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
77 return -1;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
78 }
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
79 return VCD_SECTOR_DATA * vcd_get_msf(vcd);
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
80 }
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
81
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
82 mp_vcd_priv_t*
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
83 vcd_read_toc(int fd)
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
84 {
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
85 struct ioc_toc_header tochdr;
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
86 mp_vcd_priv_t* vcd;
16547
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
87 int i, min = 0, sec = 0, frame = 0;
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
88 if (ioctl(fd, CDIOREADTOCHEADER, &tochdr) == -1) {
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
89 mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc header: %s\n",strerror(errno));
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
90 return;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
91 }
18237
4231482179b6 Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents: 16547
diff changeset
92 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_START_TRACK=%d\n", tochdr.starting_track);
4231482179b6 Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents: 16547
diff changeset
93 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_END_TRACK=%d\n", tochdr.ending_track);
16547
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
94 for (i = tochdr.starting_track; i <= tochdr.ending_track + 1; i++) {
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
95 struct ioc_read_toc_entry tocentry;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
96 struct cd_toc_entry tocentry_data;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
97
16547
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
98 tocentry.starting_track = i<=tochdr.ending_track ? i : CDROM_LEADOUT;
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
99 tocentry.address_format = CD_MSF_FORMAT;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
100 tocentry.data_len = sizeof(struct cd_toc_entry);
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
101 tocentry.data = &tocentry_data;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
102
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
103 if (ioctl(fd, CDIOREADTOCENTRYS, &tocentry) == -1) {
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
104 mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc entry: %s\n",strerror(errno));
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
105 return NULL;
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
106 }
16547
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
107 if (i <= tochdr.ending_track)
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
108 mp_msg(MSGT_OPEN,MSGL_INFO,"track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d\n",
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
109 (int) tocentry.starting_track,
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
110 (int) tocentry.data->addr_type,
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
111 (int) tocentry.data->control,
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
112 (int) tocentry.address_format,
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
113 (int) tocentry.data->addr.msf.minute,
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
114 (int) tocentry.data->addr.msf.second,
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
115 (int) tocentry.data->addr.msf.frame
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
116 );
16547
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
117
18237
4231482179b6 Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents: 16547
diff changeset
118 if (mp_msg_test(MSGT_IDENTIFY, MSGL_INFO))
16547
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
119 {
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
120 if (i > tochdr.starting_track)
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
121 {
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
122 min = tocentry.data->addr.msf.minute - min;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
123 sec = tocentry.data->addr.msf.second - sec;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
124 frame = tocentry.data->addr.msf.frame - frame;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
125 if ( frame < 0 )
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
126 {
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
127 frame += 75;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
128 sec --;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
129 }
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
130 if ( sec < 0 )
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
131 {
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
132 sec += 60;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
133 min --;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
134 }
18237
4231482179b6 Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents: 16547
diff changeset
135 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_TRACK_%d_MSF=%02d:%02d:%02d\n", i - 1, min, sec, frame);
16547
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
136 }
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
137 min = tocentry.data->addr.msf.minute;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
138 sec = tocentry.data->addr.msf.second;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
139 frame = tocentry.data->addr.msf.frame;
aa15d627a00b Prints the numbers of start and end tracks and MSF length for each
gpoirier
parents: 12797
diff changeset
140 }
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
141 }
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
142 vcd = malloc(sizeof(mp_vcd_priv_t));
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
143 vcd->fd = fd;
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
144 return vcd;
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
145 }
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
146
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
147 static int
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
148 vcd_read(mp_vcd_priv_t* vcd, char *mem)
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
149 {
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
150 struct scsireq sc;
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
151 int lba = vcd_get_msf(vcd);
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
152 int blocks;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
153 int sector_type;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
154 int sync, header_code, user_data, edc_ecc, error_field;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
155 int sub_channel;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
156 int rc;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
157
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
158 blocks = 1;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
159 sector_type = 5; /* mode2/form2 */
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
160 sync = 0;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
161 header_code = 0;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
162 user_data = 1;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
163 edc_ecc = 0;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
164 error_field = 0;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
165 sub_channel = 0;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
166
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
167 memset(&sc, 0, sizeof(sc));
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
168 sc.cmd[0] = 0xBE;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
169 sc.cmd[1] = (sector_type) << 2;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
170 sc.cmd[2] = (lba >> 24) & 0xff;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
171 sc.cmd[3] = (lba >> 16) & 0xff;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
172 sc.cmd[4] = (lba >> 8) & 0xff;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
173 sc.cmd[5] = lba & 0xff;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
174 sc.cmd[6] = (blocks >> 16) & 0xff;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
175 sc.cmd[7] = (blocks >> 8) & 0xff;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
176 sc.cmd[8] = blocks & 0xff;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
177 sc.cmd[9] = (sync << 7) | (header_code << 5) | (user_data << 4) |
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
178 (edc_ecc << 3) | (error_field << 1);
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
179 sc.cmd[10] = sub_channel;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
180 sc.cmdlen = 12;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
181 sc.databuf = (caddr_t) mem;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
182 sc.datalen = 2328;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
183 sc.senselen = sizeof(sc.sense);
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
184 sc.flags = SCCMD_READ;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
185 sc.timeout = 10000;
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
186 rc = ioctl(vcd->fd, SCIOCCOMMAND, &sc);
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
187 if (rc == -1) {
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
188 mp_msg(MSGT_STREAM,MSGL_ERR,"SCIOCCOMMAND: %s\n",strerror(errno));
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
189 return -1;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
190 }
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
191 if (sc.retsts || sc.error) {
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
192 mp_msg(MSGT_STREAM,MSGL_ERR,"scsi command failed: status %d error %d\n",
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
193 sc.retsts,sc.error);
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
194 return -1;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
195 }
9887
d862231858d5 Make the vcd API fully reentrant.
albeu
parents: 8532
diff changeset
196 vcd_inc_msf(vcd);
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
197 return VCD_SECTOR_DATA;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
198 }
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents:
diff changeset
199