aboutsummaryrefslogtreecommitdiff
path: root/tests/len2elen.sh
blob: e10127780d34b007459ecdb529a190b139b251cd (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=0

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