diff options
author | pjd <pjd@FreeBSD.org> | 2010-08-11 16:29:12 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2010-08-11 16:29:12 +0000 |
commit | 286e5bb2273791af05c408ac70e3c75f5d595f21 (patch) | |
tree | cf736f7449e59155fda8af5d5117e991ee3b0949 | |
parent | af812168de987e4574b010e1b25ef58447386595 (diff) | |
download | FreeBSD-src-286e5bb2273791af05c408ac70e3c75f5d595f21.zip FreeBSD-src-286e5bb2273791af05c408ac70e3c75f5d595f21.tar.gz |
Instead of hardcoding {NAME_MAX} as 255 and {PATH_MAX} as 1024 obtain those from
pathconf(2) and properly generate too long file names.
This should fix ENAMETOOLONG checks on Linux.
-rw-r--r-- | tools/regression/fstest/tests/misc.sh | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/tools/regression/fstest/tests/misc.sh b/tools/regression/fstest/tests/misc.sh index 9e6da96..630abb0 100644 --- a/tools/regression/fstest/tests/misc.sh +++ b/tools/regression/fstest/tests/misc.sh @@ -2,13 +2,6 @@ ntest=1 -name253="_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_12" -name255="${name253}34" -name256="${name255}5" -path1021="${name255}/${name255}/${name255}/${name253}" -path1023="${path1021}/x" -path1024="${path1023}x" - case "${dir}" in /*) maindir="${dir}/../.." @@ -99,6 +92,52 @@ namegen() echo "fstest_`dd if=/dev/urandom bs=1k count=1 2>/dev/null | openssl md5`" } +namegen_len() +{ + len="${1}" + + name="" + while :; do + namepart="`dd if=/dev/urandom bs=64 count=1 2>/dev/null | openssl md5`" + name="${name}${namepart}" + curlen=`printf "%s" "${name}" | wc -c` + [ ${curlen} -lt ${len} ] || break + done + name=`echo "${name}" | cut -b -${len}` + printf "%s" "${name}" +} + +# POSIX: +# {NAME_MAX} +# Maximum number of bytes in a filename (not including terminating null). +namegen_max() +{ + name_max=`${fstest} pathconf . _PC_NAME_MAX` + namegen_len ${name_max} +} + +# POSIX: +# {PATH_MAX} +# Maximum number of bytes in a pathname, including the terminating null character. +dirgen_max() +{ + name_max=`${fstest} pathconf . _PC_NAME_MAX` + complen=$((name_max/2)) + path_max=`${fstest} pathconf . _PC_PATH_MAX` + # "...including the terminating null character." + path_max=$((path_max-1)) + + name="" + while :; do + name="${name}`namegen_len ${complen}`/" + curlen=`printf "%s" "${name}" | wc -c` + [ ${curlen} -lt ${path_max} ] || break + done + name=`echo "${name}" | cut -b -${path_max}` + name=`echo "${name}" | sed -E 's@/$@x@'` + printf "%s" "${name}" +} + quick_exit() { echo "1..1" |