2 # Copyright (C) 2006-2010 OpenWrt.org
3 # Copyright (C) 2010 Vertical Communications
6 /bin
/busybox mount
-o noatime
"$@"
9 boot_hook_splice_start
() {
10 export -n PI_HOOK_SPLICE
=1
13 boot_hook_splice_finish
() {
15 for hook
in $PI_STACK_LIST; do
16 local v
; eval "v=\${${hook}_splice:+\$${hook}_splice }$hook"
17 export -n "${hook}=${v% }"
18 export -n "${hook}_splice="
20 export -n PI_HOOK_SPLICE
=
24 local hook
="${1}_hook"
25 export -n "PI_STACK_LIST=${PI_STACK_LIST:+$PI_STACK_LIST }$hook"
30 local hook
="${1}_hook${PI_HOOK_SPLICE:+_splice}"
34 local v
; eval "v=\$$hook"
35 export -n "$hook=${v:+$v }$func"
40 local hook
="${1}_hook"
43 local v
; eval "v=\$$hook"
45 local first
="${v%% *}"
47 [ "$v" != "${v#* }" ] && \
48 export -n "$hook=${v#* }" || \
51 export -n "$rvar=$first"
62 while boot_hook_shift
"$hook" func
; do
63 local ran
; eval "ran=\$PI_RAN_$func"
65 export -n "PI_RAN_$func=1"
72 local PART
="$(grep "\"$1\"" /proc/mtd | awk -F: '{print $1}')"
73 local PREFIX
=/dev
/mtdblock
76 [ -d /dev
/mtdblock
] && PREFIX
=/dev
/mtdblock
/
77 echo "${PART:+$PREFIX$PART}"
81 mtdpart
="$(find_mtd_part rootfs_data)"
82 [ -z "$mtdpart" ] && return 1
83 magic
=$
(hexdump $mtdpart -n 4 -e '4/1 "%02x"')
84 [ "$magic" != "deadc0de" ]
87 dupe
() { # <new_root> <old_root>
89 echo -n "creating directories... "
93 echo "./dev ./overlay ./mnt ./proc ./tmp"
94 # xdev skips mounted directories
99 echo -n "setting up symlinks... "
100 for file in $
(cd $2; find .
-xdev -type f
;); do
102 .
/rom
/note
) ;; #nothing
104 .
/usr
/lib
/opkg
/info
/*) cp -af $2/$file $file;;
105 *) ln -sf /rom
/${file#./*} $file;;
108 for file in $
(cd $2; find .
-xdev -type l
;); do
109 cp -af $2/${file#./*} $file
114 pivot
() { # <new_root> <old_root>
115 mount
-o move
/proc
$1/proc
&& \
116 pivot_root
$1 $1$2 && {
117 mount
-o move
$2/dev
/dev
118 mount
-o move
$2/tmp
/tmp
119 mount
-o move
$2/sys
/sys
2>&-
120 mount
-o move
$2/overlay
/overlay
2>&-
125 fopivot
() { # <rw_root> <ro_root> <dupe?>
128 if grep -q overlay
/proc
/filesystems
; then
129 mount
-t overlayfs
-olowerdir=/,upperdir
=$1 "overlayfs:$1" /mnt
&& root
=/mnt
130 elif grep -q mini_fo
/proc
/filesystems
; then
131 mount
-t mini_fo
-o base
=/,sto
=$1 "mini_fo:$1" /mnt
2>&- && root
=/mnt
134 mount
--bind -o union
"$1" /mnt
&& root
=/mnt
138 mount |
grep "on $1 type" 2>&- 1>&- || mount
-o bind $1 $1
147 mount
-t tmpfs
-o mode
=0755 root
/tmp
/root
148 fopivot
/tmp
/root
/rom
1
This page took 0.05061 seconds and 5 git commands to generate.