block-mount: remove explicit lock waits, solves some potential race conditions
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 19 Jun 2011 18:15:14 +0000 (18:15 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 19 Jun 2011 18:15:14 +0000 (18:15 +0000)
SVN-Revision: 27226

package/block-mount/Makefile
package/block-mount/files/block.sh
package/block-mount/files/fstab.init

index c2c9d33f134e53eca6057290a5785d90cfb5cd62..657f727bb9d0bc913c9b1cb10658d0a63ad444ed 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=block-mount
 PKG_VERSION:=0.2.0
-PKG_RELEASE:=5
+PKG_RELEASE:=6
 
 include $(INCLUDE_DIR)/package.mk
 
index 72d6c3ab3c77cf637cc8bf7ccb96b2694bebba51..80f74b210b2f0d271340dd188ba7f074e28cc126 100644 (file)
@@ -119,17 +119,15 @@ config_create_swap_fstab_entry() {
        [ -n "$device" ] || return 0
 
        local fstabnew
-       
+
        mkdir -p /var/lock
-       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
-       }
+       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() {
@@ -144,17 +142,15 @@ config_create_mount_fstab_entry() {
        [ -n "$device" ] || return 0
 
        local fstabnew
-       
+
        mkdir -p /var/lock
-       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
-       }
+       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() {
index aba50ba93ab1e8d2791a1fa3f2b37e7452b818c4..f54051ebb7f06c0ceebf8f09a77007778ff51b21 100644 (file)
@@ -66,13 +66,11 @@ start() {
 
        config_load fstab
        mkdir -p /var/lock
-       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
+       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