inconsistent results with du and multiple arguments
Can anyone explain why du (which advertises the ability to evaluate N file/dir arguments) seems to only be accurate for the first provided argument? See the following: brett@spider:/> sudo du -smxc tmp 60 tmp 60 total brett@spider:/> sudo du -smxc tmp bin 60 tmp 1 bin 60 total brett@spider:/> sudo du -smxc bin 9 bin 9 total brett@spider:/> sudo du -smxc bin tmp 9 bin 1 tmp 9 total
On Wednesday 18 June 2008, Brett Russ wrote:
Can anyone explain why du (which advertises the ability to evaluate N file/dir arguments) seems to only be accurate for the first provided argument? See the following:
brett@spider:/> sudo du -smxc tmp 60 tmp 60 total brett@spider:/> sudo du -smxc tmp bin 60 tmp 1 bin 60 total brett@spider:/> sudo du -smxc bin 9 bin 9 total brett@spider:/> sudo du -smxc bin tmp 9 bin 1 tmp 9 total
this has come up on the gnu coreutils list in the past iirc (so try searching their mail archives). i think it was one part bug and one part unexpected for the user. make sure you're using coreutils-6.11. once you have that, i think the way symlinks are counted may not be as you expect. -mike
On Wed, Jun 18, 2008 at 7:08 AM, Mike Frysinger <vapier@gentoo.org> wrote:
this has come up on the gnu coreutils list in the past iirc (so try searching their mail archives). i think it was one part bug and one part unexpected for the user. make sure you're using coreutils-6.11. once you have that, i think the way symlinks are counted may not be as you expect.
Thanks Mike, looks like it is related to the -x argument: http://www.mail-archive.com/bug-gnulib@gnu.org/msg04655.html I've confirmed it's fixed in coreutils-6.9-43, but haven't yet checked on my home machine where I saw the problem. Pretty sure it's the same thing though. Chuck, If it were rounding error I should still be able to make direct comparisons between the results, as long as they all used the -m argument. Thanks, BR
On Wed, Jun 18, 2008 at 10:20:08AM -0400, Brett Russ wrote:
Thanks Mike, looks like it is related to the -x argument: http://www.mail-archive.com/bug-gnulib@gnu.org/msg04655.html ... Chuck, If it were rounding error I should still be able to make direct comparisons between the results, as long as they all used the -m argument.
In my tests, with or without -x didn't make a difference:
du -smxc yum jigdo 1 yum 48 jigdo 48 total du -smc yum jigdo 1 yum 48 jigdo 48 total
But leaving off the -m, the total is the correct sum of the two directories:
du -sxc yum jigdo 416 yum 48660 jigdo 49076 total
I think that du -mc is adding the sizes first, then converting to 1 MiB blocks, therefore showing the approximation error in the total. In the -m case, 416 KiB rounds to 1 MiB, 48660 KiB rounds to 48 MiB, but the total isn't calculated as 1 + 48, but rather as 416 KiB + 48660 KiB = 49076 KiB, 49076 KiB / 1024 = 47.92 MiB, which rounded off becomes 48 MiB.
On Wed, Jun 18, 2008 at 10:35 AM, Chuck Anderson <cra@wpi.edu> wrote:
On Wed, Jun 18, 2008 at 10:20:08AM -0400, Brett Russ wrote:
Thanks Mike, looks like it is related to the -x argument: http://www.mail-archive.com/bug-gnulib@gnu.org/msg04655.html ... Chuck, If it were rounding error I should still be able to make direct comparisons between the results, as long as they all used the -m argument.
In my tests, with or without -x didn't make a difference:
du -smxc yum jigdo 1 yum 48 jigdo 48 total du -smc yum jigdo 1 yum 48 jigdo 48 total
Your version of du does not have the bug that I was writing about. I believe versions 6.1 - 6.6 were affected. The issue I had was that the second file/dir argument onwards was not properly tallied. So, using your example, jigdo would show a size of 1 if it were run as:
du -smxc yum jigdo but if you changed the command line to: du -smxc jigdo yum Then jigdo would show the correct size of 48.
-BR
On Wed, Jun 18, 2008 at 06:42:18AM -0400, Brett Russ wrote:
Can anyone explain why du (which advertises the ability to evaluate N file/dir arguments) seems to only be accurate for the first provided argument? See the following:
brett@spider:/> sudo du -smxc tmp 60 tmp 60 total brett@spider:/> sudo du -smxc tmp bin 60 tmp 1 bin 60 total
Try without the -m argument. You may be seeing round off error.
participants (3)
-
Brett Russ
-
Chuck Anderson
-
Mike Frysinger