[systemd-devel] cdrom_id and 60-cdrom_id.rules behavior

Martin Pitt martin.pitt at ubuntu.com
Thu Jan 15 00:03:39 PST 2015


Hello all,

Robert Milasan [2015-01-12  9:39 +0100]:
> 1. add a CD/DVD into the driver
> 2. mount the driver: mount /dev/sr0 /mnt/my_cd (ensure you don't
> use the Gnome/KDE auto-mounting or reproduce this in a server setup)
> 3. eject the media (using the hardware button) and add a new one media
> (different disk)
> 4. ls /mnt/my_cd (it will be an empty output or the previous media)
> 
> Is this expected?

no, it's not. It's been several years since I've actually had a CD
drive and looked at this stuff, but this is how it is *supposed* to
work today:

 - Mounting (manually or through udisks) keeps the kernel default
   policy of locking the door, so that users can't yank out a mounted
   medium.

 - *When* the tray is locked (the default), pressing the eject button is
   supposed to cause a change event with DISK_EJECT_REQUEST.

 - udev rules (60-cdrom_id.rules) picks that up and calls "eject
   /dev/srX" on the device; the eject program takes care to unmount
   everything before physical ejection.

Note that the kernel will *not* generate DISK_EJECT_REQUEST uevents if
the tray is not locked. Your case sounds exactly like that?

I suggest running "udevadm monitor -e --udev", then press the eject
button while a CD is mounted, and check whether you get such an
uevent. Then clean up (umount, etc.), re-mount, and this time manually
lock with "sudo hdparm -L 1 /dev/sr0", and check how it works then?

Then you could compare hdparm -L vs. /lib/udev/cdrom_id --lock-media;
maybe the former works but not the latter? Or do both report an error
that the drive might not support locking? Until a few years ago I've
never seen a drive which didn't, but who knows what modern drives do..

> Also, I remember a while back (long time ago) that once you added a
> media into the driver and it was properly mounted, you couldn't
> eject the media until you unmounted the media.

Right, because we didn't have the kernel (or userspace in udisks, as
it was before that) polling for eject button presses. But users (IMHO
rightfully) complained about the non-working button, and with the
current system it's indeed so much more natural (if it works :) ).

Martin

-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150115/dd946a9b/attachment-0001.sig>


More information about the systemd-devel mailing list