Subject: bug#39092: Bug in coreutils "du"? - ignores files when both a file and a hard link is given

From: Alex <[email-masked]>
Date: Sat, 11 Jan 2020 20:23:59 +0300

Hi guys,

I noticed that when I explicitly specify a file and a hardlink to that 
file as du's command line arguments it ignores both of them. Here 
"kernel", "initramfs" and "System.map" are hardlinks to 
kernel-genkernel-x86_64-5.4.2-gentoo, 
initramfs-genkernel-x86_64-5.4.2-gentoo and System.map-5.4.10-gentoo-x86_64.

19:56:45 [0] ~ >ls -la /boot/
total 72281
drwxr-xr-x  5 root root     1024 Jan 11 19:49 .
drwxr-xr-x 22 root root     4096 Dec  7 21:00 ..
-rw-r--r--  1 root root        0 Jan  8 23:58 .e.mount
-rw-r--r--  1 root root        0 Jan  8 23:58 .keep
-rw-r--r--  2 root root  3456397 Jan  9 21:48 System.map
-rw-r--r--  1 root root  3474911 Dec  6 20:22 System.map-5.3.5-gentoo-x86_64
-rw-r--r--  1 root root  3473259 Jan 11 19:49 
System.map-5.4.10-gentoo-x86_64
-rw-r--r--  2 root root  3456397 Jan  9 21:48 
System.map-genkernel-x86_64-5.4.2-gentoo
drwxr-xr-x  2 root root     1024 Apr 29  2019 efi
drwxr-xr-x  7 root root     1024 Jan  9 22:50 grub
-rw-r--r--  2 root root  8196820 Jan  9 22:15 initramfs
-rw-r--r--  1 root root 16531780 Oct  9 21:35 
initramfs-5.3.5-gentoo-x86_64.img
-rw-r--r--  2 root root  8196820 Jan  9 22:15 
initramfs-genkernel-x86_64-5.4.2-gentoo
-rw-r--r--  2 root root  6804640 Jan  9 21:48 kernel
-rw-r--r--  2 root root  6804640 Jan  9 21:48 
kernel-genkernel-x86_64-5.4.2-gentoo
drwx------  2 root root    12288 Apr 29  2019 lost+found
-rw-r--r--  1 root root  6759584 Dec  6 20:22 vmlinuz-5.3.5-gentoo-x86_64
-rw-r--r--  1 root root  6829216 Jan 11 19:49 vmlinuz-5.4.10-gentoo-x86_64

As you can see they are missing from du output:

19:56:48 [0] ~ >sudo du -hs /boot/System.map 
/boot/System.map-5.3.5-gentoo-x86_64 
/boot/System.map-genkernel-x86_64-5.4.2-gentoo /boot/efi /boot/grub 
/boot/initramfs /boot/initramfs-5.3.5-gentoo-x86_64.img 
/boot/initramfs-genkernel-x86_64-5.4.2-gentoo /boot/kernel 
/boot/kernel-genkernel-x86_64-5.4.2-gentoo /boot/lost+found 
/boot/vmlinuz-5.3.5-gentoo-x86_64

3.3M    /boot/System.map
3.4M    /boot/System.map-5.3.5-gentoo-x86_64
1.0K    /boot/efi
9.7M    /boot/grub
7.9M    /boot/initramfs
16M    /boot/initramfs-5.3.5-gentoo-x86_64.img
6.5M    /boot/kernel
12K    /boot/lost+found
6.5M    /boot/vmlinuz-5.3.5-gentoo-x86_64

When I remove the hard link from the arguments the corresponding file 
appears in the output:

19:56:51 [0] ~ >sudo du -hs /boot/System.map 
/boot/System.map-5.3.5-gentoo-x86_64 
/boot/System.map-genkernel-x86_64-5.4.2-gentoo /boot/efi /boot/grub 
/boot/initramfs /boot/initramfs-5.3.5-gentoo-x86_64.img 
/boot/initramfs-genkernel-x86_64-5.4.2-gentoo 
/boot/kernel-genkernel-x86_64-5.4.2-gentoo /boot/lost+found 
/boot/vmlinuz-5.3.5-gentoo-x86_64

3.3M    /boot/System.map
3.4M    /boot/System.map-5.3.5-gentoo-x86_64
1.0K    /boot/efi
9.7M    /boot/grub
7.9M    /boot/initramfs
16M    /boot/initramfs-5.3.5-gentoo-x86_64.img
6.5M    /boot/kernel-genkernel-x86_64-5.4.2-gentoo
12K    /boot/lost+found
6.5M    /boot/vmlinuz-5.3.5-gentoo-x86_64
19:57:28 [0] ~ >

Cheers,
Alex.