[systemd-commits] 2 commits - rules/60-cdrom_id.rules src/core

Lennart Poettering lennart at kemper.freedesktop.org
Wed Jan 28 08:04:36 PST 2015


 rules/60-cdrom_id.rules |    5 +++++
 src/core/mount.c        |    2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

New commits:
commit 3b48ce4ec4639437ca3db344962ed37b0c83ea9a
Author: Martin Pitt <martin.pitt at ubuntu.com>
Date:   Wed Jan 28 13:57:47 2015 +0100

    rules: clean up stale CD drive mounts after ejection
    
    Ejecting a CD with the hardware drive button only causes a change uevent, but
    the device node stays around (just without a medium). Pick up these uevents and
    mark the device as SYSTEMD_READY=0 on ejection, so that systemd stops the
    device unit and consequently all mount units on it.
    
    On media insertion, mark the device as SYSTEMD_READY=1 again.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=72206
    https://bugzilla.opensuse.org/show_bug.cgi?id=909418
    https://bugs.archlinux.org/task/42071
    https://bugs.launchpad.net/bugs/1168742

diff --git a/rules/60-cdrom_id.rules b/rules/60-cdrom_id.rules
index 6eaf76a..5c3b52e 100644
--- a/rules/60-cdrom_id.rules
+++ b/rules/60-cdrom_id.rules
@@ -15,6 +15,11 @@ ENV{DISK_EJECT_REQUEST}=="?*", RUN+="cdrom_id --eject-media $devnode", GOTO="cdr
 # enable the receiving of media eject button events
 IMPORT{program}="cdrom_id --lock-media $devnode"
 
+# ejecting a CD does not remove the device node, so mark the systemd device
+# unit as inactive while there is no medium; this automatically cleans up of
+# stale mounts after ejecting
+ENV{DISK_MEDIA_CHANGE}=="?*", ENV{ID_CDROM_MEDIA}!="?*", ENV{SYSTEMD_READY}="0"
+
 KERNEL=="sr0", SYMLINK+="cdrom", OPTIONS+="link_priority=-100"
 
 LABEL="cdrom_end"

commit 06e97888883e2cc12eb6514e80c7f0014295f59b
Author: Martin Pitt <martin.pitt at ubuntu.com>
Date:   Wed Jan 28 13:53:25 2015 +0100

    core/mount: add dependencies to dynamically mounted mounts too
    
    Add unit dependencies for dynamic (i. e. not from fstab) mounts. With that,
    mount units properly bind to their underlying device, and thus get
    automatically stopped/unmounted when the underlying device goes away.
    
    This cleans up stale mounts from unplugged devices.
    
    Thanks to Lennart Poettering for pointing out the fix!

diff --git a/src/core/mount.c b/src/core/mount.c
index 6bd6914..a0b5fda 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -300,7 +300,7 @@ static int mount_add_device_links(Mount *m) {
 
         assert(m);
 
-        p = get_mount_parameters_fragment(m);
+        p = get_mount_parameters(m);
         if (!p)
                 return 0;
 



More information about the systemd-commits mailing list