Hi,
Also if reading capabilities is still an issue right now, as the ioctl isn't 
implemented, I've still been able to use it to eject/close tray of 
ATAPI-configured CD-Roms (works also better than the CAM mode as they get a 
"Device not ready" when trying to eject an empty CD-Rom drive both with CAM 
and bsd's eject command).
To do so, I needed the attached patch (that I'm going to apply on Gentoo's 
0.75-r1 version), which makes use of the already open file descriptor instead 
of opening a new one (else we have two file descriptor open, so when it 
launch the ioctl to eject the device it results busy because of the other 
fd).
It also cleanup the comment about the result as it seems to be inverted (at 
least, the code gets fuzzy if it returned 1 on success.

HTH,
-- 
Diego "Flameeyes" Pettenò
Gentoo Developer - http://dev.gentoo.org/~flameeyes/
(Gentoo/FreeBSD, Video, Gentoo/AMD64, Sound, PAM)
diff -ur -x '*~' libcdio-0.75/lib/driver/FreeBSD/freebsd_ioctl.c libcdio-0.75-fbsd/lib/driver/FreeBSD/freebsd_ioctl.c
--- libcdio-0.75/lib/driver/FreeBSD/freebsd_ioctl.c	2005-01-27 05:00:48.000000000 +0100
+++ libcdio-0.75-fbsd/lib/driver/FreeBSD/freebsd_ioctl.c	2005-07-23 18:55:58.379631392 +0200
@@ -140,25 +140,20 @@
 }
 
 /*!
-  Eject media. Return 1 if successful, 0 otherwise.
+  Eject media. Return 0 if successful, 1 otherwise.
  */
 int 
 eject_media_freebsd_ioctl (_img_private_t *env) 
 {
   _img_private_t *_obj = env;
-  int ret=2;
-  int fd;
+  int ret=1;
 
-  if ((fd = open(_obj->gen.source_name, O_RDONLY|O_NONBLOCK)) > -1) {
-    ret = 1;
-    if (ioctl(fd, CDIOCALLOW) == -1) {
-      cdio_warn("ioctl(fd, CDIOCALLOW) failed: %s\n", strerror(errno));
-    } else if (ioctl(fd, CDIOCEJECT) == -1) {
-      cdio_warn("ioctl(CDIOCEJECT) failed: %s\n", strerror(errno));
-    } else {
-      ret = 0;
-    }
-    close(fd);
+  if (ioctl(_obj->gen.fd, CDIOCALLOW) == -1) {
+    cdio_warn("ioctl(fd, CDIOCALLOW) failed: %s\n", strerror(errno));
+  } else if (ioctl(_obj->gen.fd, CDIOCEJECT) == -1) {
+    cdio_warn("ioctl(CDIOCEJECT) failed: %s\n", strerror(errno));
+  } else {
+    ret=0;
   }
 
   return ret;

Attachment: pgppDUOJAskDp.pgp
Description: PGP signature

_______________________________________________
Libcdio-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/libcdio-devel

Reply via email to