#!/bin/sh # Ensure that d_ino (from ls -di) and st_ino (from stat --format=%i) match. if test "$VERBOSE" = yes; then set -x ls --version fi . $srcdir/../envvar-check pwd=`pwd` t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0 trap '(exit $?); exit $?' 1 2 13 15 framework_failure=0 mkdir -p $tmp || framework_failure=1 cd $tmp || framework_failure=1 if test $framework_failure = 1; then echo "$0: failure in testing framework" 1>&2 (exit 1); exit 1 fi fail=0 root_dev_ino=`stat --format=%d-%i /` t=`pwd` while :; do ls -i1 "$t" > tmp if test $? = 0; then # Extract the inode number from the first line of output from ls -i1. # This value comes from dirent.d_ino, on systems with d_ino support. d_ino=`sed -n '1s/^ *\([0-9][0-9]*\) .*/\1/p;q' tmp` # Extract the name of the corresponding directory entry. file=`sed -n '1s/^ *[0-9][0-9]* *//p;q' tmp` # Get its inode number (stat.st_ino) via stat(1)'s call to lstat. st_ino=`stat --format=%i "$t/$file"` # Make sure that they are the same. # We know from experience that there may be mismatches on some # buggy file systems, at mount points. if test "$d_ino" != "$st_ino"; then echo "$0: test failed: $t/$file: d_ino($d_ino) != st_ino($st_ino)" 1>&2 echo "$0: This may indicate a flaw in your kernel or" \ "file system implementation." 1>&2 echo "$0: This flaw won't impact coreutils, but it may well" "affect other tools," echo "$0: so you should report it to your operating system vendor." 1>&2 # This test fails too often, and we don't want to be distracted # with reports, since the code that could be affected by the losing # behavior (pwd and getcwd) works around any mismatch. # So do continue to issue the warning, but don't count it as a # real failure. # fail=1 break fi fi t=`(cd "$t/.."; pwd)` dev_ino=`stat --format=%d-%i "$t"` test $dev_ino = $root_dev_ino && break done (exit $fail); exit $fail