Commit 5a1065c3 authored by Michael Shigorin's avatar Michael Shigorin

bin/mktmpdir: check for filesystem mount options

As was found out by Vladimir Karpinsky (thanks for patience!), the autochosen directory might still have too restrictive mount options -- nodev and/or noexec. Hopefully the diags are a bit better and faster by now.
parent 87bfa3f6
......@@ -31,6 +31,12 @@ contemplate_dirs()
| uniq # _not_ sort -u
}
# hasher emits no meaningful errors regarding those, sigh
check_options()
{
! egrep -q "^$1 $2 .*no(dev|exec)" /proc/mounts
}
# pick existing, writeable, >256M free space dirs
# rank them wrt type: tmpfs > realfs > rootfs
choose_tmpdir() {
......@@ -41,6 +47,7 @@ choose_tmpdir() {
done \
| sort -unk6 \
| while read dir dev fstype size used free percent mnt; do
check_options "$dev" "$mnt" || continue
[ "$free" -gt "$MINSIZE" ] || continue
[ "$fstype" = "tmpfs" ] && { echo "2 $dir $free"; continue; }
[ "$mnt" = "/" ] && { echo "0 $dir $free"; continue; }
......@@ -54,12 +61,21 @@ choose_tmpdir() {
# bringing it all together
TMPDIRS="`contemplate_dirs $DIRS`"
if [ -z "$TMPDIRS" ]; then
echo "error: no suitable directories found" >&2
echo "error: no suitable directories found;" >&2
echo "please check docs, filesystem and hasher setup" >&2
echo "(mount enough tmpfs into /tmp or fix hasher-priv prefix?)" >&2
exit 1
fi
TEMP="`choose_tmpdir $TMPDIRS`"
if [ -z "$TEMP" ]; then
echo "error: no suitable directories found;" >&2
echo "please check hasher docs and filesystem setup" >&2
echo "(nodev and/or noexec on an otherwise suitable filesystem?)" >&2
exit 1
fi
DIR="`choose_tmpdir $TMPDIRS`/`dirname "$1"`"
DIR="$TEMP/`dirname "$1"`"
NAME="`basename "${1:-tmpdir}"`"
mkdir -p "$DIR" # in case $1 contains slash(es)
mktemp -d "$NAME.XXXXXXX" --tmpdir="${DIR%/.}"
......@@ -19,6 +19,10 @@ else \
fi; )
endif
ifeq (,$(BUILDDIR))
$(error suitable BUILDDIR unavailable)
endif
# even smart caching only hurts when every build goes from scratch
NO_CACHE ?= 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment