From a53dae47c3c68a5631a867ea1e508f3742682b8974cdaeb246fdd86d949e42a8 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Mon, 23 Jun 2014 08:43:45 +0000 Subject: [PATCH] Accepting request 237872 from home:hreinecke:branches:Base:System - 81cio_ignore: rewrite module to not mount any filesystem (bnc#882685) * Add: 0070-81cio_ignore-rewrite-module.patch - 81cio_ignore: ignore module if cio_ignore is not specified (bnc#882685) * Add: 0069-81cio_ignore-skip-module-if-cio_ignore-is-not-active.patch OBS-URL: https://build.opensuse.org/request/show/237872 OBS-URL: https://build.opensuse.org/package/show/Base:System/dracut?expand=0&rev=162 --- ...p-module-if-cio_ignore-is-not-active.patch | 115 +++++++++++ 0070-81cio_ignore-rewrite-module.patch | 180 ++++++++++++++++++ dracut.changes | 15 ++ dracut.spec | 4 + 4 files changed, 314 insertions(+) create mode 100644 0069-81cio_ignore-skip-module-if-cio_ignore-is-not-active.patch create mode 100644 0070-81cio_ignore-rewrite-module.patch diff --git a/0069-81cio_ignore-skip-module-if-cio_ignore-is-not-active.patch b/0069-81cio_ignore-skip-module-if-cio_ignore-is-not-active.patch new file mode 100644 index 0000000..9f3536e --- /dev/null +++ b/0069-81cio_ignore-skip-module-if-cio_ignore-is-not-active.patch @@ -0,0 +1,115 @@ +From d5bbccaaff904eb0dbbd2e5407278e69436e559b Mon Sep 17 00:00:00 2001 +From: Hannes Reinecke +Date: Tue, 17 Jun 2014 11:09:59 +0200 +Subject: 81cio_ignore: skip module if cio_ignore is not active + +When cio_ignore is not active we should skip the entire module +during boot; otherwise it'll lead to adverse effects. + +References: bnc#882685 + +Signed-off-by: Hannes Reinecke +--- + modules.d/81cio_ignore/module-setup.sh | 45 ++++++++++++++++++++-------------- + modules.d/81cio_ignore/parse-zipl.sh | 11 ++++++--- + 2 files changed, 34 insertions(+), 22 deletions(-) + +diff --git a/modules.d/81cio_ignore/module-setup.sh b/modules.d/81cio_ignore/module-setup.sh +index a812649..52cb188 100644 +--- a/modules.d/81cio_ignore/module-setup.sh ++++ b/modules.d/81cio_ignore/module-setup.sh +@@ -5,35 +5,44 @@ + # called by dracut + check() { + # do not add this module by default +- local arch=$(uname -m) +- [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 +- return 0 ++ local arch=$(uname -m) ++ [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 ++ return 0 + } + + find_mount() { +- local dev mnt etc wanted_dev +- wanted_dev="$(readlink -e -q $1)" +- while read dev mnt etc; do +- [ "$mnt" = "$wanted_dev" ] && echo "$dev" && return 0 +- done < /proc/mounts +- return 1 ++ 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` +- printf " rd.zipl_dasd=%s\n" "$zipl_dasd " ++ local zipl_dasd ++ zipl_dasd=`find_mount /boot/zipl` ++ if [ -n "$zipl_dasd" ] ; then ++ printf " rd.zipl_dasd=%s " $zipl_dasd ++ fi + } + + # called by dracut + install() { +- if [[ $hostonly_cmdline == "yes" ]];then +- echo $(cmdline) >"${initdir}/etc/cmdline.d/01zipl_dasd.conf" +- fi ++ if [[ $hostonly_cmdline == "yes" ]];then ++ echo $(cmdline) >"${initdir}/etc/cmdline.d/01zipl_dasd.conf" ++ fi + +- inst_hook pre-mount 10 "$moddir/parse-zipl.sh" +- inst_multiple cio_ignore mount umount mkdir ++ inst_hook pre-mount 10 "$moddir/parse-zipl.sh" ++ inst_multiple cio_ignore mount umount mkdir + } + installkernel() { +- instmods ext4 ++ instmods ext4 + } +diff --git a/modules.d/81cio_ignore/parse-zipl.sh b/modules.d/81cio_ignore/parse-zipl.sh +index 5f7aa58..9d68c52 100644 +--- a/modules.d/81cio_ignore/parse-zipl.sh ++++ b/modules.d/81cio_ignore/parse-zipl.sh +@@ -2,17 +2,20 @@ + # -*- 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=/tmp/zipl ++ZIPL_DEV=$(getarg rd.zipl_dasd) ++ZIPL_DIR=/boot/zipl + CIO_REMOVE_LIST=$ZIPL_DIR/active_devices.txt + +-if [ -n $ZIPL_DEV ];then ++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 $ZIPL_DIR ++ [ -d $ZIPL_DIR ] || mkdir -p $ZIPL_DIR + mount -t ext2 -o ro $ZIPL_DEV $ZIPL_DIR + if [ -f $CIO_REMOVE_LIST ] ; then + # +-- +1.8.4.5 + diff --git a/0070-81cio_ignore-rewrite-module.patch b/0070-81cio_ignore-rewrite-module.patch new file mode 100644 index 0000000..a0278f1 --- /dev/null +++ b/0070-81cio_ignore-rewrite-module.patch @@ -0,0 +1,180 @@ +From 137090516e1c48ef134209c2ed4f625799691090 Mon Sep 17 00:00:00 2001 +From: Hannes Reinecke +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 +--- + 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=**____:: ++ Remove the devices listed in from the default ++ cio_ignore kernel command-line settings. ++ 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 + diff --git a/dracut.changes b/dracut.changes index 99ff43e..6d60573 100644 --- a/dracut.changes +++ b/dracut.changes @@ -1,3 +1,18 @@ +------------------------------------------------------------------- +Tue Jun 17 16:58:03 CEST 2014 - hare@suse.de + +- 81cio_ignore: rewrite module to not mount any filesystem + (bnc#882685) + * Add: 0070-81cio_ignore-rewrite-module.patch + +------------------------------------------------------------------- +Tue Jun 17 11:14:07 CEST 2014 - hare@suse.de + +- 81cio_ignore: ignore module if cio_ignore is not specified + (bnc#882685) + * Add: + 0069-81cio_ignore-skip-module-if-cio_ignore-is-not-active.patch + ------------------------------------------------------------------- Mon Jun 16 14:17:43 CEST 2014 - hare@suse.de diff --git a/dracut.spec b/dracut.spec index 87a8eb7..b019357 100644 --- a/dracut.spec +++ b/dracut.spec @@ -89,6 +89,8 @@ Patch65: 0065-95iscsi-Fixup-bnx2i-offload-booting.patch Patch66: 0066-40network-always-start-netroot-in-ifup.sh.patch Patch67: 0067-95fcoe-check-always-returns-255.patch Patch68: 0068-95fcoe-uefi-Test-for-EFI-firmware.patch +Patch69: 0069-81cio_ignore-skip-module-if-cio_ignore-is-not-active.patch +Patch70: 0070-81cio_ignore-rewrite-module.patch BuildRequires: asciidoc BuildRequires: bash @@ -198,6 +200,8 @@ and its cryptography during startup. %patch66 -p1 %patch67 -p1 %patch68 -p1 +%patch69 -p1 +%patch70 -p1 %build %configure\