Skip to content

Default output format of stat uses incorrect format for Device field #9071

@rlee287

Description

@rlee287

Rust coreutils, compiled from the main branch (ca6d69a as of the time of writing):

$ cargo run --release --features unix -- stat /
    Finished `release` profile [optimized] target(s) in 0.12s
     Running `target/release/coreutils stat /`
  File: /
  size: 4096      	Blocks: 8          IO Block: 4096   directory
Device: fc01h/64513d	Inode: 2           Links: 23
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2025-10-24 17:16:40.447022494 -0700
Modify: 2025-05-02 18:37:54.159527224 -0700
Change: 2025-05-02 18:37:54.159527224 -0700
 Birth: 2024-07-25 14:12:04.000000000 -0700

GNU stat:

$ stat /
  File: /
  Size: 4096      	Blocks: 8          IO Block: 4096   directory
Device: 252,1	Inode: 2           Links: 23
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2025-10-24 17:16:40.447022494 -0700
Modify: 2025-05-02 18:37:54.159527224 -0700
Change: 2025-05-02 18:37:54.159527224 -0700
 Birth: 2024-07-25 14:12:04.000000000 -0700

The Rust coreutils stat prints out a raw u16 value in hex and decimal form, while GNU stat splits the u16 into a major and minor u8 pair. This is a mismatch in stdout output between the two utils.

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