wok-4.x rev 7850
busybox/init: reduce subroot= waste
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Dec 28 23:15:27 2010 +0100 (2010-12-28) |
parents | e176d206d075 |
children | 403fb8adf07d |
files | busybox/stuff/init |
line diff
1.1 --- a/busybox/stuff/init Tue Dec 28 15:47:46 2010 +0000 1.2 +++ b/busybox/stuff/init Tue Dec 28 23:15:27 2010 +0100 1.3 @@ -4,7 +4,7 @@ 1.4 { 1.5 umount /proc 1.6 echo -e "\\033[70G[ \\033[1;33mOK\\033[0;39m ]" 1.7 - exec /sbin/switch_root mnt$subroot /sbin/init 1.8 + exec /sbin/switch_root mnt /sbin/init 1.9 } 1.10 1.11 failed() 1.12 @@ -15,7 +15,7 @@ 1.13 1.14 try_init() 1.15 { 1.16 - if [ ! -d /mnt$subroot/etc ] && grep -q cryptoroot= /proc/cmdline; then 1.17 + if [ ! -d /mnt/etc ] && grep -q cryptoroot= /proc/cmdline; then 1.18 modprobe dm-mod 1.19 modprobe dm-crypt 1.20 modprobe aes-i586 1.21 @@ -33,10 +33,10 @@ 1.22 fi 1.23 mount /dev/mapper/$dmlabel /mnt 1.24 fi 1.25 - if [ -d /mnt$subroot/etc ]; then 1.26 + if [ -d /mnt/etc ]; then 1.27 umount /sys 1.28 [ -n "$1" ] && for i in $@ ; do 1.29 - cp -a $i /mnt$subroot$(dirname $i) 1.30 + cp -a $i /mnt$(dirname $i) 1.31 done 1.32 mount /mnt -o remount,ro 1.33 launch_init 1.34 @@ -125,9 +125,16 @@ 1.35 fi 1.36 grep -q cryptoroot= /proc/cmdline && try_init 1.37 umount /sys 1.38 -grep -q subroot= /proc/cmdline && 1.39 +if grep -q subroot= /proc/cmdline; then 1.40 subroot="/$(sed 's/.*subroot=\([^ ]*\).*/\1/' < /proc/cmdline)" && 1.41 - exec chroot /mnt$subroot /sbin/init 1.42 + if [ -s /usr/share/boot/busybox-static ]; then 1.43 + mv /usr/share/boot/busybox-static . 1.44 + /busybox-static rm -rf /etc /lib /*bin /usr /var 1.45 + exec /busybox-static chroot /mnt$subroot /sbin/init 1.46 + else 1.47 + exec chroot /mnt$subroot /sbin/init 1.48 + fi 1.49 +fi 1.50 echo -n "Switching / to tmpfs..." 1.51 size="$(grep rootfssize= < /proc/cmdline | \ 1.52 sed 's/.*rootfssize=\([0-9]*[kmg%]\).*/-o size=\1/')"