unlock_dir()
(
  set -e
  cd "$workdir"
  [[ -e dirlist.txt ]] && return 0

  find "$prefix" -type d \
    -exec stat -c "chmod %a '%n'" "{}" \; \
    -exec chmod u+w "{}" \; \
    > dirlist.txt
)

lock_dir()
(
  set -e
  cd "$workdir"

  source dirlist.txt
  rm -f dirlist.txt
)
