hal/hald/linux block_class_device.c,1.41,1.42
David Zeuthen
david at freedesktop.org
Tue Jul 20 13:39:43 PDT 2004
Update of /cvs/hal/hal/hald/linux
In directory pdx:/tmp/cvs-serv12836/hald/linux
Modified Files:
block_class_device.c
Log Message:
2004-07-20 David Zeuthen <david at fubar.dk>
* hald/linux/block_class_device.c:
(detect_media): use O_EXCL for optical drive media detection, much
safer since O_EXCL is actually in mainline. Removes possible burning
problems (that is, if only cdrecord open(2)'s the device using O_EXCL;
bug filed against fedora-devel, hopefully it will bubble upstream)
Index: block_class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/block_class_device.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- block_class_device.c 20 Jul 2004 17:27:16 -0000 1.41
+++ block_class_device.c 20 Jul 2004 20:39:41 -0000 1.42
@@ -615,11 +615,24 @@
unsigned char buffer[8];
int ret;
- fd = open (device_file, O_RDONLY | O_NONBLOCK);
+ /********** media detection for optical drives **********/
+
+ /* After talking to Hadess, magicdev maintainer, the
+ * right thing is to use O_EXCL; it's in 2.6 mainline..
+ */
+ fd = open (device_file, O_RDONLY | O_NONBLOCK | O_EXCL);
if (fd == -1) {
+
+ /* this means the disc is mounted or some other app,
+ * like a cd burner, has opened O_EXCL */
+ if (errno == EBUSY) {
+ HAL_INFO (("*** EBUSY for %s", device_file));
+ return FALSE;
+ }
+
/* open failed */
- /*HAL_WARNING (("open(\"%s\", O_RDONLY|O_NONBLOCK|O_EXCL) failed, " "errno=%d", device_file, errno));*/
+ HAL_INFO (("open(\"%s\", O_RDONLY|O_NONBLOCK|O_EXCL) failed, " "errno=%d", device_file, errno));
return FALSE;
}
More information about the hal-commit
mailing list