Subject: bug#7399: du may count one file multiple times if it visible through multiple mounts

From: Evgeny Kapun <[email-masked]>
Date: Sun, 14 Nov 2010 16:16:36 +0300

Some kernels, such as Linux, permit mounting one filesystem multiple
times. This can make multiple paths refer to the same file, although
neither hard nor symbolic links are involved. In this case, du sometimes
incorrectly counts that file many times:

	$ mkdir dir1 dir2
	# mount --bind dir1 dir2
	$ dd if=/dev/urandom of=dir1/file bs=1k count=1000
	1000+0 records in
	1000+0 records out
	1024000 bytes (1.0 MB) copied, 0.179289 s, 5.7 MB/s
	$ du
	1008	./dir1
	1008	./dir2
	2020	.

As you may see, the file is counted twice, once as dir1/file and then as
dir2/file. However, if du is run with repeated argument, it's behavior
is different:

	$ du . .
	1008	./dir1
	1012	.