File 0070-81cio_ignore-rewrite-module.patch of Package dracut.376

From 137090516e1c48ef134209c2ed4f625799691090 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Tue, 17 Jun 2014 16:45:06 +0200
Subject: 81cio_ignore: rewrite module

Rewrite cio_ignore module to rely on the dracut commandline
parameter 'rd.cio_accept', which takes a comma-separated list
of CCW IDs. Each of those IDs are being removed from the
list of devices from cio_ignore.

The default values for rd.cio_accept are taken from
/boot/zipl/active_devices.txt.

References: bnc#882685

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 dracut.cmdline.7.asc                       | 15 +++++++++++
 modules.d/81cio_ignore/module-setup.sh     | 43 ++++++++++++------------------
 modules.d/81cio_ignore/parse-cio_accept.sh | 21 +++++++++++++++
 modules.d/81cio_ignore/parse-zipl.sh       | 32 ----------------------
 4 files changed, 53 insertions(+), 58 deletions(-)
 create mode 100644 modules.d/81cio_ignore/parse-cio_accept.sh
 delete mode 100644 modules.d/81cio_ignore/parse-zipl.sh

diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc
index 985285b..bd8e4ce 100644
--- a/dracut.cmdline.7.asc
+++ b/dracut.cmdline.7.asc
@@ -711,6 +711,21 @@ rd.znet=qeth,0.0.0600,0.0.0601,0.0.0602,layer2=1,portname=foo
 rd.znet=ctc,0.0.0600,0.0.0601,protocol=bar
 --
 
+CIO_IGNORE
+~~~~~~~~~~
+**rd.cio_accept=**__<device-ids>__::
+    Remove the devices listed in <device-ids> from the default
+    cio_ignore kernel command-line settings.
+    <device-ids> is a list of comma-separated CCW device ids.
+    The default for this value is taken from the
+    _/boot/zipl/active_devices.txt_ file.
++
+[listing]
+.Example
+--
+rd.cio_accept=0.0.0180,0.0.0800,0.0.0801,0.0.0802
+--
+
 Plymouth Boot Splash
 ~~~~~~~~~~~~~~~~~~~~
 **plymouth.enable=0**::
diff --git a/modules.d/81cio_ignore/module-setup.sh b/modules.d/81cio_ignore/module-setup.sh
index 52cb188..42ae2f9 100644
--- a/modules.d/81cio_ignore/module-setup.sh
+++ b/modules.d/81cio_ignore/module-setup.sh
@@ -10,39 +10,30 @@ check() {
     return 0
 }
 
-find_mount() {
-    local dev mnt etc wanted_dev zipl_dev
-    wanted_dev="$(readlink -e -q $1)"
-    while read dev mnt etc; do
-        [ "$mnt" = "$wanted_dev" ] && zipl_dev="$dev" && break
-    done < /etc/fstab
-    if [ -z "$zipl_dev" ] ; then
-        return 1
-    fi
-    if [ -e ${wanted_dev}/active_devices.txt ] ; then
-        echo "$zipl_dev"
-        return 0
-    fi
-    return 1
-}
-
 cmdline() {
-    local zipl_dasd
-    zipl_dasd=`find_mount /boot/zipl`
-    if [ -n "$zipl_dasd" ] ; then
-	printf " rd.zipl_dasd=%s " $zipl_dasd
+    local cio_accept
+
+    if [ -e /boot/zipl/active_devices.txt ] ; then
+        while read dev etc ; do
+            [ "$dev" = "#" -o "$dev" = "" ] && continue;
+            if [ -z "$cio_accept" ] ; then
+                cio_accept="$dev"
+            else
+                cio_accept="${cio_accept},${dev}"
+            fi
+        done < /boot/zipl/active_devices.txt
+    fi
+    if [ -n "$cio_accept" ] ; then
+	echo "rd.cio_accept=${cio_accept}"
     fi
 }
 
 # called by dracut
 install() {
     if [[ $hostonly_cmdline == "yes" ]];then
-	echo $(cmdline) >"${initdir}/etc/cmdline.d/01zipl_dasd.conf"
+	cmdline >> "${initdir}/etc/cmdline.d/01cio_accept.conf"
     fi
 
-    inst_hook pre-mount 10 "$moddir/parse-zipl.sh"
-    inst_multiple cio_ignore mount umount mkdir
-}
-installkernel() {
-    instmods ext4
+    inst_hook cmdline 20 "$moddir/parse-cio_accept.sh"
+    inst_multiple cio_ignore
 }
diff --git a/modules.d/81cio_ignore/parse-cio_accept.sh b/modules.d/81cio_ignore/parse-cio_accept.sh
new file mode 100644
index 0000000..fec8a92
--- /dev/null
+++ b/modules.d/81cio_ignore/parse-cio_accept.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+
+CIO_IGNORE=$(getarg cio_ignore)
+CIO_ACCEPT=$(getarg rd.cio_accept)
+
+if [ -z $CIO_IGNORE ] ; then
+    info "cio_ignored disabled on commandline"
+    return
+fi
+if [ -n "$CIO_ACCEPT" ] ; then
+    IFS=,
+    set -- $CIO_ACCEPT
+    while (($# > 0)) ; do
+        info "Enabling device $1"
+        cio_ignore --remove $1
+        shift
+    done
+    unset IFS
+fi
diff --git a/modules.d/81cio_ignore/parse-zipl.sh b/modules.d/81cio_ignore/parse-zipl.sh
deleted file mode 100644
index 9d68c52..0000000
--- a/modules.d/81cio_ignore/parse-zipl.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
-# ex: ts=8 sw=4 sts=4 et filetype=sh
-
-ZIPL_DEV=$(getarg rd.zipl_dasd)
-ZIPL_DIR=/boot/zipl
-CIO_REMOVE_LIST=$ZIPL_DIR/active_devices.txt
-
-if ! getarg cio_ignore ; then
-    return
-fi
-if [ -n "$ZIPL_DEV" ];then
-	info "Waiting for zipl device $ZIPL_DEV"
-	wait_for_dev -n "$ZIPL_DEV"
-#
-#	mount device and read devices
-#
-	[ -d $ZIPL_DIR ] ||  mkdir -p $ZIPL_DIR
-	mount -t ext2 -o ro $ZIPL_DEV $ZIPL_DIR
-	if [ -f $CIO_REMOVE_LIST ] ; then
-#
-#	File exist
-#
-		while read dev etc; do
-		    [ "$dev" = "#" -o "$dev" = "" ] && continue
-		    cio_ignore --remove $dev
-		done < $CIO_REMOVE_LIST
-	fi
-	umount $ZIPL_DIR
-else
-	warn "No rd.zipl_dasd boot parameter found"
-fi
-- 
1.7.12.4

openSUSE Build Service is sponsored by