Search
lxdream.org :: lxdream :: r767:53dc977f8f25
lxdream 0.9.1
released Jun 29
Download Now
changeset767:53dc977f8f25
parent766:336858fb0160
child768:b2a54f6864eb
authornkeynes
dateThu Jul 24 02:31:56 2008 +0000 (15 years ago)
Fix to correctly mount empty CD drives
src/drivers/cd_linux.c
1.1 --- a/src/drivers/cd_linux.c Thu Jul 24 02:30:37 2008 +0000
1.2 +++ b/src/drivers/cd_linux.c Thu Jul 24 02:31:56 2008 +0000
1.3 @@ -99,8 +99,9 @@
1.4 return FALSE; /* Not a block device */
1.5 }
1.6
1.7 - if( ioctl(fileno(f), CDROMREADTOCHDR, &tochdr) == -1 ) {
1.8 - /* Quick check that this is really a CD */
1.9 + int caps = ioctl(fileno(f), CDROM_GET_CAPABILITY);
1.10 + if( caps == -1 ) {
1.11 + /* Quick check that this is really a CD device */
1.12 return FALSE;
1.13 }
1.14
1.15 @@ -117,16 +118,21 @@
1.16 return NULL;
1.17 }
1.18
1.19 - gdrom_error_t status = linux_read_disc_toc( (gdrom_image_t)disc );
1.20 - if( status != 0 ) {
1.21 - gdrom_image_destroy_no_close(disc);
1.22 - if( status == 0xFFFF ) {
1.23 - ERROR("Unable to load disc table of contents (%s)", strerror(errno));
1.24 - } else {
1.25 - ERROR("Unable to load disc table of contents (sense %d,%d)",
1.26 + int status = ioctl(fileno(f), CDROM_DRIVE_STATUS, CDSL_CURRENT);
1.27 + if( status == CDS_DISC_OK ) {
1.28 + status = linux_read_disc_toc( (gdrom_image_t)disc );
1.29 + if( status != 0 ) {
1.30 + gdrom_image_destroy_no_close(disc);
1.31 + if( status == 0xFFFF ) {
1.32 + ERROR("Unable to load disc table of contents (%s)", strerror(errno));
1.33 + } else {
1.34 + ERROR("Unable to load disc table of contents (sense %d,%d)",
1.35 status &0xFF, status >> 8 );
1.36 + }
1.37 + return NULL;
1.38 }
1.39 - return NULL;
1.40 + } else {
1.41 + ((gdrom_image_t)disc)->disc_type = IDE_DISC_NONE;
1.42 }
1.43 disc->read_sector = linux_read_sector;
1.44 disc->drive_status = linux_drive_status;
.