commit bd2997954d66a16334182c635876826ee3d65785
parent 01d30d0c9fd53de3a47ed78c6e34001ac70df446
Author: Jan Pobrislo <ccx@webprojekty.cz>
Date: Tue, 15 Dec 2015 11:18:21 +0100
fix lockfile handling
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sbin/snap.lvm2 b/sbin/snap.lvm2
@@ -13,8 +13,8 @@ export SNAPSHOT
LOCKDIR=/var/lock/snaprep
test -d "$LOCKDIR" || mkdir -p "$LOCKDIR" || exit $?
LOCKFILE="$LOCKDIR/lvm2.${SRC//\//-}"
-touch "$LOCKFILE" || exit $?
-flock -n 0 <"$LOCKFILE" || exit $?
+exec 3> "$LOCKFILE" || exit $?
+flock -n 3 || exit $?
if test -b "$S_DEV"; then
echo >&2 "removing stale snapshot"
if grep -qF "$S_DEV" /proc/mounts; then # TODO match only on start of line