* [PATCH 1/2] check kernel module existance
@ 2012-05-15 6:19 Cong Wang
[not found] ` <1337062797-28629-1-git-send-email-amwang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Cong Wang @ 2012-05-15 6:19 UTC (permalink / raw)
To: initramfs-u79uwXL29TY76Z2rM5mHXA; +Cc: Dave Young, Cong Wang, Harald Hoyer
From: Cong Wang <xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
This patch adds check of kernel module existance and
propagate errors to upper callers.
In case of break other callers of instmods(), this patch
adds an option '-c' to it, only when "-c" is specified
we fail, otherwise, errors are ignored.
Reported-by: Dave Young <dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Cong Wang <xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Harald Hoyer <harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
dracut-functions.sh | 37 +++++++++++++++++++++-------
dracut.sh | 10 ++++++-
modules.d/90kernel-modules/module-setup.sh | 8 ++++-
3 files changed, 42 insertions(+), 13 deletions(-)
diff --git a/dracut-functions.sh b/dracut-functions.sh
index 8256e02..4fe428e 100755
--- a/dracut-functions.sh
+++ b/dracut-functions.sh
@@ -1108,17 +1108,22 @@ find_kernel_modules () {
find_kernel_modules_by_path drivers
}
-# instmods <kernel module> [<kernel module> ... ]
-# instmods <kernel subsystem>
+# instmods [-c] <kernel module> [<kernel module> ... ]
+# instmods [-c] <kernel subsystem>
# install kernel modules along with all their dependencies.
# <kernel subsystem> can be e.g. "=block" or "=drivers/usb/storage"
instmods() {
[[ $no_kernel = yes ]] && return
# called [sub]functions inherit _fderr
local _fderr=9
+ local _check=no
+ if [[ $1 = '-c' ]]; then
+ _check=yes
+ shift
+ fi
function inst1mod() {
- local _mod="$1"
+ local _ret=0 _mod="$1"
case $_mod in
=*)
if [ -f $srcmods/modules.${_mod#=} ]; then
@@ -1162,26 +1167,40 @@ instmods() {
((_ret+=$?))
;;
esac
+ return $_ret
}
function instmods_1() {
- local _ret=0 _mod _mpargs
+ local _mod _mpargs
if (($# == 0)); then # filenames from stdin
while read _mod; do
- inst1mod "${_mod%.ko*}"
+ inst1mod "${_mod%.ko*}" || {
+ if [ "$_check" = "yes" ]; then
+ dfatal "Failed to install $_mod"
+ return 1
+ fi
+ }
done
fi
while (($# > 0)); do # filenames as arguments
- inst1mod ${1%.ko*}
+ inst1mod ${1%.ko*} || {
+ if [ "$_check" = "yes" ]; then
+ dfatal "Failed to install $1"
+ return 1
+ fi
+ }
shift
done
- return $_ret
+ return 0
}
- local _filter_not_found='FATAL: Module .* not found.'
+ local _ret _filter_not_found='FATAL: Module .* not found.'
+ set -o pipefail
# Capture all stderr from modprobe to _fderr. We could use {var}>...
# redirections, but that would make dracut require bash4 at least.
eval "( instmods_1 \"\$@\" ) ${_fderr}>&1" \
| while read line; do [[ "$line" =~ $_filter_not_found ]] || echo $line;done | derror
- return $?
+ _ret=$?
+ set +o pipefail
+ return $_ret
}
diff --git a/dracut.sh b/dracut.sh
index 2a7a812..315b965 100755
--- a/dracut.sh
+++ b/dracut.sh
@@ -708,11 +708,17 @@ for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
[[ $show_modules = yes ]] && echo "$_d_mod" || \
dinfo "*** Including module: $_d_mod ***"
if [[ $kernel_only = yes ]]; then
- module_installkernel $_d_mod
+ module_installkernel $_d_mod || {
+ dfatal "installkernel failed in module $_d_mod"
+ exit 1
+ }
else
module_install $_d_mod
if [[ $no_kernel != yes ]]; then
- module_installkernel $_d_mod
+ module_installkernel $_d_mod || {
+ dfatal "installkernel failed in module $_d_mod"
+ exit 1
+ }
fi
fi
mods_to_load=${mods_to_load// $_d_mod /}
diff --git a/modules.d/90kernel-modules/module-setup.sh b/modules.d/90kernel-modules/module-setup.sh
index 26f4784..8cff439 100755
--- a/modules.d/90kernel-modules/module-setup.sh
+++ b/modules.d/90kernel-modules/module-setup.sh
@@ -58,8 +58,12 @@ installkernel() {
hostonly='' instmods $drivers
fi
- [[ $add_drivers ]] && hostonly='' instmods $add_drivers
- [[ $filesystems ]] && hostonly='' instmods $filesystems
+ if [[ $add_drivers ]]; then
+ hostonly='' instmods -c $add_drivers || return 1
+ fi
+ if [[ $filesystems ]]; then
+ hostonly='' instmods -c $filesystems || return 1
+ fi
# force install of scsi_wait_scan
hostonly='' instmods scsi_wait_scan
--
1.7.7.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] check install files passed by cmdline
[not found] ` <1337062797-28629-1-git-send-email-amwang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2012-05-15 6:19 ` Cong Wang
2012-05-21 9:42 ` [PATCH 1/2] check kernel module existance Cong Wang
1 sibling, 0 replies; 4+ messages in thread
From: Cong Wang @ 2012-05-15 6:19 UTC (permalink / raw)
To: initramfs-u79uwXL29TY76Z2rM5mHXA; +Cc: Dave Young, Cong Wang, Harald Hoyer
From: Cong Wang <xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
We should not trust cmdline passed by users, always
check the install files passed from cmdline. This restores
the old behaviour which was changed by:
commit c6c6a08850c7e4ee211696895f7ca3864be85052
Author: Harald Hoyer <harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Date: Tue Feb 7 18:26:30 2012 +0100
add "install_items" to dracut.conf
Reported-by: Dave Young <dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Cong Wang <xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Harald Hoyer <harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
dracut.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/dracut.sh b/dracut.sh
index 315b965..bf9e79f 100755
--- a/dracut.sh
+++ b/dracut.sh
@@ -770,7 +770,7 @@ done
if [[ $kernel_only != yes ]]; then
for item in $install_items; do
- dracut_install -o "$item"
+ dracut_install "$item"
done
unset item
--
1.7.7.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] check kernel module existance
[not found] ` <1337062797-28629-1-git-send-email-amwang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-05-15 6:19 ` [PATCH 2/2] check install files passed by cmdline Cong Wang
@ 2012-05-21 9:42 ` Cong Wang
[not found] ` <4FBA0DF7.5000903-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
1 sibling, 1 reply; 4+ messages in thread
From: Cong Wang @ 2012-05-21 9:42 UTC (permalink / raw)
To: Cong Wang; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA, Dave Young, Harald Hoyer
Hi, Harald,
Could you review these 2 patches please? Kdump needs these 2 patches, as
Dave reported.
Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] check kernel module existance
[not found] ` <4FBA0DF7.5000903-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2012-05-21 9:49 ` Harald Hoyer
0 siblings, 0 replies; 4+ messages in thread
From: Harald Hoyer @ 2012-05-21 9:49 UTC (permalink / raw)
To: Cong Wang; +Cc: Cong Wang, initramfs-u79uwXL29TY76Z2rM5mHXA, Dave Young
Am 21.05.2012 11:42, schrieb Cong Wang:
> Hi, Harald,
>
> Could you review these 2 patches please? Kdump needs these 2 patches, as Dave
> reported.
>
> Thanks!
Pushed
http://git.kernel.org/?p=boot/dracut/dracut.git;a=commitdiff;h=a6d3be9dd5e105c926b753fc3a26f0a91119c2a4
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-05-21 9:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-15 6:19 [PATCH 1/2] check kernel module existance Cong Wang
[not found] ` <1337062797-28629-1-git-send-email-amwang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-05-15 6:19 ` [PATCH 2/2] check install files passed by cmdline Cong Wang
2012-05-21 9:42 ` [PATCH 1/2] check kernel module existance Cong Wang
[not found] ` <4FBA0DF7.5000903-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-05-21 9:49 ` Harald Hoyer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox