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