Skip to content

Commit

Permalink
zed-functions.sh: zed_lock(): don't truncate lock
Browse files Browse the repository at this point in the history
By appending instead of truncating, we can lock on any file (with write
permissions) instead of only dedicated lock files, since the locking
process itself no longer alters the file in any way

Reviewed-by: Tony Hutter <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ahelenia Ziemiańska <[email protected]>
Closes #12042
  • Loading branch information
nabijaczleweli authored and behlendorf committed Jun 8, 2021
1 parent 75b4cbf commit b828cf1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/zed/zed.d/zed-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ zed_lock()

# Obtain a lock on the file bound to the given file descriptor.
#
eval "exec ${fd}> '${lockfile}'"
eval "exec ${fd}>> '${lockfile}'"
if ! err="$(flock --exclusive "${fd}" 2>&1)"; then
zed_log_err "failed to lock \"${lockfile}\": ${err}"
fi
Expand Down

0 comments on commit b828cf1

Please sign in to comment.