chiark / gitweb /
rules: run vol_id on opticals only if media is found
authorKay Sievers <kay.sievers@vrfy.org>
Sat, 2 Aug 2008 08:26:48 +0000 (10:26 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Sat, 2 Aug 2008 08:26:48 +0000 (10:26 +0200)
Opening an optical drive device node without O_NONBLOCK autocloses the
tray, we run vol_id on every media change by kernel emitted "change"
events, which can make it hard to change the media when the tray closes
immediatey again.:) We check for cdrom_id to indicate an existing track,
if no media is found, we will not open the device with vol_id.

Thanks to Christian Krause and DavidZ for debugging and testing.

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

index 5ae0c7fec90a8714d56fb925dad1d2378dd7bd4e..097e8640c465ec82974cdabfe7292ef71ce00548 100644 (file)
@@ -52,6 +52,8 @@ ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PA
 
 # skip unpartitioned removable media devices from drivers which do not send "change" events
 ENV{DEVTYPE}=="disk", KERNEL!="sd*|sr*", ATTR{removable}=="1", GOTO="persistent_storage_end"
 
 # skip unpartitioned removable media devices from drivers which do not send "change" events
 ENV{DEVTYPE}=="disk", KERNEL!="sd*|sr*", ATTR{removable}=="1", GOTO="persistent_storage_end"
+# skip optical drives without media
+ENV{DEVTYPE}=="disk", KERNEL=="sr*", ENV{ID_CDROM_MEDIA_TRACK_COUNT}!="?*", GOTO="persistent_storage_end"
 
 # import filesystem metadata
 IMPORT{program}="vol_id --export $tempnode"
 
 # import filesystem metadata
 IMPORT{program}="vol_id --export $tempnode"