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;