zdev: Fix zdev dracut module aborting on unknown root device

Running dracut when the root device is not known to zdev (for example
because it is located on a virtio block device) will cause the zdev
dracut module to incorrectly return an error in the installkernel()
function. As a result dracut aborts with an error.

Fix this by ensuring that the non-zero exit code resulting from lszdev
not being able to determine the root device is not passed on to the
calling function. Also remove unnecessary error output in this case
by leaving the install() function early when the root device is not
known to zdev.

Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
This commit is contained in:
Peter Oberparleiter
2017-12-07 17:21:11 +01:00
committed by Michael Holzheu
parent dba9616a5b
commit 0348a8443e

View File

@@ -29,13 +29,21 @@ depends() {
}
installkernel() {
local _modules=$(lszdev --by-path / --columns MODULES --no-headings)
local _modules=$(lszdev --by-path / --columns MODULES --no-headings 2>/dev/null)
[ -z "$_modules" ] && return 0
[ ! -z "$_modules" ] && instmods $_modules
}
install() {
local _tempfile=$(mktemp --tmpdir dracut-zdev.XXXXXX)
local _tempfile
# Exit early if root device type is unknown
if ! lszdev --by-path / >/dev/null 2>&1 ; then
return 0
fi
_tempfile=$(mktemp --tmpdir dracut-zdev.XXXXXX)
if chzdev --export - --persistent --by-path / >/dev/null 2>&1 ; then
# Use persistent configuration