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

Previous Next

Package: coreutils;

Reported by: Alex <me <at> rakul.info>

Date: Sat, 11 Jan 2020 18:17:01 UTC

Severity: normal

Tags: notabug

Done: Bernhard Voelker <mail <at> bernhard-voelker.de>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 39092 in the body.
You can then email your comments to 39092 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#39092; Package coreutils. (Sat, 11 Jan 2020 18:17:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Alex <me <at> rakul.info>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Sat, 11 Jan 2020 18:17:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Alex <me <at> rakul.info>
To: bug-coreutils <at> gnu.org
Subject: Bug in coreutils "du"? - ignores files when both a file and a hard
 link is given
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.





Information forwarded to bug-coreutils <at> gnu.org:
bug#39092; Package coreutils. (Sun, 12 Jan 2020 15:12:01 GMT) Full text and rfc822 format available.

Message #8 received at 39092 <at> debbugs.gnu.org (full text, mbox):

From: Bernhard Voelker <mail <at> bernhard-voelker.de>
To: 39092 <at> debbugs.gnu.org
Subject: Re: bug#39092: Bug in coreutils "du"? - ignores files when both a
 file and a hard link is given
Date: Sun, 12 Jan 2020 16:11:42 +0100
tag 39092 notabug
close 39092
stop

I had to take out your email address to be able to reply to this issue:

  An error occurred while sending mail. The mail server responded:
  Requested action not taken: mailbox unavailable
  invalid DNS MX or A/AAAA resource record.
  Please check the message recipient "me <at> rakul.info" and try again.

On 2020-01-11 18:23, Alex wrote:
> 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.

du(1) should count the actual disc usage, and hard links do not
add more to that, so that was actually a bug fix back in coreutils-8.6:

  https://git.sv.gnu.org/cgit/coreutils.git/commit/?id=efe53cc72b59

Discussion starts here:
  https://bugs.gnu.org/6557
  https://lists.gnu.org/r/bug-coreutils/2010-07/msg00015.html

This is intended behavior, and also documented in the Texinfo manual:

  https://www.gnu.org/software/coreutils/du

  If two or more hard links point to the same file, only one of the
  hard links is counted. The file argument order affects which links
  are counted, and changing the argument order may change the numbers
  and entries that du outputs.

I suggest to use the following option to make du(1) also count hard
links if needed:

  ‘-l’
  ‘--count-links’
    Count the size of all files, even if they have appeared already (as a hard link).

As such, I'm hereby marking this as "not-a-bug", and close the issue in
out bug tracker.  However, the discussion about this can continue here,
of course.

Have a nice day,
Berny




Added tag(s) notabug. Request was from Bernhard Voelker <mail <at> bernhard-voelker.de> to control <at> debbugs.gnu.org. (Sun, 12 Jan 2020 15:12:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 39092 <at> debbugs.gnu.org and Alex <me <at> rakul.info> Request was from Bernhard Voelker <mail <at> bernhard-voelker.de> to control <at> debbugs.gnu.org. (Sun, 12 Jan 2020 15:12:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 10 Feb 2020 12:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 68 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.