From 1064be64a7398b9b5dec4ece39b738ff15073d56 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Tue, 6 Oct 2009 10:51:09 +0200 Subject: [PATCH] =?utf8?q?Bug=2024052=20=E2=80=93=20CDROM=20eject=20button?= =?utf8?q?=20is=20locked=20while=20CDROM=20is=20mounted?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Unlike in the hal world, we do not have a daemon polling CD drives for eject button presses. In order to make hardware tray eject buttons work, unlock the tray after mounting a CD. This is pretty much equivalent to yanking out USB sticks, which we already handle reasonably (detecting disappeared device, force-unmounting). https://bugs.freedesktop.org/show_bug.cgi?id=24052 Signed-off-by: David Zeuthen --- src/devkit-disks-device.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/devkit-disks-device.c b/src/devkit-disks-device.c index 60153d9..6460afd 100644 --- a/src/devkit-disks-device.c +++ b/src/devkit-disks-device.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -4395,6 +4396,23 @@ prepend_default_mount_options (const FSMountOptions *fsmo, uid_t caller_uid, cha } static void +unlock_cd_tray (DevkitDisksDevice *device) +{ + /* Unlock CD tray to keep the hardware eject button working */ + if (g_udev_device_has_property (device->priv->d, "ID_CDROM")) { + g_print ("**** Unlocking CD-ROM door for %s\n", device->priv->device_file); + int fd = open(device->priv->device_file, O_RDONLY); + if (fd > 0) { + if (ioctl (fd, CDROM_LOCKDOOR, 0) != 0) + g_warning ("Could not unlock CD-ROM door: %s", strerror (errno)); + close (fd); + } else { + g_warning ("Could not open CD-ROM device: %s", strerror (errno)); + } + } +} + +static void filesystem_mount_completed_cb (DBusGMethodInvocation *context, DevkitDisksDevice *device, gboolean job_was_cancelled, @@ -4412,6 +4430,7 @@ filesystem_mount_completed_cb (DBusGMethodInvocation *context, update_info (device); drain_pending_changes (device, FALSE); + unlock_cd_tray (device); dbus_g_method_return (context, data->mount_point); } else { -- 2.7.4