Blame 0032-98pollcdrom-factored-out-the-ugly-cdrom-polling-in-t.patch

Harald Hoyer ee76a0
From 74db72dd0b22973cfd9f3cbe832b09096c4e7ab9 Mon Sep 17 00:00:00 2001
Harald Hoyer ee76a0
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer ee76a0
Date: Fri, 2 Mar 2012 14:53:22 +0100
Harald Hoyer ee76a0
Subject: [PATCH] 98pollcdrom: factored out the ugly cdrom polling in the main
Harald Hoyer ee76a0
 loop
Harald Hoyer ee76a0
Harald Hoyer ee76a0
---
Harald Hoyer ee76a0
 modules.d/98pollcdrom/module-setup.sh |   16 ++++++++++++++++
Harald Hoyer ee76a0
 modules.d/98pollcdrom/pollcdrom.sh    |   23 +++++++++++++++++++++++
Harald Hoyer ee76a0
 modules.d/99base/init.sh              |   14 --------------
Harald Hoyer ee76a0
 3 files changed, 39 insertions(+), 14 deletions(-)
Harald Hoyer ee76a0
 create mode 100755 modules.d/98pollcdrom/module-setup.sh
Harald Hoyer ee76a0
 create mode 100644 modules.d/98pollcdrom/pollcdrom.sh
Harald Hoyer ee76a0
Harald Hoyer ee76a0
diff --git a/modules.d/98pollcdrom/module-setup.sh b/modules.d/98pollcdrom/module-setup.sh
Harald Hoyer ee76a0
new file mode 100755
Harald Hoyer ee76a0
index 0000000..e80ae16
Harald Hoyer ee76a0
--- /dev/null
Harald Hoyer ee76a0
+++ b/modules.d/98pollcdrom/module-setup.sh
Harald Hoyer ee76a0
@@ -0,0 +1,16 @@
Harald Hoyer ee76a0
+#!/bin/bash
Harald Hoyer ee76a0
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
Harald Hoyer ee76a0
+# ex: ts=8 sw=4 sts=4 et filetype=sh
Harald Hoyer ee76a0
+
Harald Hoyer ee76a0
+check() {
Harald Hoyer ee76a0
+    return 255
Harald Hoyer ee76a0
+}
Harald Hoyer ee76a0
+
Harald Hoyer ee76a0
+depends() {
Harald Hoyer ee76a0
+    return 0
Harald Hoyer ee76a0
+}
Harald Hoyer ee76a0
+
Harald Hoyer ee76a0
+install() {
Harald Hoyer ee76a0
+    inst_hook initqueue/settled 99 "$moddir/pollcdrom.sh"
Harald Hoyer ee76a0
+}
Harald Hoyer ee76a0
+
Harald Hoyer ee76a0
diff --git a/modules.d/98pollcdrom/pollcdrom.sh b/modules.d/98pollcdrom/pollcdrom.sh
Harald Hoyer ee76a0
new file mode 100644
Harald Hoyer ee76a0
index 0000000..4abc9d7
Harald Hoyer ee76a0
--- /dev/null
Harald Hoyer ee76a0
+++ b/modules.d/98pollcdrom/pollcdrom.sh
Harald Hoyer ee76a0
@@ -0,0 +1,23 @@
Harald Hoyer ee76a0
+#!/bin/sh
Harald Hoyer ee76a0
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
Harald Hoyer ee76a0
+# ex: ts=8 sw=4 sts=4 et filetype=sh
Harald Hoyer ee76a0
+#
Harald Hoyer ee76a0
+# Licensed under the GPLv2
Harald Hoyer ee76a0
+#
Harald Hoyer ee76a0
+# Copyright 2008-2012, Red Hat, Inc.
Harald Hoyer ee76a0
+# Harald Hoyer <harald@redhat.com>
Harald Hoyer ee76a0
+
Harald Hoyer ee76a0
+if [ ! -e /sys/module/block/parameters/events_dfl_poll_msecs ]; then
Harald Hoyer ee76a0
+    # if the kernel does not support autopolling
Harald Hoyer ee76a0
+    # then we have to do a
Harald Hoyer ee76a0
+    # dirty hack for some cdrom drives,
Harald Hoyer ee76a0
+    # which report no medium for quiet
Harald Hoyer ee76a0
+    # some time.
Harald Hoyer ee76a0
+    for cdrom in /sys/block/sr*; do
Harald Hoyer ee76a0
+        [ -e "$cdrom" ] || continue
Harald Hoyer ee76a0
+        # skip, if cdrom medium was already found
Harald Hoyer ee76a0
+        strstr "$(udevadm info --query=env --path=${cdrom##/sys})" \
Harald Hoyer ee76a0
+            ID_CDROM_MEDIA && continue
Harald Hoyer ee76a0
+        echo change > "$cdrom/uevent"
Harald Hoyer ee76a0
+    done
Harald Hoyer ee76a0
+fi
Harald Hoyer ee76a0
diff --git a/modules.d/99base/init.sh b/modules.d/99base/init.sh
Harald Hoyer ee76a0
index 96fd5f2..f6e4027 100755
Harald Hoyer ee76a0
--- a/modules.d/99base/init.sh
Harald Hoyer ee76a0
+++ b/modules.d/99base/init.sh
Harald Hoyer ee76a0
@@ -199,20 +199,6 @@ while :; do
Harald Hoyer ee76a0
     # no more udev jobs and queues empty.
Harald Hoyer ee76a0
     sleep 0.5
Harald Hoyer ee76a0
 
Harald Hoyer ee76a0
-    if [ ! -e /sys/module/block/parameters/events_dfl_poll_msecs ]; then
Harald Hoyer ee76a0
-        # if the kernel does not support autopolling
Harald Hoyer ee76a0
-        # then we have to do a
Harald Hoyer ee76a0
-        # dirty hack for some cdrom drives,
Harald Hoyer ee76a0
-        # which report no medium for quiet
Harald Hoyer ee76a0
-        # some time.
Harald Hoyer ee76a0
-        for cdrom in /sys/block/sr*; do
Harald Hoyer ee76a0
-            [ -e "$cdrom" ] || continue
Harald Hoyer ee76a0
-            # skip, if cdrom medium was already found
Harald Hoyer ee76a0
-            strstr "$(udevadm info --query=env --path=${cdrom##/sys})" \
Harald Hoyer ee76a0
-                ID_CDROM_MEDIA && continue
Harald Hoyer ee76a0
-            echo change > "$cdrom/uevent"
Harald Hoyer ee76a0
-        done
Harald Hoyer ee76a0
-    fi
Harald Hoyer ee76a0
 
Harald Hoyer ee76a0
     if [ $main_loop -gt $(($RDRETRY/2)) ]; then
Harald Hoyer ee76a0
         for job in $hookdir/initqueue/timeout/*.sh; do