I don't know the answer definitively, but since no one else has responded, here's my 2¢.
They are probably both right. It's just a definition of what "right" is.
Things to consider.
Is 1K equal to 1,000 or 1024? Is 1M equal to 1,000,000 or 1048576?
The answer is probably 1024 and 1048576. You see this nonsense mostly with disk sizes, not with files within filesystems.
If there are subdirectories, I would guess there is also directory overhead as well to account or not account for. This is probably negligible, and also probably not a factor.
Is the total the sum of the individual file sizes, or the total of each file's disk space usage?
A small example using a directory I have called "sparse" that contains sparse files.
Code:
[root@athlonz ~]# du -sh sparse
1.1G sparse
[root@athlonz ~]# du -sh --apparent-size sparse
3.1G sparse
[root@athlonz sparse]# ls -sl
total 1049720
16 -rwxrwxr-x 1 root root 15621 2010-09-27 22:44 ff
12 -rw-r--r-- 1 root root 9813 2010-09-27 22:44 ff.c
16 -rwxrwxr-x 1 root root 14802 2010-09-27 17:41 filefrag
12 -rw-r--r-- 1 15806 15806 9676 2010-05-13 19:00 filefrag.c
4 -rw-r--r-- 1 root root 1383 2010-09-27 22:31 hexprint.h
1049604 -rw-r--r-- 1 root root 1073741824 2010-09-27 17:46 nonsparsefile
12 -rwxrwxr-x 1 root root 8553 2010-09-23 15:55 sparse
8 -rwxrwxr-x 1 root root 8100 2010-09-23 16:05 sparse2
4 -rw-r--r-- 1 root root 1118 2010-09-23 16:05 sparse2.c
4 -rw-r--r-- 1 root root 2820 2010-09-23 15:55 sparse.c
16 -rw-r--r-- 1 root root 1073741824 2010-09-23 15:55 sparsefile
12 -rw-r--r-- 1 root root 1073741824 2010-09-23 16:05 sparsefile2
[root@athlonz sparse]# ls -sl --block-size=4096
total 262430
4 -rwxrwxr-x 1 root root 4 2010-09-27 22:44 ff
3 -rw-r--r-- 1 root root 3 2010-09-27 22:44 ff.c
4 -rwxrwxr-x 1 root root 4 2010-09-27 17:41 filefrag
3 -rw-r--r-- 1 15806 15806 3 2010-05-13 19:00 filefrag.c
1 -rw-r--r-- 1 root root 1 2010-09-27 22:31 hexprint.h
262401 -rw-r--r-- 1 root root 262144 2010-09-27 17:46 nonsparsefile
3 -rwxrwxr-x 1 root root 3 2010-09-23 15:55 sparse
2 -rwxrwxr-x 1 root root 2 2010-09-23 16:05 sparse2
1 -rw-r--r-- 1 root root 1 2010-09-23 16:05 sparse2.c
1 -rw-r--r-- 1 root root 1 2010-09-23 15:55 sparse.c
4 -rw-r--r-- 1 root root 262144 2010-09-23 15:55 sparsefile
3 -rw-r--r-- 1 root root 262144 2010-09-23 16:05 sparsefile2
If you totalled the file sizes it comes to 3,221,297,358.
If you got the properties of directory 'sparse' in Nautilus it says "Contents: 12 items, totalling 3.0 GB".
On disk it is 1.1GB. These two lines tell you a lot.
Code:
16 -rw-r--r-- 1 root root 1073741824 2010-09-23 15:55 sparsefile
12 -rw-r--r-- 1 root root 1073741824 2010-09-23 16:05 sparsefile2
Each of these files is logically 1GB, but they take up 16KB and 12KB respectively.
Since the Block Size of my filesystem is 4K, non-sparse files on disk are rounded up to a multiple of 4K; but on the other hand, if it is a sparse file, it can be smaller in size on disk than its apparent size as shown above.
So, which one is right?