mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
stat: fix determination of max name length on BSD systems
We only use one of statfs or statvfs for `stat -f` and on the BSDs we use statfs which doesn't have the f_namelen member. However on OpenBSD and later FreeBSD systems statfs does provide f_namemax, so use that. * NEWS: Mention the improvement for OpenBSD and FreeBSD. * m4/stat-prog.m4: Check for f_namemax in the statfs struct. * src/stat.c: Return '?' rather than '*' when we can't determine the max length of the file system. * tests/ln/sf-1.sh: This test was failing on all BSDs due to '*' being returned for the max length which caused the test to attempt to create 1Mi+1 names. The test now uses a short name when we can't determine the max name length to use. Reported by Assaf Gordon on various BSD based systems.
This commit is contained in:
@@ -33,12 +33,10 @@ esac
|
||||
|
||||
# Ensure we replace symlinks that don't or can't link to an existing target.
|
||||
# coreutils-8.22 would fail to replace {ENOTDIR,ELOOP,ENAMETOOLONG}_link below.
|
||||
name_max=$(stat -f -c %l .) || skip_ 'Error determining NAME_MAX'
|
||||
# Apply a limit since AIX returns 2^32-1 which would trigger resource issues.
|
||||
name_limit=$((1024*1024))
|
||||
test "$name_max" -lt "$name_limit" || name_max="$name_limit"
|
||||
# We apply a limit since AIX returns 2^32-1 which would trigger resource issues.
|
||||
name_max=$(stat -f -c %l .) && test "$name_max" -lt $((1024*1024)) ||
|
||||
name_max=1 # skip this portion of the test
|
||||
name_max_plus1=$(expr $name_max + 1)
|
||||
test $name_max_plus1 -gt 1 || skip_ 'Error determining NAME_MAX'
|
||||
long_name=$(printf '%0*d' $name_max_plus1 0)
|
||||
|
||||
for f in '' f; do
|
||||
|
||||
Reference in New Issue
Block a user