Lennart Poettering [2015-01-27 23:33 +0100]: > > That sounds good indeed! I can sit down at qemu tomorrow and simulate > > some CD insertions/removals, and come up with an udev rule for this. > > That would be great. It would really just be a matter of setting > SYSTEMD_READY=0 for block devices where media sense suggests that no > media is in the drive. Probably a one line fix...
Turns out that there's no proper way to simulate that under QEMU -- that has no "eject" button, and the "eject" monitor command blocks as long as the OS is still accessing it (i. e. it's mounted). I borrowed the laptop from a friend which has a CD drive (I can do this until Saturday while I'm in Belgium, FTR), and confirm the stale mounts. I tried adding these rules to 60-cdrom_id.rules after the IMPORT line: # remove a medium/eject CD: disable corresponding .mount units ENV{DISK_MEDIA_CHANGE}=="?*", ENV{ID_CDROM_MEDIA}!="?*", ENV{SYSTEMD_READY}="0" # insert a medium; undo the previous rule ENV{DISK_MEDIA_CHANGE}=="?*", ENV{ID_CDROM_MEDIA}=="?*", ENV{SYSTEMD_READY}="1" These essentially make SYSTEMD_READY the negation of ID_CDROM_MEDIA, but as the latter isn't actually 0 but disappears, and we can't "negate" in udev without resorting to (much slower) shell hacks, we need two rules. In udevadm I see that this has the intended effect -- as soon as I eject the CD, /dev/sr0 gets ENV{SYSTEMD_READY}="0". But there's still something missing, as merely adding this property doesn't yet tell systemd to stop the unit -- media-ubuntu-5ML.mount is still "active" after that. systemd.device(5) also only documents the other transition from 0 to 1, but not from 1 to 0. So do we need to teach systemd to listen to 1 → 0 transitions too for stopping? Martin -- Martin Pitt | http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org) _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel