2 # ensure that ls -i works also for mount points
4 # Copyright (C) 2009 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 3 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, see <http://www.gnu.org/licenses/>.
19 if test "$VERBOSE" = yes; then
27 mount_points=$(df --local -P 2>&1 | sed -n 's,.*[0-9]% \(/.\),\1,p')
28 test -z "$mount_points" && skip_test_ "this test requires a non-root mount point"
30 # Given e.g., /dev/shm, produce the list of GNU ls options that
31 # let us list just that entry using readdir data from its parent:
32 # ls -i -I '[^s]*' -I 's[^h]*' -I 'sh[^m]*' -I 'shm?*' -I '.?*' \
38 opts="-I '.?*' -I '$name?*'"
40 glob=$(echo "$name"|sed 's/\(.*\)\(.\)$/\1[^\2]*/')
41 opts="$opts -I '$glob'"
42 name=$(echo "$name"|sed 's/.$//')
43 test -z "$name" && break
44 glob=$(echo "$name"|sed 's/./?/g')
45 opts="$opts -I '$glob'"
53 base=$(basename $mount_point)
55 .*) skip_test_ 'mount point component starts with "."' ;;
56 *[*?]*) skip_test_ 'mount point component contains "?" or "*"' ;;
58 opts=$(ls_ignore_options "$base")
59 parent_dir=$(dirname $mount_point)
60 eval "ls -i $opts $parent_dir" | sed 's/ .*//'
63 # FIXME: use a timeout, in case stat'ing mount points takes too long.
65 for dir in $mount_points; do
66 readdir_inode=$(inode_via_readdir $dir)
67 stat_inode=$(env stat --format=%i $dir)
68 test "$readdir_inode" = "$stat_inode" || fail=1