aboutsummaryrefslogtreecommitdiff
path: root/tests/len2elen.sh
blob: 86f21199b473e38f2d403894d5cf1e88e24e5b84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash -eu
#
# Check plaintext file name length -> encrypted file name length relation
#
# Part of the gocryptfs test suite
# https://nuetzlich.net/gocryptfs/

NAME="x"
LEN=1

if [[ ! -f a/gocryptfs.conf ]] ; then
	echo "fatal: must have gocryptfs dir 'a' mounted at 'b'"
	exit 1
fi
if ! mountpoint b > /dev/null ; then
	echo "fatal: must have gocryptfs dir 'a' mounted at 'b'"
	exit 1
fi

rm -f b/*

while [[ $LEN -le 255 ]]; do
	touch b/$NAME || break
	ELEN=$(ls a | wc -L)
	echo $LEN $ELEN
	rm b/$NAME
	NAME="${NAME}x"
	LEN=${#NAME}
done