From e24db8edb49abd52eff3b1bc8fb51fd1f0cbb980 Mon Sep 17 00:00:00 2001 From: jow Date: Wed, 13 Oct 2010 19:21:41 +0000 Subject: [PATCH] [backfire] merge r21987, r22002, r22147, r22148 and r22150 git-svn-id: svn://svn.openwrt.org/openwrt/branches/backfire@23429 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/block-mount/files/block.sh | 34 ++++++++++++++++------------ package/block-mount/files/fsck.sh | 24 +++++++++----------- package/block-mount/files/fstab.init | 13 +++++++---- package/block-mount/files/mount.sh | 4 +--- 4 files changed, 41 insertions(+), 34 deletions(-) diff --git a/package/block-mount/files/block.sh b/package/block-mount/files/block.sh index b8a473a00..72d6c3ab3 100644 --- a/package/block-mount/files/block.sh +++ b/package/block-mount/files/block.sh @@ -118,15 +118,18 @@ config_create_swap_fstab_entry() { [ -n "$device" ] || return 0 - local fstabnew="$(mktemp -t '.fstab.XXXXXXXX')" + local fstabnew mkdir -p /var/lock - lock /var/lock/fstab.lck - cat /tmp/fstab | grep -E -v "^$device[[:blank:]]" >>"$fstabnew" - [ "$enabled" -eq 1 ] && echo "$device none swap sw 0 0" >> "$fstabnew" - cat "$fstabnew" >/tmp/fstab - lock -u /var/lock/fstab.lck - rm -f $fstabnew + lock -w /var/lock/fstab.lck && { + lock /var/lock/fstab.lck + fstabnew="$(mktemp -t '.fstab.XXXXXXXX')" + cat /tmp/fstab | grep -E -v "^$device[[:blank:]]" >>"$fstabnew" + [ "$enabled" -eq 1 ] && echo "$device none swap sw 0 0" >> "$fstabnew" + cat "$fstabnew" >/tmp/fstab + rm -f $fstabnew + lock -u /var/lock/fstab.lck + } } config_create_mount_fstab_entry() { @@ -140,15 +143,18 @@ config_create_mount_fstab_entry() { [ -n "$target" ] || return 0 [ -n "$device" ] || return 0 - local fstabnew="$(mktemp -t '.fstab.XXXXXXXX')" + local fstabnew mkdir -p /var/lock - lock /var/lock/fstab.lck - cat /tmp/fstab | grep -E -v "^$device[[:blank:]]" | grep -v "$target" >>"$fstabnew" - echo "$device $target $fstype $options 0 0" >>"$fstabnew" - cat "$fstabnew" >/tmp/fstab - lock -u /var/lock/fstab.lck - rm -f $fstabnew + lock -w /var/lock/fstab.lck && { + lock /var/lock/fstab.lck + fstabnew="$(mktemp -t '.fstab.XXXXXXXX')" + cat /tmp/fstab | grep -E -v "^$device[[:blank:]]" | grep -v "$target" >>"$fstabnew" + echo "$device $target $fstype $options 0 0" >>"$fstabnew" + cat "$fstabnew" >/tmp/fstab + rm -f $fstabnew + lock -u /var/lock/fstab.lck + } } libmount_find_token() { diff --git a/package/block-mount/files/fsck.sh b/package/block-mount/files/fsck.sh index 056229a4d..3011160a4 100644 --- a/package/block-mount/files/fsck.sh +++ b/package/block-mount/files/fsck.sh @@ -12,20 +12,18 @@ libmount_fsck() { local found_fsck=0 - [ -n "$fsck_type" ] && [ "$fsck_type" != "swap" ] && { - grep -q "$device" /proc/swaps || grep -q "$device" /proc/mounts || { - [ -e "$device" ] && [ "$fsck_enabled" -eq 1 ] && { - for known_type in $libmount_known_fsck; do - if [ "$known_type" = "$fsck_fstype" ]; then - fsck_${known_type} "$device" - found_fsck=1 - break - fi - done - if [ "$found_fsck" -ne 1 ]; then - logger -t 'fstab' "Unable to check/repair $device; no known fsck for filesystem type $fstype" + grep -q "$device" /proc/swaps || grep -q "$device" /proc/mounts || { + [ -e "$device" ] && [ "$fsck_enabled" -eq 1 ] && { + for known_type in $libmount_known_fsck; do + if [ "$known_type" = "$fsck_fstype" ]; then + fsck_${known_type} "$device" + found_fsck=1 + break fi - } + done + if [ "$found_fsck" -ne 1 ]; then + logger -t 'fstab' "Unable to check/repair $device; no known fsck for filesystem type $fstype" + fi } } } diff --git a/package/block-mount/files/fstab.init b/package/block-mount/files/fstab.init index d136e906f..a3e0338f4 100644 --- a/package/block-mount/files/fstab.init +++ b/package/block-mount/files/fstab.init @@ -41,11 +41,16 @@ start() { config_load fstab mkdir -p /var/lock - lock /var/lock/fstab.lck - echo '# WARNING: this is an auto generated file, please use uci to set defined filesystems' > /etc/fstab - lock -u /var/lock/fstab.lck - config_foreach do_mount mount + lock -w /var/lock/fstab.lck && { + lock /var/lock/fstab.lck + [ -e /tmp/fstab ] || { + echo '# WARNING: this is an auto generated file, please use uci to set defined filesystems' > /tmp/fstab + } + lock -u /var/lock/fstab.lck + } config_foreach do_swapon swap + config_foreach do_mount mount + config_foreach do_swapon swap # do swap a second time so that swap on filesystems is enabled } stop() { diff --git a/package/block-mount/files/mount.sh b/package/block-mount/files/mount.sh index 96307222f..583e1a5ca 100644 --- a/package/block-mount/files/mount.sh +++ b/package/block-mount/files/mount.sh @@ -28,14 +28,13 @@ config_mount_by_section() { local is_rootfs="$9" shift local found_device="" - local fsck_type="" found_device="$(libmount_find_device_by_id "$uuid" "$label" "$device" "$cfgdevice")" if [ -n "$found_device" ]; then if [ -z "$find_rootfs" ] || [ "$find_rootfs" -eq 0 ] || [ "$is_rootfs" -eq 1 ]; then [ "$enabled_fsck" -eq 1 ] && { grep -q "$found_device" /proc/swaps || grep -q "$found_device" /proc/mounts || { - libmount_fsck "$found_device" "$fsck_type" "$enabled_fsck" + libmount_fsck "$found_device" "$fstype" "$enabled_fsck" } } @@ -72,7 +71,6 @@ config_swapon_by_section() { local label local found_device="" - local fsck_type="" found_device="$(libmount_find_device_by_id "$uuid" "$label" "$device" "$cfgdevice")"