| 1 | #!/bin/sh |
| 2 | # Copyright (C) 2006-2011 OpenWrt.org |
| 3 | # Copyright (C) 2010 Vertical Communications |
| 4 | |
| 5 | # This is free software, licensed under the GNU General Public License v2. |
| 6 | # See /LICENSE for more information. |
| 7 | |
| 8 | determine_root_device() { |
| 9 | root_device="$(mount | grep ' / ' | cut -f1 -d\ | grep -v rootfs )" |
| 10 | } |
| 11 | |
| 12 | set_jffs_mp() { |
| 13 | jffs="$(awk '/jffs2/ {print $2}' /proc/mounts)" |
| 14 | } |
| 15 | |
| 16 | er_load_modules() { |
| 17 | mkdir -p /tmp/extroot_modules/modules.d |
| 18 | mkdir -p /tmp/extroot_modules/modules |
| 19 | cp -L /etc/modules-boot.d/* /tmp/overlay/etc/modules-boot.d/* /tmp/extroot_modules/modules.d |
| 20 | ln -sf /lib/modules/*/* /tmp/overlay/lib/modules/*/* /tmp/extroot_modules/modules |
| 21 | local modules="$(cat /tmp/extroot_modules/modules.d/* 2>/dev/null)" |
| 22 | cd /tmp/extroot_modules/modules && [ -n "$modules" ] && { |
| 23 | echo "$modules" | sed -e 's/^\([^#].*\)/insmod \.\/\1.ko/'| sh 2>&- || : |
| 24 | } |
| 25 | rm -rf /tmp/extroot_modules |
| 26 | } |
| 27 | |
| 28 | pivot_rom() { # <new_root> <old_root> |
| 29 | mount -o move /proc $1/proc && \ |
| 30 | pivot_root $1 $1$2 && { |
| 31 | mount -o move $2/dev /dev |
| 32 | mount -o move $2/tmp /tmp |
| 33 | mount -o move $2/sys /sys 2>&- |
| 34 | return 0 |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | |