hal/hald/linux block_class_device.c,1.86.2.3,1.86.2.4
David Zeuthen
david at freedesktop.org
Wed Dec 8 19:15:24 PST 2004
Update of /cvs/hal/hal/hald/linux
In directory gabe:/tmp/cvs-serv21705/hald/linux
Modified Files:
Tag: hal-0_4-stable-branch
block_class_device.c
Log Message:
2004-12-08 David Zeuthen <davidz at redhat.com>
* hald/linux/block_class_device.c (detect_media): Patch from
Martin Pitt <martin at piware.de>.
Media change detection for CD-ROMs does not work on some broken
CD-ROM devices. There are some devices where the
CDROM_DRIVE_STATUS ioctl returns CDS_DISK_OK even when the tray is
open. This has the consequence that the event of inserting a CD is
not recognized by hal.
If the CD-ROM reports CDS_DISK_OK, then CDROM_MEDIA_CHANGED should
be checked twice. If it returns two different values, then there
really was a media change and got_media can be set to true. OTOH,
if both CDROM_MEDIA_CHANGED events return the same value, then the
tray is still open and we must not assume that there is already a
CD in the drive.
Second, for deciding the value of storage.cdrom.support_media_changed
hald should not use the CDROM_MEDIA_CHANGED ioctl() (which returns
the current state), but the CDC_MEDIA_CHANGED capability.
Index: block_class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/block_class_device.c,v
retrieving revision 1.86.2.3
retrieving revision 1.86.2.4
diff -u -d -r1.86.2.3 -r1.86.2.4
--- block_class_device.c 9 Dec 2004 02:57:07 -0000 1.86.2.3
+++ block_class_device.c 9 Dec 2004 03:15:22 -0000 1.86.2.4
@@ -354,7 +354,7 @@
}
/* while we're at it, check if we support media changed */
- if (ioctl (fd, CDROM_MEDIA_CHANGED) >= 0) {
+ if (capabilities & CDC_MEDIA_CHANGED) {
hal_device_property_set_bool (d, "storage.cdrom.support_media_changed", TRUE);
} else {
hal_device_property_set_bool (d, "storage.cdrom.support_media_changed", FALSE);
@@ -879,7 +879,17 @@
break;
case CDS_DISC_OK:
- got_media = TRUE;
+ /* some CD-ROMs report CDS_DISK_OK even with an open
+ * tray; if media check has the same value two times in
+ * a row then this seems to be the case and we must not
+ * report that there is a media in it. */
+ if (hal_device_property_get_bool (d, "storage.cdrom.support_media_changed") &&
+ ioctl (fd, CDROM_MEDIA_CHANGED, CDSL_CURRENT) &&
+ ioctl (fd, CDROM_MEDIA_CHANGED, CDSL_CURRENT)) {
+ /*HAL_INFO (("CD-ROM drive %s: media checking is broken, assuming no CD is inside.", device_file));*/
+ } else {
+ got_media = TRUE;
+ }
break;
case -1:
More information about the hal-commit
mailing list