Search
lxdream.org :: lxdream :: r353:b8569afb53fc
lxdream 0.9.1
released Jun 29
Download Now
changeset353:b8569afb53fc
parent352:f0df7a6d4703
child354:8bf6587e1f9b
authornkeynes
dateSun Feb 11 10:11:05 2007 +0000 (12 years ago)
Bug 19: Read real drive status, detect media change to reload toc
src/gdrom/linux.c
1.1 --- a/src/gdrom/linux.c Sun Feb 11 10:09:32 2007 +0000
1.2 +++ b/src/gdrom/linux.c Sun Feb 11 10:11:05 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: linux.c,v 1.3 2007-01-31 10:58:42 nkeynes Exp $
1.6 + * $Id: linux.c,v 1.4 2007-02-11 10:11:05 nkeynes Exp $
1.7 *
1.8 * Linux cd-rom device driver.
1.9 *
1.10 @@ -53,7 +53,7 @@
1.11 int mode, char *buf, uint32_t *length );
1.12 static gdrom_error_t linux_send_command( int fd, char *cmd, char *buffer, size_t *buflen,
1.13 int direction );
1.14 -
1.15 +static int linux_drive_status( gdrom_disc_t disc );
1.16
1.17 struct gdrom_image_class linux_device_class = { "Linux", NULL,
1.18 linux_image_is_valid, linux_open_device };
1.19 @@ -101,10 +101,25 @@
1.20 return NULL;
1.21 }
1.22 disc->read_sector = linux_read_sector;
1.23 + disc->drive_status = linux_drive_status;
1.24 ((gdrom_image_t)disc)->disc_type = IDE_DISC_CDROM;
1.25 return disc;
1.26 }
1.27
1.28 +static int linux_drive_status( gdrom_disc_t disc )
1.29 +{
1.30 + int fd = fileno(((gdrom_image_t)disc)->file);
1.31 + int status = ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
1.32 + if( status == CDS_DISC_OK ) {
1.33 + status = ioctl(fd, CDROM_MEDIA_CHANGED, CDSL_CURRENT);
1.34 + if( status != 0 ) {
1.35 + linux_read_disc_toc(disc);
1.36 + }
1.37 + return ((gdrom_image_t)disc)->disc_type | IDE_DISC_READY;
1.38 + } else {
1.39 + return IDE_DISC_NONE;
1.40 + }
1.41 +}
1.42 /**
1.43 * Read the full table of contents into the disc from the device.
1.44 */
.