1 Index: interface/test_interface.c
2 ===================================================================
3 --- interface/test_interface.c (Revision 15337)
4 +++ interface/test_interface.c (Revision 15340)
6 if(!fd)fd=fdopen(d->cdda_fd,"r");
9 - d->private->last_milliseconds=20;
10 + d->private_data->last_milliseconds=20;
12 - d->private->last_milliseconds=sectors;
13 + d->private_data->last_milliseconds=sectors;
15 #ifdef CDDA_TEST_UNDERRUN
17 Index: interface/cdda_interface.h
18 ===================================================================
19 --- interface/cdda_interface.h (Revision 15337)
20 +++ interface/cdda_interface.h (Revision 15340)
25 - cdda_private_data_t *private;
26 + cdda_private_data_t *private_data;
28 unsigned char inqbytes[4];
30 Index: interface/interface.c
31 ===================================================================
32 --- interface/interface.c (Revision 15337)
33 +++ interface/interface.c (Revision 15340)
35 if(d->drive_model)free(d->drive_model);
36 if(d->cdda_fd!=-1)close(d->cdda_fd);
37 if(d->ioctl_fd!=-1 && d->ioctl_fd!=d->cdda_fd)close(d->ioctl_fd);
39 - if(d->private->sg_hd)free(d->private->sg_hd);
41 + if(d->private_data){
42 + if(d->private_data->sg_hd)free(d->private_data->sg_hd);
43 + free(d->private_data);
51 - if(ms)*ms=d->private->last_milliseconds;
52 + if(ms)*ms=d->private_data->last_milliseconds;
56 Index: interface/scsi_interface.c
57 ===================================================================
58 --- interface/scsi_interface.c (Revision 15337)
59 +++ interface/scsi_interface.c (Revision 15340)
61 static int timed_ioctl(cdrom_drive *d, int fd, int command, void *arg){
64 - int ret1=clock_gettime(d->private->clock,&tv1);
65 + int ret1=clock_gettime(d->private_data->clock,&tv1);
66 int ret2=ioctl(fd, command,arg);
67 - int ret3=clock_gettime(d->private->clock,&tv2);
68 + int ret3=clock_gettime(d->private_data->clock,&tv2);
70 - d->private->last_milliseconds=-1;
71 + d->private_data->last_milliseconds=-1;
73 - d->private->last_milliseconds = (tv2.tv_sec-tv1.tv_sec)*1000. + (tv2.tv_nsec-tv1.tv_nsec)/1000000.;
74 + d->private_data->last_milliseconds = (tv2.tv_sec-tv1.tv_sec)*1000. + (tv2.tv_nsec-tv1.tv_nsec)/1000000.;
79 static void clear_garbage(cdrom_drive *d){
82 - struct sg_header *sg_hd=d->private->sg_hd;
83 + struct sg_header *sg_hd=d->private_data->sg_hd;
86 /* clear out any possibly preexisting garbage */
91 - struct sg_header *sg_hd=d->private->sg_hd;
92 + struct sg_header *sg_hd=d->private_data->sg_hd;
93 long writebytes=SG_OFF+cmd_len+in_size;
95 /* generic scsi device services */
98 memset(sg_hd,0,sizeof(sg_hd));
99 memset(sense_buffer,0,SG_MAX_SENSE);
100 - memcpy(d->private->sg_buffer,cmd,cmd_len+in_size);
101 + memcpy(d->private_data->sg_buffer,cmd,cmd_len+in_size);
102 sg_hd->twelve_byte = cmd_len == 12;
104 sg_hd->reply_len = SG_OFF + out_size;
106 tell if the command failed. Scared yet? */
108 if(bytecheck && out_size>in_size){
109 - memset(d->private->sg_buffer+cmd_len+in_size,bytefill,out_size-in_size);
110 + memset(d->private_data->sg_buffer+cmd_len+in_size,bytefill,out_size-in_size);
111 /* the size does not remove cmd_len due to the way the kernel
112 driver copies buffers */
113 writebytes+=(out_size-in_size);
117 sigprocmask (SIG_BLOCK, &(d->sigset), NULL );
118 - tret1=clock_gettime(d->private->clock,&tv1);
119 + tret1=clock_gettime(d->private_data->clock,&tv1);
121 status = write(d->cdda_fd, sg_hd, writebytes );
127 - tret2=clock_gettime(d->private->clock,&tv2);
128 + tret2=clock_gettime(d->private_data->clock,&tv2);
130 status = read(d->cdda_fd, sg_hd, SG_OFF + out_size);
131 sigprocmask ( SIG_UNBLOCK, &(d->sigset), NULL );
133 if(bytecheck && in_size+cmd_len<out_size){
135 for(i=in_size;i<out_size;i++)
136 - if(d->private->sg_buffer[i]!=bytefill){
137 + if(d->private_data->sg_buffer[i]!=bytefill){
144 if(tret1<0 || tret2<0){
145 - d->private->last_milliseconds=-1;
146 + d->private_data->last_milliseconds=-1;
148 - d->private->last_milliseconds = (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_nsec-tv1.tv_nsec)/1000000;
149 + d->private_data->last_milliseconds = (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_nsec-tv1.tv_nsec)/1000000;
155 memset(&hdr,0,sizeof(hdr));
156 memset(sense,0,sizeof(sense));
157 - memcpy(d->private->sg_buffer,cmd+cmd_len,in_size);
158 + memcpy(d->private_data->sg_buffer,cmd+cmd_len,in_size);
161 hdr.cmd_len = cmd_len;
163 hdr.mx_sb_len = SG_MAX_SENSE;
165 hdr.interface_id = 'S';
166 - hdr.dxferp = d->private->sg_buffer;
167 + hdr.dxferp = d->private_data->sg_buffer;
168 hdr.flags = SG_FLAG_DIRECT_IO; /* direct IO if we can get it */
170 /* scary buffer fill hack */
172 if(bytecheck && in_size<out_size){
174 for(i=in_size;i<out_size;i++)
175 - if(d->private->sg_buffer[i]!=bytefill){
176 + if(d->private_data->sg_buffer[i]!=bytefill){
183 /* Can't rely on .duration because we can't be certain kernel has HZ set to something useful */
184 - /* d->private->last_milliseconds = hdr.duration; */
185 + /* d->private_data->last_milliseconds = hdr.duration; */
191 handle_scsi_cmd(d, cmd, 6, 0, 56, 0,0, sense);
193 - key = d->private->sg_buffer[2] & 0xf;
194 - ASC = d->private->sg_buffer[12];
195 - ASCQ = d->private->sg_buffer[13];
196 + key = d->private_data->sg_buffer[2] & 0xf;
197 + ASC = d->private_data->sg_buffer[12];
198 + ASCQ = d->private_data->sg_buffer[13];
200 if(key == 2 && ASC == 4 && ASCQ == 1) return 0;
203 if (handle_scsi_cmd (d, cmd, 10, 0, size+4,'\377',1,sense)) return(1);
206 - unsigned char *b=d->private->sg_buffer;
207 + unsigned char *b=d->private_data->sg_buffer;
208 if(b[0])return(1); /* Handles only up to 256 bytes */
209 if(b[6])return(1); /* Handles only up to 256 bytes */
212 static unsigned int get_orig_sectorsize(cdrom_drive *d){
213 if(mode_sense(d,12,0x01))return(-1);
215 - d->orgdens = d->private->sg_buffer[4];
216 - return(d->orgsize = ((int)(d->private->sg_buffer[10])<<8)+d->private->sg_buffer[11]);
217 + d->orgdens = d->private_data->sg_buffer[4];
218 + return(d->orgsize = ((int)(d->private_data->sg_buffer[10])<<8)+d->private_data->sg_buffer[11]);
221 /* switch CDROM scsi drives to given sector size */
226 - first=d->private->sg_buffer[2];
227 - last=d->private->sg_buffer[3];
228 + first=d->private_data->sg_buffer[2];
229 + last=d->private_data->sg_buffer[3];
232 if (last > MAXTRK || first > MAXTRK || last<0 || first<0) {
237 - scsi_TOC *toc=(scsi_TOC *)(d->private->sg_buffer+4);
238 + scsi_TOC *toc=(scsi_TOC *)(d->private_data->sg_buffer+4);
240 d->disc_toc[i-first].bFlags=toc->bFlags;
241 d->disc_toc[i-first].bTrack=i;
246 - scsi_TOC *toc=(scsi_TOC *)(d->private->sg_buffer+4);
247 + scsi_TOC *toc=(scsi_TOC *)(d->private_data->sg_buffer+4);
249 d->disc_toc[i-first].bFlags=toc->bFlags;
250 d->disc_toc[i-first].bTrack=0xAA;
254 /* copy to our structure and convert start sector */
255 - tracks = d->private->sg_buffer[1];
256 + tracks = d->private_data->sg_buffer[1];
257 if (tracks > MAXTRK) {
258 cderror(d,"003: CDROM reporting illegal number of tracks\n");
260 @@ -754,33 +754,33 @@
264 - d->disc_toc[i].bFlags = d->private->sg_buffer[10];
265 + d->disc_toc[i].bFlags = d->private_data->sg_buffer[10];
266 d->disc_toc[i].bTrack = i + 1;
268 d->disc_toc[i].dwStartSector= d->adjust_ssize *
269 - (((signed char)(d->private->sg_buffer[2])<<24) |
270 - (d->private->sg_buffer[3]<<16)|
271 - (d->private->sg_buffer[4]<<8)|
272 - (d->private->sg_buffer[5]));
273 + (((signed char)(d->private_data->sg_buffer[2])<<24) |
274 + (d->private_data->sg_buffer[3]<<16)|
275 + (d->private_data->sg_buffer[4]<<8)|
276 + (d->private_data->sg_buffer[5]));
279 d->disc_toc[i].bFlags = 0;
280 d->disc_toc[i].bTrack = i + 1;
281 - memcpy (&foo, d->private->sg_buffer+2, 4);
282 - memcpy (&bar, d->private->sg_buffer+6, 4);
283 + memcpy (&foo, d->private_data->sg_buffer+2, 4);
284 + memcpy (&bar, d->private_data->sg_buffer+6, 4);
285 d->disc_toc[i].dwStartSector = d->adjust_ssize * (be32_to_cpu(foo) +
288 d->disc_toc[i].dwStartSector= d->adjust_ssize *
289 - ((((signed char)(d->private->sg_buffer[2])<<24) |
290 - (d->private->sg_buffer[3]<<16)|
291 - (d->private->sg_buffer[4]<<8)|
292 - (d->private->sg_buffer[5]))+
293 + ((((signed char)(d->private_data->sg_buffer[2])<<24) |
294 + (d->private_data->sg_buffer[3]<<16)|
295 + (d->private_data->sg_buffer[4]<<8)|
296 + (d->private_data->sg_buffer[5]))+
298 - ((((signed char)(d->private->sg_buffer[6])<<24) |
299 - (d->private->sg_buffer[7]<<16)|
300 - (d->private->sg_buffer[8]<<8)|
301 - (d->private->sg_buffer[9]))));
302 + ((((signed char)(d->private_data->sg_buffer[6])<<24) |
303 + (d->private_data->sg_buffer[7]<<16)|
304 + (d->private_data->sg_buffer[8]<<8)|
305 + (d->private_data->sg_buffer[9]))));
308 d->cd_extra = FixupTOC(d,tracks+1);
311 if((ret=handle_scsi_cmd(d,cmd,10,0,sectors * CD_FRAMESIZE_RAW,'\177',1,sense)))
313 - if(p)memcpy(p,d->private->sg_buffer,sectors*CD_FRAMESIZE_RAW);
314 + if(p)memcpy(p,d->private_data->sg_buffer,sectors*CD_FRAMESIZE_RAW);
320 if((ret=handle_scsi_cmd(d,cmd,12,0,sectors * CD_FRAMESIZE_RAW,'\177',1,sense)))
322 - if(p)memcpy(p,d->private->sg_buffer,sectors*CD_FRAMESIZE_RAW);
323 + if(p)memcpy(p,d->private_data->sg_buffer,sectors*CD_FRAMESIZE_RAW);
329 if((ret=handle_scsi_cmd(d,cmd,10,0,sectors * CD_FRAMESIZE_RAW,'\177',1,sense)))
331 - if(p)memcpy(p,d->private->sg_buffer,sectors*CD_FRAMESIZE_RAW);
332 + if(p)memcpy(p,d->private_data->sg_buffer,sectors*CD_FRAMESIZE_RAW);
338 if((ret=handle_scsi_cmd(d,cmd,12,0,sectors * CD_FRAMESIZE_RAW,'\177',1,sense)))
340 - if(p)memcpy(p,d->private->sg_buffer,sectors*CD_FRAMESIZE_RAW);
341 + if(p)memcpy(p,d->private_data->sg_buffer,sectors*CD_FRAMESIZE_RAW);
347 if((ret=handle_scsi_cmd(d,cmd,10,0,sectors * CD_FRAMESIZE_RAW,'\177',1,sense)))
349 - if(p)memcpy(p,d->private->sg_buffer,sectors*CD_FRAMESIZE_RAW);
350 + if(p)memcpy(p,d->private_data->sg_buffer,sectors*CD_FRAMESIZE_RAW);
356 if((ret=handle_scsi_cmd(d,cmd,12,0,sectors * CD_FRAMESIZE_RAW,'\177',1,sense)))
358 - if(p)memcpy(p,d->private->sg_buffer,sectors*CD_FRAMESIZE_RAW);
359 + if(p)memcpy(p,d->private_data->sg_buffer,sectors*CD_FRAMESIZE_RAW);
365 if((ret=handle_scsi_cmd(d,cmd,12,0,sectors * CD_FRAMESIZE_RAW,'\177',1,sense)))
367 - if(p)memcpy(p,d->private->sg_buffer,sectors*CD_FRAMESIZE_RAW);
368 + if(p)memcpy(p,d->private_data->sg_buffer,sectors*CD_FRAMESIZE_RAW);
374 if((ret=handle_scsi_cmd(d,cmd,12,0,sectors * CD_FRAMESIZE_RAW,'\177',1,sense)))
376 - if(p)memcpy(p,d->private->sg_buffer,sectors*CD_FRAMESIZE_RAW);
377 + if(p)memcpy(p,d->private_data->sg_buffer,sectors*CD_FRAMESIZE_RAW);
383 if((ret=handle_scsi_cmd(d,cmd,12,0,sectors * CD_FRAMESIZE_RAW,'\177',1,sense)))
385 - if(p)memcpy(p,d->private->sg_buffer,sectors*CD_FRAMESIZE_RAW);
386 + if(p)memcpy(p,d->private_data->sg_buffer,sectors*CD_FRAMESIZE_RAW);
392 if((ret=handle_scsi_cmd(d,cmd,12,0,sectors * CD_FRAMESIZE_RAW,'\177',1,sense)))
394 - if(p)memcpy(p,d->private->sg_buffer,sectors*CD_FRAMESIZE_RAW);
395 + if(p)memcpy(p,d->private_data->sg_buffer,sectors*CD_FRAMESIZE_RAW);
401 if((ret=handle_scsi_cmd(d,cmd,12,0,sectors * CD_FRAMESIZE_RAW,'\177',1,sense)))
403 - if(p)memcpy(p,d->private->sg_buffer,sectors*CD_FRAMESIZE_RAW);
404 + if(p)memcpy(p,d->private_data->sg_buffer,sectors*CD_FRAMESIZE_RAW);
410 if((ret=handle_scsi_cmd(d,cmd,12,0,sectors * CD_FRAMESIZE_RAW,'\177',1,sense)))
412 - if(p)memcpy(p,d->private->sg_buffer,sectors*CD_FRAMESIZE_RAW);
413 + if(p)memcpy(p,d->private_data->sg_buffer,sectors*CD_FRAMESIZE_RAW);
417 @@ -1026,7 +1026,7 @@
419 if((ret=handle_scsi_cmd(d,cmd,12,0,sectors * CD_FRAMESIZE_RAW,'\177',1,sense)))
421 - if(p)memcpy(p,d->private->sg_buffer,sectors*CD_FRAMESIZE_RAW);
422 + if(p)memcpy(p,d->private_data->sg_buffer,sectors*CD_FRAMESIZE_RAW);
426 @@ -1039,7 +1039,7 @@
428 if((ret=handle_scsi_cmd(d,cmd,12,0,sectors * CD_FRAMESIZE_RAW,'\177',1,sense)))
430 - if(p)memcpy(p,d->private->sg_buffer,sectors*CD_FRAMESIZE_RAW);
431 + if(p)memcpy(p,d->private_data->sg_buffer,sectors*CD_FRAMESIZE_RAW);
435 @@ -1052,7 +1052,7 @@
437 if((ret=handle_scsi_cmd(d,cmd,12,0,sectors * CD_FRAMESIZE_RAW,'\177',1,sense)))
439 - if(p)memcpy(p,d->private->sg_buffer,sectors*CD_FRAMESIZE_RAW);
440 + if(p)memcpy(p,d->private_data->sg_buffer,sectors*CD_FRAMESIZE_RAW);
444 @@ -1275,7 +1275,7 @@
445 static int count_2352_bytes(cdrom_drive *d){
448 - if(d->private->sg_buffer[i]!=(unsigned char)'\177')
449 + if(d->private_data->sg_buffer[i]!=(unsigned char)'\177')
450 return(((i+3)>>2)<<2);
453 @@ -1284,7 +1284,7 @@
454 static int verify_nonzero(cdrom_drive *d){
457 - if(d->private->sg_buffer[i]!=0){
458 + if(d->private_data->sg_buffer[i]!=0){
462 @@ -1621,7 +1621,7 @@
464 if(mode_sense(d,22,0x2A)==0){
466 - b=d->private->sg_buffer;
467 + b=d->private_data->sg_buffer;
470 if((b[0]&0x3F)==0x2A){
471 @@ -1669,7 +1669,7 @@
472 cderror(d,"008: Unable to identify CDROM model\n");
475 - return (d->private->sg_buffer);
476 + return (d->private_data->sg_buffer);
479 int scsi_init_drive(cdrom_drive *d){
480 @@ -1725,8 +1725,8 @@
484 - d->private->sg_hd=realloc(d->private->sg_hd,d->nsectors*CD_FRAMESIZE_RAW + SG_OFF + 128);
485 - d->private->sg_buffer=((unsigned char *)d->private->sg_hd)+SG_OFF;
486 + d->private_data->sg_hd=realloc(d->private_data->sg_hd,d->nsectors*CD_FRAMESIZE_RAW + SG_OFF + 128);
487 + d->private_data->sg_buffer=((unsigned char *)d->private_data->sg_hd)+SG_OFF;
491 Index: interface/cooked_interface.c
492 ===================================================================
493 --- interface/cooked_interface.c (Revision 15337)
494 +++ interface/cooked_interface.c (Revision 15340)
496 static int timed_ioctl(cdrom_drive *d, int fd, int command, void *arg){
499 - int ret1=clock_gettime(d->private->clock,&tv1);
500 + int ret1=clock_gettime(d->private_data->clock,&tv1);
501 int ret2=ioctl(fd, command,arg);
502 - int ret3=clock_gettime(d->private->clock,&tv2);
503 + int ret3=clock_gettime(d->private_data->clock,&tv2);
504 if(ret1<0 || ret3<0){
505 - d->private->last_milliseconds=-1;
506 + d->private_data->last_milliseconds=-1;
508 - d->private->last_milliseconds = (tv2.tv_sec-tv1.tv_sec)*1000. + (tv2.tv_nsec-tv1.tv_nsec)/1000000.;
509 + d->private_data->last_milliseconds = (tv2.tv_sec-tv1.tv_sec)*1000. + (tv2.tv_nsec-tv1.tv_nsec)/1000000.;
513 Index: interface/scan_devices.c
514 ===================================================================
515 --- interface/scan_devices.c (Revision 15337)
516 +++ interface/scan_devices.c (Revision 15340)
517 @@ -264,11 +264,11 @@
518 d->interface=COOKED_IOCTL;
519 d->bigendianp=-1; /* We don't know yet... */
521 - d->private=calloc(1,sizeof(*d->private));
522 + d->private_data=calloc(1,sizeof(*d->private_data));
526 - d->private->clock=(clock_gettime(CLOCK_MONOTONIC,&tv)<0?CLOCK_REALTIME:CLOCK_MONOTONIC);
527 + d->private_data->clock=(clock_gettime(CLOCK_MONOTONIC,&tv)<0?CLOCK_REALTIME:CLOCK_MONOTONIC);
529 idmessage(messagedest,messages,"\t\tCDROM sensed: %s\n",description);
531 @@ -674,15 +674,15 @@
532 d->bigendianp=-1; /* We don't know yet... */
534 d->messagedest = messagedest;
535 - d->private=calloc(1,sizeof(*d->private));
536 + d->private_data=calloc(1,sizeof(*d->private_data));
540 - d->private->clock=(clock_gettime(CLOCK_MONOTONIC,&tv)<0?CLOCK_REALTIME:CLOCK_MONOTONIC);
541 + d->private_data->clock=(clock_gettime(CLOCK_MONOTONIC,&tv)<0?CLOCK_REALTIME:CLOCK_MONOTONIC);
544 d->interface=SGIO_SCSI;
545 - d->private->sg_buffer=(unsigned char *)(d->private->sg_hd=malloc(MAX_BIG_BUFF_SIZE));
546 + d->private_data->sg_buffer=(unsigned char *)(d->private_data->sg_hd=malloc(MAX_BIG_BUFF_SIZE));
547 g_fd=d->cdda_fd=dup(d->ioctl_fd);
549 version=verify_SG_version(d,messagedest,messages);
553 /* malloc our big buffer for scsi commands */
554 - d->private->sg_hd=malloc(MAX_BIG_BUFF_SIZE);
555 - d->private->sg_buffer=((unsigned char *)d->private->sg_hd)+SG_OFF;
556 + d->private_data->sg_hd=malloc(MAX_BIG_BUFF_SIZE);
557 + d->private_data->sg_buffer=((unsigned char *)d->private_data->sg_hd)+SG_OFF;
562 if(i_fd!=-1)close(i_fd);
563 if(g_fd!=-1)close(g_fd);
566 - if(d->private->sg_hd)free(d->private->sg_hd);
568 + if(d->private_data){
569 + if(d->private_data->sg_hd)free(d->private_data->sg_hd);
570 + free(d->private_data);
575 d->interface=TEST_INTERFACE;
576 d->bigendianp=-1; /* We don't know yet... */
578 - d->private=calloc(1,sizeof(*d->private));
579 + d->private_data=calloc(1,sizeof(*d->private_data));
580 d->drive_model=copystring("File based test interface");
581 idmessage(messagedest,messages,"\t\tCDROM sensed: %s\n",d->drive_model);