From 439a869090282f229cf0edb41cc2d6e94f02b5c2 Mon Sep 17 00:00:00 2001 From: Mirko Vogt Date: Wed, 19 Dec 2012 16:07:46 +0000 Subject: [PATCH] Do not overload mount-call - trying to reduce confusion The behaviour of calling 'mount' differed depending on whether it called the busybox-mount, the mount of util-linux, the mount defined in /lib/functions.sh and /lib/functions/boot.sh /etc/preinit even included /lib/functions.sh and /lib/functions/boot.sh, both re-defining 'mount'. SVN-Revision: 34792 --- package/base-files/files/etc/init.d/boot | 2 +- package/base-files/files/etc/init.d/usb | 2 +- .../files/lib/firstboot/20_no_fo_mount_jffs | 4 +-- .../files/lib/firstboot/30_is_rootfs_mounted | 2 +- package/base-files/files/lib/functions.sh | 3 --- .../base-files/files/lib/functions/boot.sh | 26 ++++++++----------- .../files/lib/preinit/10_check_for_mtd | 2 +- .../files/lib/preinit/10_essential_fs | 6 ++--- .../files/lib/preinit/20_device_fs_mount | 8 +++--- .../files/lib/preinit/40_mount_devpts | 2 +- .../files/lib/preinit/40_mount_jffs2 | 2 +- .../files/lib/preinit/70_pivot_jffs2_root | 2 +- .../base-files/files/lib/upgrade/common.sh | 12 ++++----- package/base-files/files/sbin/firstboot | 2 +- .../base-files/lib/preinit/15_mount_proc_brcm | 2 +- target/linux/generic/base-files/init | 24 ++++++++--------- .../lib/preinit/15_essential_fs_x86 | 2 +- .../lib/preinit/15_essential_fs_x86 | 4 +-- .../base-files/lib/preinit/45_mount_xenfs | 2 +- 19 files changed, 50 insertions(+), 59 deletions(-) diff --git a/package/base-files/files/etc/init.d/boot b/package/base-files/files/etc/init.d/boot index 43837a80f2..ef97383d8d 100755 --- a/package/base-files/files/etc/init.d/boot +++ b/package/base-files/files/etc/init.d/boot @@ -66,7 +66,7 @@ start() { touch /var/log/lastlog touch /tmp/resolv.conf.auto ln -sf /tmp/resolv.conf.auto /tmp/resolv.conf - grep -q debugfs /proc/filesystems && mount -t debugfs debugfs /sys/kernel/debug + grep -q debugfs /proc/filesystems && mount -o noatime -t debugfs debugfs /sys/kernel/debug [ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe load_modules /etc/modules.d/* diff --git a/package/base-files/files/etc/init.d/usb b/package/base-files/files/etc/init.d/usb index 7b443b651e..43cdfd9a95 100755 --- a/package/base-files/files/etc/init.d/usb +++ b/package/base-files/files/etc/init.d/usb @@ -4,6 +4,6 @@ START=39 start() { [ -d /proc/bus/usb ] && { - /bin/mount -t usbfs none /proc/bus/usb + mount -o noatime -t usbfs none /proc/bus/usb } } diff --git a/package/base-files/files/lib/firstboot/20_no_fo_mount_jffs b/package/base-files/files/lib/firstboot/20_no_fo_mount_jffs index 8a1d4e06d2..c03714fa6d 100644 --- a/package/base-files/files/lib/firstboot/20_no_fo_mount_jffs +++ b/package/base-files/files/lib/firstboot/20_no_fo_mount_jffs @@ -5,8 +5,8 @@ no_fo_mount_jffs() { # initialize jffs2 - mount "$mtdpart" /overlay -t jffs2 || exit - + mount -o noatime "$mtdpart" /overlay -t jffs2 || exit + # workaround to ensure that union can attach properly sync ls /overlay >/dev/null diff --git a/package/base-files/files/lib/firstboot/30_is_rootfs_mounted b/package/base-files/files/lib/firstboot/30_is_rootfs_mounted index e2ba01d502..7233fd9039 100644 --- a/package/base-files/files/lib/firstboot/30_is_rootfs_mounted +++ b/package/base-files/files/lib/firstboot/30_is_rootfs_mounted @@ -4,7 +4,7 @@ # Copyright (C) 2010 Vertical Communications skip_if_rootfs_mounted() { - mount "$mtdpart" /rom/overlay -t jffs2 || exit + mount -o noatime -t jffs2 "$mtdpart" /rom/overlay || exit } boot_hook_add switch2jffs skip_if_rootfs_mounted diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh index b924fce285..db59706bc5 100755 --- a/package/base-files/files/lib/functions.sh +++ b/package/base-files/files/lib/functions.sh @@ -6,9 +6,6 @@ debug () { ${DEBUG:-:} "$@" } -mount() { - busybox mount "$@" -} # newline N=" diff --git a/package/base-files/files/lib/functions/boot.sh b/package/base-files/files/lib/functions/boot.sh index 8c3f27ba4f..137c3bf476 100644 --- a/package/base-files/files/lib/functions/boot.sh +++ b/package/base-files/files/lib/functions/boot.sh @@ -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 } @@ -112,12 +108,12 @@ dupe() { # } pivot() { # - 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 } } @@ -126,16 +122,16 @@ fopivot() { # root=$1 { if grep -q overlay /proc/filesystems; then - mount -t overlayfs -olowerdir=/,upperdir=$1 "overlayfs:$1" /mnt && root=/mnt + 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 base=/,sto=$1 "mini_fo:$1" /mnt 2>&- && root=/mnt + 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 } } @@ -144,7 +140,7 @@ fopivot() { # 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 } diff --git a/package/base-files/files/lib/preinit/10_check_for_mtd b/package/base-files/files/lib/preinit/10_check_for_mtd index 66f185e1af..6a7bd307f8 100644 --- a/package/base-files/files/lib/preinit/10_check_for_mtd +++ b/package/base-files/files/lib/preinit/10_check_for_mtd @@ -5,7 +5,7 @@ mount_no_mtd() { mtd unlock rootfs - mount -o remount,rw /dev/root / + mount -o noatime,remount,rw /dev/root / } check_for_mtd() { diff --git a/package/base-files/files/lib/preinit/10_essential_fs b/package/base-files/files/lib/preinit/10_essential_fs index 5d979fd49a..fc04eb7ff3 100644 --- a/package/base-files/files/lib/preinit/10_essential_fs +++ b/package/base-files/files/lib/preinit/10_essential_fs @@ -3,11 +3,11 @@ # Copyright (C) 2010 Vertical Communications do_mount_procfs() { - mount -t proc proc /proc + mount -o noatime -t proc proc /proc } do_mount_sysfs() { - mount -t sysfs sysfs /sys + mount -o noatime -tsysfs sysfs /sys } calc_tmpfs_size() { @@ -16,7 +16,7 @@ calc_tmpfs_size() { do_mount_tmpfs() { calc_tmpfs_size - mount -t tmpfs -o size=$pi_size,nosuid,nodev,mode=1777 tmpfs /tmp + mount -o noatime -t tmpfs -o size=$pi_size,nosuid,nodev,mode=1777 tmpfs /tmp } boot_hook_add preinit_essential do_mount_procfs diff --git a/package/base-files/files/lib/preinit/20_device_fs_mount b/package/base-files/files/lib/preinit/20_device_fs_mount index ed59b5b237..7535b3ff9d 100644 --- a/package/base-files/files/lib/preinit/20_device_fs_mount +++ b/package/base-files/files/lib/preinit/20_device_fs_mount @@ -6,19 +6,19 @@ do_move_devtmpfs() { local mnt="$(grep devtmpfs /proc/mounts)" mnt="${mnt#* }"; mnt="${mnt%% *}" - [ "$mnt" = "/dev" ] || mount -o move "$mnt" /dev + [ "$mnt" = "/dev" ] || mount -o noatime,move "$mnt" /dev } do_mount_devfs() { - mount -t devfs devfs /dev + mount -o noatime -t devfs devfs /dev } do_mount_hotplug() { - mount -t tmpfs -o mode=0755,size=512K tmpfs /dev + mount -t tmpfs -o noatime,mode=0755,size=512K tmpfs /dev } do_mount_udev() { - mount -n -t tmpfs -o mode=0755 udev /dev + mount -n -t tmpfs -o noatime,mode=0755 udev /dev } choose_device_fs() { diff --git a/package/base-files/files/lib/preinit/40_mount_devpts b/package/base-files/files/lib/preinit/40_mount_devpts index b75d692878..b55a7f2e8e 100644 --- a/package/base-files/files/lib/preinit/40_mount_devpts +++ b/package/base-files/files/lib/preinit/40_mount_devpts @@ -7,7 +7,7 @@ init_devpts() { } do_mount_devpts() { - mount -t devpts devpts /dev/pts + mount -o noatime -t devpts devpts /dev/pts } boot_hook_add preinit_essential init_devpts diff --git a/package/base-files/files/lib/preinit/40_mount_jffs2 b/package/base-files/files/lib/preinit/40_mount_jffs2 index 00f45a8908..ded785ed58 100644 --- a/package/base-files/files/lib/preinit/40_mount_jffs2 +++ b/package/base-files/files/lib/preinit/40_mount_jffs2 @@ -4,7 +4,7 @@ find_mount_jffs2() { mkdir -p /tmp/overlay - mount "$(find_mtd_part rootfs_data)" /tmp/overlay -t jffs2 + mount -o noatime -t jffs2 "$(find_mtd_part rootfs_data)" /tmp/overlay mtd -qq unlock rootfs_data } diff --git a/package/base-files/files/lib/preinit/70_pivot_jffs2_root b/package/base-files/files/lib/preinit/70_pivot_jffs2_root index 821bfb14f3..b76f111ca3 100644 --- a/package/base-files/files/lib/preinit/70_pivot_jffs2_root +++ b/package/base-files/files/lib/preinit/70_pivot_jffs2_root @@ -5,7 +5,7 @@ rootfs_pivot() { check_skip || jffs2_not_mounted || { echo "switching to jffs2" - mount -o move /tmp/overlay /overlay 2>&- + mount -o noatime,move /tmp/overlay /overlay 2>&- fopivot /overlay /rom && pi_mount_skip_next=true } } diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh index e6de34849a..e796c7bacd 100644 --- a/package/base-files/files/lib/upgrade/common.sh +++ b/package/base-files/files/lib/upgrade/common.sh @@ -36,16 +36,16 @@ install_bin() { # [ ... ] pivot() { # mount | grep "on $1 type" 2>&- 1>&- || mount -o bind $1 $1 mkdir -p $1$2 $1/proc $1/sys $1/dev $1/tmp $1/overlay && \ - mount -o move /proc $1/proc && \ + mount -o noatime,move /proc $1/proc && \ pivot_root $1 $1$2 || { umount $1 $1 return 1 } - mount -o move $2/sys /sys - mount -o move $2/dev /dev - mount -o move $2/tmp /tmp - mount -o move $2/overlay /overlay 2>&- + mount -o noatime,move $2/sys /sys + mount -o noatime,move $2/dev /dev + mount -o noatime,move $2/tmp /tmp + mount -o noatime,move $2/overlay /overlay 2>&- return 0 } @@ -71,7 +71,7 @@ run_ramfs() { # [...] umount -l /mnt grep /overlay /proc/mounts > /dev/null && { - mount -o remount,ro /overlay + mount -o noatime,remount,ro /overlay umount -l /overlay } diff --git a/package/base-files/files/sbin/firstboot b/package/base-files/files/sbin/firstboot index 4da299189e..8fbd499902 100755 --- a/package/base-files/files/sbin/firstboot +++ b/package/base-files/files/sbin/firstboot @@ -27,7 +27,7 @@ if [ "${0##*/}" = "firstboot" ]; then boot_run_hook jffs2reset else mtd erase "$partname" - mount "$mtdpart" /overlay -t jffs2 + mount -o noatime "$mtdpart" /overlay -t jffs2 fopivot /overlay /rom 1 fi fi diff --git a/target/linux/brcm47xx/base-files/lib/preinit/15_mount_proc_brcm b/target/linux/brcm47xx/base-files/lib/preinit/15_mount_proc_brcm index 923c98fd49..4ca445623c 100644 --- a/target/linux/brcm47xx/base-files/lib/preinit/15_mount_proc_brcm +++ b/target/linux/brcm47xx/base-files/lib/preinit/15_mount_proc_brcm @@ -1,5 +1,5 @@ #!/bin/sh do_mount_procfs() { - mount none /proc -t proc + mount -o noatime none /proc -t proc } diff --git a/target/linux/generic/base-files/init b/target/linux/generic/base-files/init index 5e4fbaec36..470576156b 100755 --- a/target/linux/generic/base-files/init +++ b/target/linux/generic/base-files/init @@ -9,14 +9,14 @@ set_state init echo "- init -" [ -n "$SWITCH_ROOT_TMPFS" ] && { - mount none /mnt -t tmpfs + mount -o noatime none /mnt -t tmpfs ( cd /; find -xdev -type d ) | ( cd /mnt; xargs mkdir -p ) find / \! -type d -xdev | tar -cT /proc/self/fd/0 | tar -xC /mnt mkdir /mnt/proc /mnt/dev /mnt/tmp /mnt/sys - mount -o move /proc /mnt/proc - mount -o move /dev /mnt/dev - mount -o move /tmp /mnt/tmp - mount -o move /sys /mnt/sys + mount -o noatime,move /proc /mnt/proc + mount -o noatime,move /dev /mnt/dev + mount -o noatime,move /tmp /mnt/tmp + mount -o noatime,move /sys /mnt/sys rm -rf /proc /dev /tmp /sys exec switch_root -c /dev/console /mnt /sbin/init } @@ -60,7 +60,7 @@ done COUNTER=0 while [ $COUNTER -lt 10 ]; do sleep 1 - mount $rootfs /mnt + mount -o noatime $rootfs /mnt [ $? -eq "0" ] && let COUNTER=100; let COUNTER=COUNTER+1 done @@ -84,12 +84,12 @@ done unset rootfs -mount -o move /proc /mnt/proc -mount -o move /dev /mnt/dev -mount -o move /dev/pts /mnt/dev/pts -mount -o move /tmp /mnt/tmp -mount -o move /sys /mnt/sys -mount none /tmp -t tmpfs +mount -o noatime,move /proc /mnt/proc +mount -o noatime,move /dev /mnt/dev +mount -o noatime,move /dev/pts /mnt/dev/pts +mount -o noatime,move /tmp /mnt/tmp +mount -o noatime,move /sys /mnt/sys +mount -o noatime none /tmp -t tmpfs killall -q hotplug2 exec switch_root -c /dev/console /mnt /sbin/init diff --git a/target/linux/x86/base-files/lib/preinit/15_essential_fs_x86 b/target/linux/x86/base-files/lib/preinit/15_essential_fs_x86 index ba22849d1e..5d5453093f 100644 --- a/target/linux/x86/base-files/lib/preinit/15_essential_fs_x86 +++ b/target/linux/x86/base-files/lib/preinit/15_essential_fs_x86 @@ -3,6 +3,6 @@ # Copyright (C) 2010 Vertical Communications do_mount_procfs() { - mount -t proc none /proc + mount -o noatime -t proc none /proc } diff --git a/target/linux/x86/olpc/base-files/lib/preinit/15_essential_fs_x86 b/target/linux/x86/olpc/base-files/lib/preinit/15_essential_fs_x86 index be342433d2..e4a380fd5f 100644 --- a/target/linux/x86/olpc/base-files/lib/preinit/15_essential_fs_x86 +++ b/target/linux/x86/olpc/base-files/lib/preinit/15_essential_fs_x86 @@ -3,7 +3,5 @@ # Copyright (C) 2010 Vertical Communications do_mount_procfs() { - mount -t proc none /proc + mount -o noatime -t proc none /proc } - - diff --git a/target/linux/x86/xen_domu/base-files/lib/preinit/45_mount_xenfs b/target/linux/x86/xen_domu/base-files/lib/preinit/45_mount_xenfs index 7eb8bf7958..7b0760516e 100644 --- a/target/linux/x86/xen_domu/base-files/lib/preinit/45_mount_xenfs +++ b/target/linux/x86/xen_domu/base-files/lib/preinit/45_mount_xenfs @@ -4,7 +4,7 @@ do_mount_xenfs() { [ -f /etc/modules.d/??-xenfs ] && { insmod $(cat /etc/modules.d/??-xenfs) - mount none /proc/xen -t xenfs + mount -o noatime none /proc/xen -t xenfs } }