ntdll: Implemented reading of the CDROM TOC on Mac OS.

This commit is contained in:
Alexandre Julliard 2007-06-15 12:42:06 +02:00
parent 8143d42c4c
commit e6ce0da2f9
1 changed files with 33 additions and 7 deletions

View File

@ -76,13 +76,12 @@
#endif
#ifdef HAVE_IOKIT_IOKITLIB_H
# ifndef SENSEBUFLEN
# include <sys/disk.h>
# include <IOKit/IOKitLib.h>
# include <IOKit/storage/IOMedia.h>
# include <IOKit/scsi/SCSICmds_REQUEST_SENSE_Defs.h>
# define SENSEBUFLEN kSenseDefaultSize
# endif
# include <sys/disk.h>
# include <IOKit/IOKitLib.h>
# include <IOKit/storage/IOMedia.h>
# include <IOKit/storage/IOCDMediaBSDClient.h>
# include <IOKit/scsi/SCSICmds_REQUEST_SENSE_Defs.h>
# define SENSEBUFLEN kSenseDefaultSize
#endif
#define NONAMELESSUNION
@ -491,6 +490,33 @@ static NTSTATUS CDROM_SyncCache(int dev, int fd)
}
cdrom_cache[dev].toc_good = 1;
return STATUS_SUCCESS;
#elif defined(__APPLE__)
int i;
dk_cd_read_toc_t hdr;
CDROM_TOC *toc = &cdrom_cache[dev].toc;
cdrom_cache[dev].toc_good = 0;
memset( &hdr, 0, sizeof(hdr) );
hdr.buffer = toc;
hdr.bufferLength = sizeof(*toc);
if (ioctl(fd, DKIOCCDREADTOC, &hdr) == -1)
{
WARN("(%d) -- Error occurred (%s)!\n", dev, strerror(errno));
return FILE_GetNtStatus();
}
for (i = toc->FirstTrack; i <= toc->LastTrack + 1; i++)
{
/* convert address format */
TRACK_DATA *data = &toc->TrackData[i - toc->FirstTrack];
DWORD frame = (((DWORD)data->Address[0] << 24) | ((DWORD)data->Address[1] << 16) |
((DWORD)data->Address[2] << 8) | data->Address[3]);
MSF_OF_FRAME( data->Address[1], frame );
data->Address[0] = 0;
}
cdrom_cache[dev].toc_good = 1;
return STATUS_SUCCESS;
#else
return STATUS_NOT_SUPPORTED;
#endif