DKIOCCDREADTOC returning BCD numbers?
DKIOCCDREADTOC returning BCD numbers?
- Subject: DKIOCCDREADTOC returning BCD numbers?
- From: "Stephen F. Booth" <email@hidden>
- Date: Thu, 3 Jan 2008 19:56:52 -0800
One of my users reported a bug when accessing some of his CDs from an
external CD drive. After some debugging, it appears to me that the
CDTOC returned from the external drive contains BCD-encoded numbers.
My code which reads the TOC looks like:
dk_cd_read_toc_t cd_read_toc;
uint8_t buffer [2048];
bzero(&cd_read_toc, sizeof(cd_read_toc));
bzero(buffer, sizeof(buffer));
cd_read_toc.format = kCDTOCFormatTOC;
cd_read_toc.buffer = buffer;
cd_read_toc.bufferLength = sizeof(buffer);
result = ioctl([self fileDescriptor], DKIOCCDREADTOC, &cd_read_toc);
I inserted some debugging statements to print out the result. For the
same disc, here is what the user saw in each of his drives:
External Plextor:
2008-01-03 20:40:29.544 Max[3025:10b] TOC parsing complete
2008-01-03 20:40:29.545 Max[3025:10b] ====================
2008-01-03 20:40:29.546 Max[3025:10b] First session : 1
2008-01-03 20:40:29.547 Max[3025:10b] Last session : 1
2008-01-03 20:40:29.548 Max[3025:10b] Session number : 1
2008-01-03 20:40:29.548 Max[3025:10b] First track : 1
2008-01-03 20:40:29.549 Max[3025:10b] Last track : 38
2008-01-03 20:40:29.550 Max[3025:10b] Lead out : 519112
2008-01-03 20:40:29.550 Max[3025:10b] Track number 1
2008-01-03 20:40:29.551 Max[3025:10b] First sector : 51
2008-01-03 20:40:29.551 Max[3025:10b] Track number 2
2008-01-03 20:40:29.552 Max[3025:10b] First sector : 91133
2008-01-03 20:40:29.552 Max[3025:10b] Track number 3
2008-01-03 20:40:29.553 Max[3025:10b] First sector : 111482
2008-01-03 20:40:29.555 Max[3025:10b] Track number 4
2008-01-03 20:40:29.555 Max[3025:10b] First sector : 185858
2008-01-03 20:40:29.556 Max[3025:10b] Track number 5
2008-01-03 20:40:29.556 Max[3025:10b] First sector : 221062
2008-01-03 20:40:29.557 Max[3025:10b] Track number 6
2008-01-03 20:40:29.558 Max[3025:10b] First sector : 225426
2008-01-03 20:40:29.559 Max[3025:10b] Track number 7
2008-01-03 20:40:29.559 Max[3025:10b] First sector : 226433
2008-01-03 20:40:29.560 Max[3025:10b] Track number 8
2008-01-03 20:40:29.560 Max[3025:10b] First sector : 229476
2008-01-03 20:40:29.561 Max[3025:10b] Track number 9
2008-01-03 20:40:29.561 Max[3025:10b] First sector : 235476
2008-01-03 20:40:29.562 Max[3025:10b] Track number 10
2008-01-03 20:40:29.562 Max[3025:10b] First sector : 0
2008-01-03 20:40:29.562 Max[3025:10b] Track number 11
2008-01-03 20:40:29.563 Max[3025:10b] First sector : 0
2008-01-03 20:40:29.563 Max[3025:10b] Track number 12
2008-01-03 20:40:29.563 Max[3025:10b] First sector : 0
2008-01-03 20:40:29.564 Max[3025:10b] Track number 13
2008-01-03 20:40:29.564 Max[3025:10b] First sector : 0
2008-01-03 20:40:29.565 Max[3025:10b] Track number 14
2008-01-03 20:40:29.565 Max[3025:10b] First sector : 0
2008-01-03 20:40:29.566 Max[3025:10b] Track number 15
2008-01-03 20:40:29.566 Max[3025:10b] First sector : 0
2008-01-03 20:40:29.566 Max[3025:10b] Track number 16
2008-01-03 20:40:29.567 Max[3025:10b] First sector : 238551
2008-01-03 20:40:29.567 Max[3025:10b] Track number 17
2008-01-03 20:40:29.568 Max[3025:10b] First sector : 252351
2008-01-03 20:40:29.568 Max[3025:10b] Track number 18
2008-01-03 20:40:29.569 Max[3025:10b] First sector : 255876
2008-01-03 20:40:29.569 Max[3025:10b] Track number 19
2008-01-03 20:40:29.569 Max[3025:10b] First sector : 257826
2008-01-03 20:40:29.570 Max[3025:10b] Track number 20
2008-01-03 20:40:29.570 Max[3025:10b] First sector : 292749
2008-01-03 20:40:29.571 Max[3025:10b] Track number 21
2008-01-03 20:40:29.571 Max[3025:10b] First sector : 298626
2008-01-03 20:40:29.571 Max[3025:10b] Track number 22
2008-01-03 20:40:29.572 Max[3025:10b] First sector : 307813
2008-01-03 20:40:29.572 Max[3025:10b] Track number 23
2008-01-03 20:40:29.573 Max[3025:10b] First sector : 315158
2008-01-03 20:40:29.573 Max[3025:10b] Track number 24
2008-01-03 20:40:29.574 Max[3025:10b] First sector : 324487
2008-01-03 20:40:29.574 Max[3025:10b] Track number 25
2008-01-03 20:40:29.575 Max[3025:10b] First sector : 331401
2008-01-03 20:40:29.575 Max[3025:10b] Track number 26
2008-01-03 20:40:29.575 Max[3025:10b] First sector : 0
2008-01-03 20:40:29.576 Max[3025:10b] Track number 27
2008-01-03 20:40:29.576 Max[3025:10b] First sector : 0
2008-01-03 20:40:29.578 Max[3025:10b] Track number 28
2008-01-03 20:40:29.579 Max[3025:10b] First sector : 0
2008-01-03 20:40:29.579 Max[3025:10b] Track number 29
2008-01-03 20:40:29.591 Max[3025:10b] First sector : 0
2008-01-03 20:40:29.592 Max[3025:10b] Track number 30
2008-01-03 20:40:29.592 Max[3025:10b] First sector : 0
2008-01-03 20:40:29.592 Max[3025:10b] Track number 31
2008-01-03 20:40:29.593 Max[3025:10b] First sector : 0
2008-01-03 20:40:29.593 Max[3025:10b] Track number 32
2008-01-03 20:40:29.593 Max[3025:10b] First sector : 369233
2008-01-03 20:40:29.594 Max[3025:10b] Track number 33
2008-01-03 20:40:29.594 Max[3025:10b] First sector : 378426
2008-01-03 20:40:29.594 Max[3025:10b] Track number 34
2008-01-03 20:40:29.595 Max[3025:10b] First sector : 383113
2008-01-03 20:40:29.595 Max[3025:10b] Track number 35
2008-01-03 20:40:29.595 Max[3025:10b] First sector : 391701
2008-01-03 20:40:29.596 Max[3025:10b] Track number 36
2008-01-03 20:40:29.596 Max[3025:10b] First sector : 433508
2008-01-03 20:40:29.597 Max[3025:10b] Track number 37
2008-01-03 20:40:29.597 Max[3025:10b] First sector : 445851
2008-01-03 20:40:29.597 Max[3025:10b] Track number 38
2008-01-03 20:40:29.611 Max[3025:10b] First sector : 459051
---------------------------------------------------------------------------------------------------------------------------------------------------------
Internal Drive:
2008-01-03 20:43:03.275 Max[3042:10b] TOC parsing complete
2008-01-03 20:43:03.277 Max[3042:10b] ====================
2008-01-03 20:43:03.277 Max[3042:10b] First session : 1
2008-01-03 20:43:03.278 Max[3042:10b] Last session : 1
2008-01-03 20:43:03.278 Max[3042:10b] Session number : 1
2008-01-03 20:43:03.278 Max[3042:10b] First track : 1
2008-01-03 20:43:03.279 Max[3042:10b] Last track : 26
2008-01-03 20:43:03.279 Max[3042:10b] Lead out : 327820
2008-01-03 20:43:03.279 Max[3042:10b] Track number 1
2008-01-03 20:43:03.281 Max[3042:10b] First sector : 33
2008-01-03 20:43:03.281 Max[3042:10b] Track number 2
2008-01-03 20:43:03.282 Max[3042:10b] First sector : 63683
2008-01-03 20:43:03.282 Max[3042:10b] Track number 3
2008-01-03 20:43:03.282 Max[3042:10b] First sector : 83120
2008-01-03 20:43:03.283 Max[3042:10b] Track number 4
2008-01-03 20:43:03.283 Max[3042:10b] First sector : 131408
2008-01-03 20:43:03.284 Max[3042:10b] Track number 5
2008-01-03 20:43:03.284 Max[3042:10b] First sector : 138220
2008-01-03 20:43:03.284 Max[3042:10b] Track number 6
2008-01-03 20:43:03.285 Max[3042:10b] First sector : 142608
2008-01-03 20:43:03.285 Max[3042:10b] Track number 7
2008-01-03 20:43:03.286 Max[3042:10b] First sector : 144983
2008-01-03 20:43:03.286 Max[3042:10b] Track number 8
2008-01-03 20:43:03.286 Max[3042:10b] First sector : 148458
2008-01-03 20:43:03.287 Max[3042:10b] Track number 9
2008-01-03 20:43:03.287 Max[3042:10b] First sector : 154008
2008-01-03 20:43:03.287 Max[3042:10b] Track number 10
2008-01-03 20:43:03.288 Max[3042:10b] First sector : 157533
2008-01-03 20:43:03.288 Max[3042:10b] Track number 11
2008-01-03 20:43:03.289 Max[3042:10b] First sector : 169533
2008-01-03 20:43:03.289 Max[3042:10b] Track number 12
2008-01-03 20:43:03.289 Max[3042:10b] First sector : 173508
2008-01-03 20:43:03.293 Max[3042:10b] Track number 13
2008-01-03 20:43:03.294 Max[3042:10b] First sector : 176358
2008-01-03 20:43:03.295 Max[3042:10b] Track number 14
2008-01-03 20:43:03.295 Max[3042:10b] First sector : 182943
2008-01-03 20:43:03.295 Max[3042:10b] Track number 15
2008-01-03 20:43:03.296 Max[3042:10b] First sector : 190158
2008-01-03 20:43:03.296 Max[3042:10b] Track number 16
2008-01-03 20:43:03.298 Max[3042:10b] First sector : 197533
2008-01-03 20:43:03.299 Max[3042:10b] Track number 17
2008-01-03 20:43:03.299 Max[3042:10b] First sector : 207158
2008-01-03 20:43:03.300 Max[3042:10b] Track number 18
2008-01-03 20:43:03.300 Max[3042:10b] First sector : 216445
2008-01-03 20:43:03.301 Max[3042:10b] Track number 19
2008-01-03 20:43:03.302 Max[3042:10b] First sector : 222483
2008-01-03 20:43:03.303 Max[3042:10b] Track number 20
2008-01-03 20:43:03.303 Max[3042:10b] First sector : 232433
2008-01-03 20:43:03.303 Max[3042:10b] Track number 21
2008-01-03 20:43:03.304 Max[3042:10b] First sector : 243408
2008-01-03 20:43:03.304 Max[3042:10b] Track number 22
2008-01-03 20:43:03.305 Max[3042:10b] First sector : 248083
2008-01-03 20:43:03.305 Max[3042:10b] Track number 23
2008-01-03 20:43:03.306 Max[3042:10b] First sector : 256683
2008-01-03 20:43:03.306 Max[3042:10b] Track number 24
2008-01-03 20:43:03.307 Max[3042:10b] First sector : 271058
2008-01-03 20:43:03.307 Max[3042:10b] Track number 25
2008-01-03 20:43:03.307 Max[3042:10b] First sector : 282033
2008-01-03 20:43:03.308 Max[3042:10b] Track number 26
2008-01-03 20:43:03.308 Max[3042:10b] First sector : 297033
So indeed it appears that his external Plextor drive is returning a
CDTOC with BCD-encoded numbers, because
Internal last track: 26 (which is correct)
External last track: 38, 0010 0110 in binary, when interpreted as BCD
equals 26 in decimal
Internal LBA for track 1: 33 (correct)
External LBA for track 1: 51, 0011 0011 in binary, when interpreted as
BCD equals 33
There is a comment in IOCDTypes.h which says:
/*
* Table Of Contents
*
* All CDTOC fields passed across I/O Kit APIs are guaranteed to be
* binary-encoded numbers (no BCD-encoded numbers are ever passed).
*/
so I assumed I didn't have to convert from BCD. Have I made an error
in my code or should this not be happening?
Thanks,
Stephen
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden