Skip to content

du --inodes reports 0 for a lone directory (GNU: 1) and mixes byte counts into inode counts (4097 for a directory holding one file; GNU: 2) #1372

Closed

Description

@caomengxuan666

Probe-verified (same-source mingw+Wine harness, two runs, GNU coreutils 9.4). du --inodes (audit item I11; the hardlink faces of du are #1351, this is separate):

  1. Empty directory d: du --inodes d → WinuxCmd prints 0 d; GNU prints 1 d (a directory counts itself).
  2. Directory d containing one file: du --inodes d → WinuxCmd prints 4097 d; GNU prints 2 d. WinuxCmd's number looks like a disk-block total (4096) plus one — byte accounting leaks into inode mode.

Expected (GNU)

--inodes reports pure inode counts: every visited object, including each directory itself, contributes exactly 1.

Source

src/commands/du.cpp: the inode-count path initializes a directory's count at 0 instead of 1 and adds the block-usage accumulator into the reported value in directory totals.

Regression seed

In-repo test named with this issue number: both fixtures above, asserting 1 and 2.

Activity

  1. added
    bug
    compat-gap
    on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugcompat-gap

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions