Skip to content

ls: implement device symbol and id #2145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 8, 2021

Conversation

tertsdiepraam
Copy link
Member

Closes #2140

This is a quick fix to show the correct symbols for character device and block device, fifo and pipe special files and show the minor and major id numbers of devices. I'm not sure how to test this, so any ideas on that are welcome!

The id numbers are not spaced correctly yet, because that would require a bit of a rewrite of the long format. I would rather do that in another PR (which should also fix #2139). This is what it looks like now:

crw-rw---- 1 root audio 116, 12 Apr 29 09:01 hwC0D0
crw-rw---- 1 root audio 116, 11 Apr 29 09:01 hwC0D2
crw-rw---- 1 root audio  116, 5 Apr 29 13:08 pcmC0D0c
crw-rw---- 1 root audio  116, 4 Apr 29 13:08 pcmC0D0p

and here is what it should eventually look like:

crw-rw----+ 1 root audio 116, 12 29 apr 09:01 hwC0D0
crw-rw----+ 1 root audio 116, 11 29 apr 09:01 hwC0D2
crw-rw----+ 1 root audio 116,  5 29 apr 13:08 pcmC0D0c
crw-rw----+ 1 root audio 116,  4 29 apr 13:08 pcmC0D0p

Note: the + at the end is also not implemented yet.

@tertsdiepraam
Copy link
Member Author

Looks like the birthtime tests are still not 100% stable...

@sylvestre
Copy link
Contributor

@tertsdiepraam yeah, would you mind opening a bug about this?
(we can just ignore it)

@sylvestre
Copy link
Contributor

Could you please fix


failures:

---- test_ls::test_ls_order_birthtime stdout ----
current_directory_resolved: 
open: /tmp/.tmpsgBoma/test-birthtime-1
run: /home/runner/work/coreutils/coreutils/target/debug/coreutils ls --time=birth -t
---- test_ls::test_ls_order_birthtime stderr ----
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `"test-birthtime-1\ntest-birthtime-2\n"`,
 right: `"test-birthtime-2\ntest-birthtime-1\n"`', /home/runner/work/coreutils/coreutils/tests/by-util/test_ls.rs:580:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    test_ls::test_ls_order_birthtime

@tertsdiepraam
Copy link
Member Author

Seems like that other PR was not successful then :( I'll try again soon!

@sylvestre
Copy link
Contributor

Could you please fix the conflict? thanks

@tertsdiepraam
Copy link
Member Author

Should be all good now! Only code cov failed due to an unrelated test.

@sylvestre
Copy link
Contributor

conflicting again with the recent pr :( sorry

@tertsdiepraam
Copy link
Member Author

No problem! I was expecting that to happen :)

let dev: u64 = metadata.rdev();
let major = (dev >> 8) as u8;
let minor = dev as u8;
return format!("{}, {}", major, minor);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it expected that we don't have tests for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I wasn't sure how to test that. If you know a way to create (or mock?) devices in the test suite I'd be happy to add some tests!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dunno, sorry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ls: show device details ls: user & group column alignment in long output format
2 participants