]> err.no Git - systemd/commitdiff
Avoid spinning up CD on pressing eject button
authorMartin Pitt <martin.pitt@ubuntu.com>
Mon, 4 Apr 2011 09:47:54 +0000 (11:47 +0200)
committerMartin Pitt <martin.pitt@ubuntu.com>
Mon, 4 Apr 2011 09:47:54 +0000 (11:47 +0200)
When the CD tray door is locked and the hardware eject button is pressed, newer
kernels (2.6.38+) will send out a change event with a DISK_EJECT_REQUEST==1
property. Do not run cdrom_id and blkid in this case, as the media state and
contents does not change, and this only needlessly spins up the drive again
right before ejection.

extras/cdrom_id/60-cdrom_id.rules
rules/rules.d/60-persistent-storage.rules

index b3109f1d016785824229684763c9beed89dfc144..aedf6f0558994b2b9985a5a8caa89d80bf16d666 100644 (file)
@@ -5,6 +5,9 @@ SUBSYSTEM!="block", GOTO="cdrom_end"
 KERNEL!="sr[0-9]*|xvd*", GOTO="cdrom_end"
 ENV{DEVTYPE}!="disk", GOTO="cdrom_end"
 
+# this is only a button press event
+ENV{DISK_EJECT_REQUEST}=="?*", GOTO="cdrom_end"
+
 KERNEL=="sr[0-9]*", ENV{ID_CDROM}="1"
 IMPORT{program}="cdrom_id --export $tempnode"
 
index 12fabeff0ead7f61f5d6883cf182f9f9d419c9ff..05a405f64ba1efe81ab35c6ce65afe8c4e476eac 100644 (file)
@@ -62,9 +62,9 @@ ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PA
 ENV{DEVTYPE}=="disk", KERNEL!="sd*|sr*", ATTR{removable}=="1", GOTO="persistent_storage_end"
 
 # probe filesystem metadata of optical drives which have a media inserted
-KERNEL=="sr*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DATA}=="?*", ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="?*", IMPORT{program}="/sbin/blkid -o udev -p -u noraid -O $env{ID_CDROM_MEDIA_SESSION_LAST_OFFSET} $tempnode"
+KERNEL=="sr*", ENV{DISK_EJECT_REQUEST}!="?*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DATA}=="?*", ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="?*", IMPORT{program}="/sbin/blkid -o udev -p -u noraid -O $env{ID_CDROM_MEDIA_SESSION_LAST_OFFSET} $tempnode"
 # single-session CDs do not have ID_CDROM_MEDIA_SESSION_LAST_OFFSET
-KERNEL=="sr*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DATA}=="?*", ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="", IMPORT{program}="/sbin/blkid -o udev -p -u noraid $tempnode"
+KERNEL=="sr*", ENV{DISK_EJECT_REQUEST}!="?*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DATA}=="?*", ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="", IMPORT{program}="/sbin/blkid -o udev -p -u noraid $tempnode"
 
 # probe filesystem metadata of disks
 KERNEL!="sr*", IMPORT{program}="/sbin/blkid -o udev -p $tempnode"