Skip to content

du command outputs wrong sizes when a subdirectory is included with its parent directory in the arguments #9202

@fedkad

Description

@fedkad

Test case with uutils' du command:

$ mkdir test
$ cd test
$ mkdir dir1
$ dd if=/dev/urandom of=file1 bs=1M count=3
$ dd if=/dev/urandom of=dir1/file1 bs=1M count=5
$ mkdir dir2
$ dd if=/dev/urandom of=dir2/file1 bs=1M count=7
$ du -smc dir1 .
5	dir1
15	.
20	total
$ du --version
du (uutils coreutils) 0.2.2

The same test with GNU coreutils' du command:

$ du -smc dir1 .
5	dir1
10	.
15	total
$ du --version
du (GNU coreutils) 9.5
Copyright (C) 2024 Free Software Foundation, Inc

The correct output is the one provided by GNU coreutils, because the test directory contains a total of 15 MiB data and its subdirectory dir1 contains 5 MiB. During an invocation, du should not count files more than once, even when the arguments passed to it specify so.

This is a incompatibility bug of uutils wrt GNU coreutils and it should be treated according to the Goals:

Our key objectives include:
Matching GNU's output (stdout and error code) exactly

Please check the relevant discussion at AskUbuntu.com too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions