From: SeokYeon Hwang Date: Mon, 12 Jan 2015 07:08:38 +0000 (+0900) Subject: initramfs: respect "init=", "root=" in kernel parameters X-Git-Tag: Tizen_Studio_1.3_Release_p3.0~97 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0c2eeae603bf92d5a583ea10db8e99635ad1aee8;p=sdk%2Femulator%2Femulator-kernel.git initramfs: respect "init=", "root=" in kernel parameters Change-Id: Id35d3b96deefc9df2b22471b734f6cebd9c79b97 Signed-off-by: SeokYeon Hwang --- diff --git a/ramfs/init b/ramfs/init index 5b8ed28..1a5d8fc 100644 --- a/ramfs/init +++ b/ramfs/init @@ -8,6 +8,14 @@ NO_COLOR="\033[0m" NEW_ROOT="/new_root" +cmdline() { + local value + value=" $(cat /proc/cmdline) " + value="${value##* $1=}" + value="${value%% *}" + [ "$value" != "" ] && echo "$value" +} + /bin/busybox mkdir -p /dev /bin/busybox mount -t devtmpfs devtmpfs /dev @@ -22,14 +30,26 @@ echo -e "${COLOR_GREEN}Preparing...${NO_COLOR}" /bin/busybox mkdir -p /sys /bin/busybox mount -t sysfs sys /sys +# for init... +INIT=$(cmdline init) +if [ -z $INIT ]; then + INIT="/sbin/init" +fi + # mount root... echo -e "${COLOR_GREEN}Mount image...${NO_COLOR}" -/bin/busybox mount -o rw /dev/vda $NEW_ROOT +ROOT=$(cmdline root) +if [ -z $ROOT ]; then + echo -e "${COLOR_BLUE}Mount legacy image...${NO_COLOR}" + /bin/busybox mount -o rw /dev/vda $NEW_ROOT +else + echo -e "${COLOR_BLUE}Mount ${ROOT}...${NO_COLOR}" + /bin/busybox mount -o rw $ROOT $NEW_ROOT +fi # clean up... /bin/busybox umount /proc /bin/busybox umount /sys -# switch root... echo -e "${COLOR_GREEN}Switching root...${NO_COLOR}" -exec /bin/busybox switch_root -c /dev/console $NEW_ROOT /sbin/init +exec /bin/busybox switch_root -c /dev/console $NEW_ROOT $INIT