2 # Ensure that hard-linked files are counted (and listed) only once.
3 # Likewise for excluded directories.
4 # Ensure that hard links _are_ listed twice when using --count-links.
6 # Copyright (C) 2003, 2006-2008 Free Software Foundation, Inc.
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 if test "$VERBOSE" = yes; then
29 ( cd dir
&& { echo non-empty
> f1
; ln f1 f2
; echo non-empty
> sub
/F
; } )
33 # Note that for this first test, we transform f1 or f2
34 # (whichever name we find first) to f_. That is necessary because,
35 # depending on the type of file system, du could encounter either of those
36 # two hard-linked files first, thus listing that one and not the other.
37 du
-a --exclude=sub dir \
38 |
sed 's/^[0-9][0-9]* //' |
sed 's/f[12]/f_/' > out || fail
=1
40 du
-a --exclude=sub
--count-links dir \
41 |
sed 's/^[0-9][0-9]* //' |
sort -r >> out || fail
=1
51 compare out exp || fail
=1