summaryrefslogtreecommitdiff
path: root/package/block-mount/files/block.sh
diff options
context:
space:
mode:
authorjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>2011-06-19 18:15:14 +0000
committerjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>2011-06-19 18:15:14 +0000
commit0efc8cde24464dd4ef4ab8164c4e6b659980180a (patch)
treeeee03ea6d09d27a0b4cb5cd781e8169a17fed3ed /package/block-mount/files/block.sh
parent8738d0666a79f3f047ed4266bc0ce52732687d7c (diff)
[package] block-mount: remove explicit lock waits, solves some potential race conditions
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@27226 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/block-mount/files/block.sh')
-rw-r--r--package/block-mount/files/block.sh36
1 files changed, 16 insertions, 20 deletions
diff --git a/package/block-mount/files/block.sh b/package/block-mount/files/block.sh
index 72d6c3ab3c..80f74b210b 100644
--- a/package/block-mount/files/block.sh
+++ b/package/block-mount/files/block.sh
@@ -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() {