OSDN Git Service

initrd: support iso-scan/filename in cmdline
authorChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 31 Dec 2014 09:21:08 +0000 (17:21 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 31 Dec 2014 09:21:08 +0000 (17:21 +0800)
By specifying the iso-scan/filename to the iso file and
using bootloader support loopback device (e.g., grub2),
we can now boot from an iso file directly.

Android.mk
initrd/init

index c964afe..404d998 100644 (file)
@@ -66,7 +66,7 @@ $(INITRD_RAMDISK): $(initrd_bin) $(systemimg) $(TARGET_INITRD_SCRIPTS) | $(ACP)
        $(ACP) -pr $(initrd_dir) $(TARGET_INSTALLER_OUT)
        $(if $(TARGET_INITRD_SCRIPTS),$(ACP) -p $(TARGET_INITRD_SCRIPTS) $(TARGET_INSTALLER_OUT)/scripts)
        ln -s /bin/ld-linux.so.2 $(TARGET_INSTALLER_OUT)/lib
-       mkdir -p $(addprefix $(TARGET_INSTALLER_OUT)/,android mnt proc sys tmp sfs hd)
+       mkdir -p $(addprefix $(TARGET_INSTALLER_OUT)/,android iso mnt proc sys tmp sfs hd)
        echo "VER=$(VER)" > $(TARGET_INSTALLER_OUT)/scripts/00-ver
        $(MKBOOTFS) $(TARGET_INSTALLER_OUT) | gzip -9 > $@
 
index 49d4c65..60bdd30 100755 (executable)
@@ -78,8 +78,15 @@ check_root()
        else
                dev=$1
        fi
-       try_mount ro $dev /mnt && [ -e /mnt/$SRC/ramdisk.img ]
-       [ $? -ne 0 ] && return 1
+       try_mount ro $dev /mnt || return 1
+       if [ -n "$iso" -a -e /mnt/$iso ]; then
+               mount --move /mnt /iso
+               mkdir /mnt/iso
+               mount -o loop /iso/$iso /mnt/iso
+               SRC=iso
+       elif [ ! -e /mnt/$SRC/ramdisk.img ]; then
+               return 1
+       fi
        zcat /mnt/$SRC/ramdisk.img | cpio -id > /dev/null
        if [ -e /mnt/$SRC/system.sfs ]; then
                mount -o loop /mnt/$SRC/system.sfs /sfs
@@ -121,6 +128,16 @@ echo -n Detecting Android-x86...
 
 [ -z "$SRC" -a -n "$BOOT_IMAGE" ] && SRC=`dirname $BOOT_IMAGE`
 
+for c in `cat /proc/cmdline`; do
+       case $c in
+               iso-scan/filename=*)
+                       eval `echo $c | cut -b1-3,18-`
+                       ;;
+               *)
+                       ;;
+       esac
+done
+
 mount -t tmpfs tmpfs /android
 cd /android
 while :; do