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