Skip to content

Don't count the same hard link multiple times in du #1317

Closed

Description

@thegedge

Is your feature request related to a problem? Please describe.
The builtin du counts hard links multiple times.

Describe the solution you'd like
I would like du to only count the same hard link once in computing disk usage. This could be either via a flag or by default.

One problem to figure out: if the same hard link exists multiple times, who do we attribute the disk usage to? Do we attribute it to all directories, but have a top-level sum that has the real usage?

Describe alternatives you've considered
Keeping the current behaviour, which may overestimate actual disk usage.

Additional context
From @Freaky's suggestion here: #679 (comment)

Activity

  1. added
    category:enhancement
    delight
    on Jan 31, 2020
  2. Freaky commented on Feb 10, 2020

    @Freaky

    I think when in doubt, do what du does. In this case, first one found wins, subsequent entries are skipped unless a flag not to do inode tracking is set.

    Ignoring precedent, an argument could be made for double-counting in apparent, because that's how big the directories appear to be, but the question is which is more useful and which is less surprising.

  3. thegedge commented on Feb 11, 2020

    @thegedge
    ContributorAuthor

    but the question is which is more useful and which is less surprising.

    Agree that this is probably the best question to ask. When I think du, I think "disk usage", and more me that sounds a lot like "how much disk space am I actually using" 🙂

  4. Freaky commented on Feb 11, 2020

    @Freaky

    I think it might be worth reworking this to use a single ignore loop. It can handle most of the heavy-lifting and keep the traversal in one place where both the inode and ctrl-c checks can go (currently broken except in the most trivial of cases).

    This will also enable easily adding features like supporting .gitgnore and even multithreaded traversal.

  5. github-actions commented on Jun 24, 2021

    @github-actions

    This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

  6. github-actions commented on Jul 7, 2021

    @github-actions

    This issue has been marked stale for more than 10 days without activity. Closing this issue, but if you find that the issue is still valid, please reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    category:enhancementdelight

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions