Do not use deprecated path to functions.sh (/etc/functions.sh -> /lib/functions.sh)
[openwrt.git] / package / base-files / files / lib / functions / boot.sh
index a8832413501bfc949fc30888312c30b7558fe978..137c3bf476525b7730150925bd2a6b37e420af6e 100644 (file)
@@ -2,10 +2,6 @@
 # Copyright (C) 2006-2010 OpenWrt.org
 # Copyright (C) 2010 Vertical Communications
 
-mount() {
-       /bin/busybox mount -o noatime "$@"
-}
-
 boot_hook_splice_start() {
        export -n PI_HOOK_SPLICE=1
 }
@@ -71,28 +67,28 @@ boot_run_hook() {
 find_mtd_part() {
        local PART="$(grep "\"$1\"" /proc/mtd | awk -F: '{print $1}')"
        local PREFIX=/dev/mtdblock
-       
+
        PART="${PART##mtd}"
        [ -d /dev/mtdblock ] && PREFIX=/dev/mtdblock/
        echo "${PART:+$PREFIX$PART}"
 }
 
 jffs2_ready () {
-    mtdpart="$(find_mtd_part rootfs_data)"
-    [ -z "$mtdpart" ] && return 1
-    magic=$(hexdump $mtdpart -n 4 -e '4/1 "%02x"')
-    [ "$magic" != "deadc0de" ]
+       mtdpart="$(find_mtd_part rootfs_data)"
+       [ -z "$mtdpart" ] && return 1
+       magic=$(hexdump $mtdpart -n 4 -e '4/1 "%02x"')
+       [ "$magic" != "deadc0de" ]
 }
 
 dupe() { # <new_root> <old_root>
        cd $1
        echo -n "creating directories... "
        {
-               cd $2 
+               cd $2
                find . -xdev -type d
                echo "./dev ./overlay ./mnt ./proc ./tmp"
                # xdev skips mounted directories
-               cd $1 
+               cd $1
        } | xargs mkdir -p
        echo "done"
 
@@ -112,12 +108,12 @@ dupe() { # <new_root> <old_root>
 }
 
 pivot() { # <new_root> <old_root>
-       mount -o move /proc $1/proc && \
+       mount -o noatime,move /proc $1/proc && \
        pivot_root $1 $1$2 && {
-               mount -o move $2/dev /dev
-               mount -o move $2/tmp /tmp
-               mount -o move $2/sys /sys 2>&-
-               mount -o move $2/overlay /overlay 2>&-
+               mount -o noatime,move $2/dev /dev
+               mount -o noatime,move $2/tmp /tmp
+               mount -o noatime,move $2/sys /sys 2>&-
+               mount -o noatime,move $2/overlay /overlay 2>&-
                return 0
        }
 }
@@ -125,15 +121,17 @@ pivot() { # <new_root> <old_root>
 fopivot() { # <rw_root> <ro_root> <dupe?>
        root=$1
        {
-               if grep -q mini_fo /proc/filesystems; then
-                       mount -t mini_fo -o base=/,sto=$1 "mini_fo:$1" /mnt 2>&- && root=/mnt
+               if grep -q overlay /proc/filesystems; then
+                       mount -o noatime,lowerdir=/,upperdir=$1 -t overlayfs "overlayfs:$1" /mnt && root=/mnt
+               elif grep -q mini_fo /proc/filesystems; then
+                       mount -t mini_fo -o noatime,base=/,sto=$1 "mini_fo:$1" /mnt 2>&- && root=/mnt
                else
-                       mount --bind / /mnt
-                       mount --bind -o union "$1" /mnt && root=/mnt 
+                       mount --bind -o noatime / /mnt
+                       mount --bind -o noatime,union "$1" /mnt && root=/mnt
                fi
        } || {
                [ "$3" = "1" ] && {
-               mount | grep "on $1 type" 2>&- 1>&- || mount -o bind $1 $1
+               mount | grep "on $1 type" 2>&- 1>&- || mount -o noatime,bind $1 $1
                dupe $1 $rom
                }
        }
@@ -142,7 +140,7 @@ fopivot() { # <rw_root> <ro_root> <dupe?>
 
 ramoverlay() {
        mkdir -p /tmp/root
-       mount -t tmpfs -o mode=0755 root /tmp/root
+       mount -t tmpfs -o noatime,mode=0755 root /tmp/root
        fopivot /tmp/root /rom 1
 }