summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2023-06-01 10:02:24 +0300
committerPatrick Williams <patrick@stwcx.xyz>2023-06-08 03:46:24 +0300
commite9284a5c79f324ddd9d58e2a70090f9d397e90f1 (patch)
tree26f05fa4308463296d33f8596371c9fe55b558ff
parent13890c637db45bf0536b257c8b3085885e6db140 (diff)
downloadopenbmc-e9284a5c79f324ddd9d58e2a70090f9d397e90f1.tar.xz
meta-phosphor: mmc-init: Abide by init= from kernel commandline
Use of e.g. systemd-bootchart[1] requires that we override the path to `init` on the kernel commandline. Currently `mmc-init.sh` hard-codes `/sbin/init` as the init path and this prevents such boot analysis. Generalise option processing for the kernel commandline so we can extract the value for arbitrary key-value pairs and build the required functionality on top of this new abstraction. [1]: https://manpages.debian.org/testing/systemd-bootchart/systemd-bootchart.1.en.html Change-Id: I3d3d441f4861e1ce37954a0fcd49eb15906006a1 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
-rw-r--r--meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh23
1 files changed, 13 insertions, 10 deletions
diff --git a/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh b/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh
index c55977f2fa..295bcc1d2c 100644
--- a/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh
+++ b/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh
@@ -1,20 +1,21 @@
#!/bin/sh
-# Get the value of the root env variable found in /proc/cmdline
-get_root() {
+kgetopt ()
+{
_cmdline="$(cat /proc/cmdline)"
- root=
- for opt in $_cmdline
+ _optname="$1"
+ _optval="$2"
+ for _opt in $_cmdline
do
- case $opt in
- root=PARTLABEL=*)
- root=${opt##root=PARTLABEL=}
+ case "$_opt" in
+ "${_optname}"=*)
+ _optval="${_opt##"${_optname}"=}"
;;
*)
;;
esac
done
- [ -n "$root" ] && echo "$root"
+ [ -n "$_optval" ] && echo "$_optval"
}
fslist="proc sys dev run"
@@ -61,7 +62,7 @@ udevadm trigger --type=devices --action=add
udevadm settle --timeout=10
mkdir -p $rodir
-if ! mount /dev/disk/by-partlabel/"$(get_root)" $rodir -t ext4 -o ro; then
+if ! mount /dev/disk/by-partlabel/"$(kgetopt root=PARTLABEL)" $rodir -t ext4 -o ro; then
/bin/sh
fi
@@ -102,8 +103,10 @@ rm -rf $rodir/var/persist/etc-work/
mkdir -p $rodir/var/persist/etc $rodir/var/persist/etc-work $rodir/var/persist/home/root
mount overlay $rodir/etc -t overlay -o lowerdir=$rodir/etc,upperdir=$rodir/var/persist/etc,workdir=$rodir/var/persist/etc-work
+init="$(kgetopt init /sbin/init)"
+
for f in $fslist; do
mount --move "$f" "$rodir/$f"
done
-exec switch_root $rodir /sbin/init
+exec switch_root $rodir "$init"