diff options
| author | Martin Pitt <martin.pitt@ubuntu.com> | 2009-10-06 10:51:09 +0200 |
|---|---|---|
| committer | David Zeuthen <davidz@redhat.com> | 2009-10-09 09:40:09 -0400 |
| commit | 1064be64a7398b9b5dec4ece39b738ff15073d56 (patch) | |
| tree | 3c4627201e76df9b630b391f3a8b1d4ed3681e7c | |
| parent | e672ccb6917772f2e7f0f4294eb2828193eaa89f (diff) | |
Bug 24052 – CDROM eject button is locked while CDROM is mounted
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 <davidz@redhat.com>
| -rw-r--r-- | src/devkit-disks-device.c | 19 |
1 files changed, 19 insertions, 0 deletions
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 <grp.h> #include <linux/fs.h> #include <sys/ioctl.h> +#include <linux/cdrom.h> #include <glib.h> #include <glib/gstdio.h> @@ -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 { |
