Blame 0012-init-set-cdrom-polling-in-kernel.patch

Harald Hoyer 59f9af
From 9edf1b206b69a9f6d6d038d333d8b855145ed4d6 Mon Sep 17 00:00:00 2001
Harald Hoyer 59f9af
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer 59f9af
Date: Fri, 18 Feb 2011 13:27:31 +0100
Harald Hoyer 59f9af
Subject: [PATCH] init: set cdrom polling in kernel
Harald Hoyer 59f9af
Harald Hoyer 59f9af
and reset to -1 after we are done.
Harald Hoyer 59f9af
---
Harald Hoyer 59f9af
 modules.d/99base/init |   22 +++++++++++++++++-----
Harald Hoyer 59f9af
 1 files changed, 17 insertions(+), 5 deletions(-)
Harald Hoyer 59f9af
Harald Hoyer 59f9af
diff --git a/modules.d/99base/init b/modules.d/99base/init
Harald Hoyer 59f9af
index 0a05e91..b49c87a 100755
Harald Hoyer 59f9af
--- a/modules.d/99base/init
Harald Hoyer 59f9af
+++ b/modules.d/99base/init
Harald Hoyer 59f9af
@@ -203,15 +203,19 @@ while :; do
Harald Hoyer 59f9af
     # dirty hack for some cdrom drives,
Harald Hoyer 59f9af
     # which report no medium for quiet
Harald Hoyer 59f9af
     # some time.
Harald Hoyer 59f9af
-    if [ ! -e /sys/module/block/parameters/events_dfl_poll_msecs ]; then
Harald Hoyer 59f9af
-        for cdrom in /sys/block/sr*; do
Harald Hoyer 59f9af
-            [ -e "$cdrom" ] || continue       
Harald Hoyer 59f9af
+    for cdrom in /sys/block/sr*; do
Harald Hoyer 59f9af
+        [ -e "$cdrom" ] || continue 
Harald Hoyer 59f9af
+        if [ -e "$cdrom"/events_poll_msecs ]; then
Harald Hoyer 59f9af
+            msecs=$(while read a; do echo $a;done < "$cdrom"/events_poll_msecs)
Harald Hoyer 59f9af
+            [ "$msecs" = "-1" ] && \
Harald Hoyer 59f9af
+                echo 1000 > "$cdrom"/events_poll_msecs
Harald Hoyer 59f9af
+        else
Harald Hoyer 59f9af
             # skip, if cdrom medium was already found
Harald Hoyer 59f9af
             strstr "$(udevadm info --query=env --path=${cdrom##/sys})" \
Harald Hoyer 59f9af
                 ID_CDROM_MEDIA && continue
Harald Hoyer 59f9af
             echo change > "$cdrom/uevent"        
Harald Hoyer 59f9af
-        done
Harald Hoyer 59f9af
-    fi
Harald Hoyer 59f9af
+        fi
Harald Hoyer 59f9af
+    done
Harald Hoyer 59f9af
     
Harald Hoyer 59f9af
     i=$(($i+1))
Harald Hoyer 59f9af
     [ $i -gt $RDRETRY ] \
Harald Hoyer 59f9af
@@ -220,6 +224,14 @@ done
Harald Hoyer 59f9af
 unset job
Harald Hoyer 59f9af
 unset queuetriggered
Harald Hoyer 59f9af
 
Harald Hoyer 59f9af
+# reset cdrom polling
Harald Hoyer 59f9af
+for cdrom in /sys/block/sr*; do
Harald Hoyer 59f9af
+    [ -e "$cdrom" ] || continue 
Harald Hoyer 59f9af
+    if [ -e "$cdrom"/events_poll_msecs ]; then
Harald Hoyer 59f9af
+        echo -1 > "$cdrom"/events_poll_msecs
Harald Hoyer 59f9af
+    fi
Harald Hoyer 59f9af
+done
Harald Hoyer 59f9af
+
Harald Hoyer 59f9af
 # pre-mount happens before we try to mount the root filesystem,
Harald Hoyer 59f9af
 # and happens once.
Harald Hoyer 59f9af
 getarg 'rd.break=pre-mount' 'rdbreak=pre-mount' && emergency_shell -n pre-mount "Break pre-mount"