2 # ensure that ls -i works also for mount points
4 # Copyright (C) 2009-2012 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 .
"${srcdir=.}/init.sh"; path_prepend_ ..
/src
22 # We use --local here so as to not activate
23 # potentially very many remote mounts.
24 mount_points
=$
(df
--local -P 2>&1 |
sed -n 's,.*[0-9]% \(/.\),\1,p')
25 test -z "$mount_points" &&
26 skip_
"this test requires a non-root mount point"
28 # Given e.g., /dev/shm, produce the list of GNU ls options that
29 # let us list just that entry using readdir data from its parent:
30 # ls -i -I '[^s]*' -I 's[^h]*' -I 'sh[^m]*' -I 'shm?*' -I '.?*' \
36 opts
="-I '.?*' -I '$name?*'"
38 glob
=$
(echo "$name"|
sed 's/\(.*\)\(.\)$/\1[^\2]*/')
39 opts
="$opts -I '$glob'"
40 name
=$
(echo "$name"|
sed 's/.$//')
41 test -z "$name" && break
42 glob
=$
(echo "$name"|
sed 's/./?/g')
43 opts
="$opts -I '$glob'"
51 base
=$
(basename $mount_point)
53 .
*) skip_
'mount point component starts with "."' ;;
54 *[*?
]*) skip_
'mount point component contains "?" or "*"' ;;
56 opts
=$
(ls_ignore_options
"$base")
57 parent_dir
=$
(dirname $mount_point)
58 eval "ls -i $opts $parent_dir" |
sed 's/ .*//'
61 for dir
in $mount_points; do
62 readdir_inode
=$
(inode_via_readdir
$dir)
63 test $?
= 77 && continue
64 stat_inode
=$
(timeout
1 stat
--format=%i
$dir)
65 # If stat fails or says the inode is 0, skip $dir.
66 case $stat_inode in 0|
'') continue;; esac
67 test "$readdir_inode" = "$stat_inode" || fail
=1