60-cdrom_id.rules 1.0 KB

1234567891011121314151617181920212223242526272829
  1. # do not edit this file, it will be overwritten on update
  2. ACTION=="remove", GOTO="cdrom_end"
  3. SUBSYSTEM!="block", GOTO="cdrom_end"
  4. KERNEL!="sr[0-9]*|vdisk*|xvd*", GOTO="cdrom_end"
  5. ENV{DEVTYPE}!="disk", GOTO="cdrom_end"
  6. # unconditionally tag device as CDROM
  7. KERNEL=="sr[0-9]*", ENV{ID_CDROM}="1"
  8. # stop automatically any mount units bound to the device if the media eject
  9. # button is pressed.
  10. ENV{ID_CDROM}=="1", ENV{SYSTEMD_MOUNT_DEVICE_BOUND}="1"
  11. # media eject button pressed
  12. ENV{DISK_EJECT_REQUEST}=="?*", RUN+="cdrom_id --eject-media $devnode", GOTO="cdrom_end"
  13. # import device and media properties and lock tray to
  14. # enable the receiving of media eject button events
  15. IMPORT{program}="cdrom_id --lock-media $devnode"
  16. # ejecting a CD does not remove the device node, so mark the systemd device
  17. # unit as inactive while there is no medium; this automatically cleans up of
  18. # stale mounts after ejecting
  19. ENV{DISK_MEDIA_CHANGE}=="?*", ENV{ID_CDROM_MEDIA}!="?*", ENV{SYSTEMD_READY}="0"
  20. KERNEL=="sr0", SYMLINK+="cdrom", OPTIONS+="link_priority=-100"
  21. LABEL="cdrom_end"