On Thu, 15 Jan 2015 12:00:15 +0100 "Oliver Neukum" <oneu...@suse.de> wrote:
> On Thu, 2015-01-15 at 11:38 +0100, Martin Pitt wrote: > > Oliver Neukum [2015-01-15 11:31 +0100]: > > > No, the events are generated. And it is processed. > > > There is just no unmounting. > > > > That sounds like a bug/missing feature in cdrom_id --eject-media > > then. You could try and replace it with /usr/bin/eject, which does > > the unmounting of all partitions first, fail on busy, and does the > > eject at last? > > That does work. > > > > But what is the motivation of in effect disabling door locking? > > > > We don't -- we specifically leave it locked so that we get the > > "eject button pressed" events. (See my other response for some > > details). > > Well, yes, but why is policy that should be left to the GUI placed > into udev? > > Regards > Oliver > > What about this little bundle of joy, the patch I mean, of course. Please check attachment :) Might need work, but the basic idea seems to work, at least in my tests. -- Robert Milasan L3 Support Engineer SUSE Linux (http://www.suse.com) email: rmila...@suse.com GPG fingerprint: B6FE F4A8 0FA3 3040 3402 6FE7 2F64 167C 1909 6D1A
>From 59b5e141bb5a5ad99d6492c3764c220334a8833f Mon Sep 17 00:00:00 2001 From: Robert Milasan <rmila...@suse.com> Date: Thu, 15 Jan 2015 12:21:10 +0100 Subject: [PATCH] cdrom_id: unmount media if mount on --eject-media Signed-off-by: Robert Milasan <rmila...@suse.com> --- src/udev/cdrom_id/cdrom_id.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/udev/cdrom_id/cdrom_id.c b/src/udev/cdrom_id/cdrom_id.c index 6052f6a..50e6a42 100644 --- a/src/udev/cdrom_id/cdrom_id.c +++ b/src/udev/cdrom_id/cdrom_id.c @@ -32,6 +32,7 @@ #include <sys/stat.h> #include <sys/time.h> #include <sys/ioctl.h> +#include <sys/mount.h> #include <linux/cdrom.h> #include "libudev.h" @@ -200,6 +201,24 @@ static int media_lock(struct udev *udev, int fd, bool lock) return err; } +static int media_umount(const char *node) +{ + int err; + + if (!node) + return -1; + + if (is_mounted(node)) { + err = umount(node); + if (err < 0) { + log_debug("umount failed\n"); + return err; + } + } + + return 0; +} + static int media_eject(struct udev *udev, int fd) { struct scsi_cmd sc; @@ -971,6 +990,8 @@ work: if (eject) { log_debug("PREVENT_ALLOW_MEDIUM_REMOVAL (unlock)"); media_lock(udev, fd, false); + log_debug("UNMOUNT_MEDIA (umount)\n"); + media_umount(node); log_debug("START_STOP_UNIT (eject)"); media_eject(udev, fd); } -- 1.8.4.5
_______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel