Changeset 27226


Ignore:
Timestamp:
2011-06-19T20:15:14+02:00 (7 years ago)
Author:
jow
Message:

[package] block-mount: remove explicit lock waits, solves some potential race conditions

Location:
trunk/package/block-mount
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/package/block-mount/Makefile

    r27139 r27226  
    1010PKG_NAME:=block-mount 
    1111PKG_VERSION:=0.2.0 
    12 PKG_RELEASE:=5 
     12PKG_RELEASE:=6 
    1313 
    1414include $(INCLUDE_DIR)/package.mk 
  • trunk/package/block-mount/files/block.sh

    r21987 r27226  
    120120 
    121121        local fstabnew 
    122          
     122 
    123123        mkdir -p /var/lock 
    124         lock -w /var/lock/fstab.lck && { 
    125                 lock /var/lock/fstab.lck 
    126                 fstabnew="$(mktemp -t '.fstab.XXXXXXXX')" 
    127                 cat /tmp/fstab | grep -E -v "^$device[[:blank:]]" >>"$fstabnew" 
    128                 [ "$enabled" -eq 1 ] && echo "$device   none    swap    sw      0       0" >> "$fstabnew" 
    129                 cat "$fstabnew" >/tmp/fstab 
    130                 rm -f $fstabnew 
    131                 lock -u /var/lock/fstab.lck 
    132         } 
     124        lock /var/lock/fstab.lck 
     125        fstabnew="$(mktemp -t '.fstab.XXXXXXXX')" 
     126        cat /tmp/fstab | grep -E -v "^$device[[:blank:]]" >>"$fstabnew" 
     127        [ "$enabled" -eq 1 ] && echo "$device   none    swap    sw      0       0" >> "$fstabnew" 
     128        cat "$fstabnew" >/tmp/fstab 
     129        rm -f $fstabnew 
     130        lock -u /var/lock/fstab.lck 
    133131} 
    134132 
     
    145143 
    146144        local fstabnew 
    147          
     145 
    148146        mkdir -p /var/lock 
    149         lock -w /var/lock/fstab.lck && { 
    150                 lock /var/lock/fstab.lck 
    151                 fstabnew="$(mktemp -t '.fstab.XXXXXXXX')" 
    152                 cat /tmp/fstab | grep -E -v "^$device[[:blank:]]" | grep -v "$target" >>"$fstabnew" 
    153                 echo "$device   $target $fstype $options        0       0" >>"$fstabnew" 
    154                 cat "$fstabnew" >/tmp/fstab              
    155                 rm -f $fstabnew 
    156                 lock -u /var/lock/fstab.lck 
    157         } 
     147        lock /var/lock/fstab.lck 
     148        fstabnew="$(mktemp -t '.fstab.XXXXXXXX')" 
     149        cat /tmp/fstab | grep -E -v "^$device[[:blank:]]" | grep -v "$target" >>"$fstabnew" 
     150        echo "$device   $target $fstype $options        0       0" >>"$fstabnew" 
     151        cat "$fstabnew" >/tmp/fstab              
     152        rm -f $fstabnew 
     153        lock -u /var/lock/fstab.lck 
    158154} 
    159155 
  • trunk/package/block-mount/files/fstab.init

    r26312 r27226  
    6767        config_load fstab 
    6868        mkdir -p /var/lock 
    69         lock -w /var/lock/fstab.lck && { 
    70                 lock /var/lock/fstab.lck 
    71                 [ -e /tmp/fstab ] || {  
    72                         echo '# WARNING: this is an auto generated file, please use uci to set defined filesystems' > /tmp/fstab 
    73                 } 
    74                 lock -u /var/lock/fstab.lck 
     69        lock /var/lock/fstab.lck 
     70        [ -e /tmp/fstab ] || { 
     71                echo '# WARNING: this is an auto generated file, please use uci to set defined filesystems' > /tmp/fstab 
    7572        } 
     73        lock -u /var/lock/fstab.lck 
    7674        config_foreach do_swapon swap 
    7775        config_foreach do_mount mount 
Note: See TracChangeset for help on using the changeset viewer.