Skip to content

Display the right major and minor device IDs when encountering block or char devices #1126

Open
@SteveLauC

Description

@SteveLauC

I noticed that the device ID returned by exa is wrong:

$ bat src/main.rs
───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: src/main.rs
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ use nix::sys::stat::{major, minor, stat};
   2   │ fn main() {
   3   │     let s = stat("/dev/nvme0n1p3").unwrap();
   4   │
   5   │     println!("major: {}", major(s.st_rdev));
   6   │     println!("minor: {}", minor(s.st_rdev));
   7   │ }
───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

$ cargo r -q
major: 259
minor: 3

$ exa -l /dev/nvme0n1p3
brw-rw----@ 3,3 root  2 Oct 07:22 /dev/nvme0n1p3

And this behavior is actually documented in the source code:
https://github.com/ogham/exa/blob/master/src/fs/file.rs#L321~L332

Any reason why it is not correctly decomposed and returned?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions