2 # Ensure that d_ino (from ls -di) and st_ino (from stat --format=%i) match.
4 # Copyright (C) 2006 Free Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 if test "$VERBOSE" = yes; then
26 . $srcdir/../envvar-check
29 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
30 trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
31 trap '(exit $?); exit $?' 1 2 13 15
34 mkdir -p $tmp || framework_failure=1
35 cd $tmp || framework_failure=1
37 if test $framework_failure = 1; then
38 echo "$0: failure in testing framework" 1>&2
44 root_dev_ino=`stat --format=%d-%i /`
49 # Extract the inode number from the first line of output from ls -i1.
50 # This value comes from dirent.d_ino, on systems with d_ino support.
51 d_ino=`sed -n '1s/^ *\([0-9][0-9]*\) .*/\1/p;q' tmp`
53 # Extract the name of the corresponding directory entry.
54 file=`sed -n '1s/^ *[0-9][0-9]* *//p;q' tmp`
56 # Get its inode number (stat.st_ino) via stat(1)'s call to lstat.
57 st_ino=`stat --format=%i "$t/$file"`
59 # Make sure that they are the same.
60 # We know from experience that there may be mismatches on some
61 # buggy file systems, at mount points.
62 if test "$d_ino" != "$st_ino"; then
63 echo "$0: test failed: $t/$file: d_ino($d_ino) != st_ino($st_ino)
64 This may indicate a flaw in your kernel or file system implementation.
65 The flaw isn't serious for coreutils, but it might break other tools,
66 so you should report it to your operating system vendor." 1>&2
68 # This test fails too often, and we don't want to be distracted
69 # with reports, since the code that could be affected by the losing
70 # behavior (pwd and getcwd) works around any mismatch.
71 # So do continue to issue the warning, but don't count it as a
79 dev_ino=`stat --format=%d-%i "$t"`
80 test $dev_ino = $root_dev_ino && break
83 (exit $fail); exit $fail