-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
ls: Fix display of inodes and add allocation size feature #3052
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
Conversation
I think there's some miscalculation somewhere, trying to figure out where, output is sorted because we currently don't sort by default. hbina@akarin ~/g/uutils (ls_2)> ls -l --block-size=512 | sort
drwxrwxr-x 2 hbina hbina 8 Dec 24 22:33 examples
drwxrwxr-x 2 hbina hbina 8 Feb 2 21:32 dir2
drwxrwxr-x 2 hbina hbina 8 Feb 2 23:18 dir1
drwxrwxr-x 2 hbina hbina 8 Jan 31 23:43 util
drwxrwxr-x 4 hbina hbina 8 Jan 31 23:20 target
drwxrwxr-x 4 hbina hbina 8 Jan 31 23:43 docs
drwxrwxr-x 6 hbina hbina 8 Dec 24 22:33 src
drwxrwxr-x 6 hbina hbina 8 Jan 31 23:43 tests
-rw-rw-r-- 1 hbina hbina 11 Dec 24 22:33 CODE_OF_CONDUCT.md <=== does not match
-rw-rw-r-- 1 hbina hbina 12 Jan 31 23:43 build.rs <=== does not match
-rw-rw-r-- 1 hbina hbina 131 Feb 2 21:31 Cargo.lock
-rw-rw-r-- 1 hbina hbina 14 Jan 31 23:43 GNUmakefile
-rw-rw-r-- 1 hbina hbina 1 Dec 24 22:33 Makefile
-rw-rw-r-- 1 hbina hbina 21 Dec 24 22:33 Makefile.toml
-rw-rw-r-- 1 hbina hbina 33 Feb 3 21:33 Cargo.toml
-rw-rw-r-- 1 hbina hbina 37 Feb 2 21:31 README.md
-rw-rw-r-- 1 hbina hbina 3 Dec 24 22:33 LICENSE
-rw-rw-r-- 1 hbina hbina 7 Jan 31 23:43 DEVELOPER_INSTRUCTIONS.md
-rw-rw-r-- 1 hbina hbina 8 Jan 31 23:43 CONTRIBUTING.md
total 384
hbina@akarin ~/g/uutils (ls_2)> cargo run --quiet -- ls -l --block-size=512 | sort
drwxrwxr-x 2 hbina hbina 8 Dec 24 22:33 examples
drwxrwxr-x 2 hbina hbina 8 Feb 2 21:32 dir2
drwxrwxr-x 2 hbina hbina 8 Feb 2 23:18 dir1
drwxrwxr-x 2 hbina hbina 8 Jan 31 23:43 util
drwxrwxr-x 4 hbina hbina 8 Jan 31 23:20 target
drwxrwxr-x 4 hbina hbina 8 Jan 31 23:43 docs
drwxrwxr-x 6 hbina hbina 8 Dec 24 22:33 src
drwxrwxr-x 6 hbina hbina 8 Jan 31 23:43 tests
-rw-rw-r-- 1 hbina hbina 136 Feb 2 21:31 Cargo.lock
-rw-rw-r-- 1 hbina hbina 16 Dec 24 22:33 CODE_OF_CONDUCT.md <=== does not match
-rw-rw-r-- 1 hbina hbina 16 Jan 31 23:43 build.rs <=== does not match
-rw-rw-r-- 1 hbina hbina 16 Jan 31 23:43 GNUmakefile
-rw-rw-r-- 1 hbina hbina 24 Dec 24 22:33 Makefile.toml
-rw-rw-r-- 1 hbina hbina 40 Feb 2 21:31 README.md
-rw-rw-r-- 1 hbina hbina 40 Feb 3 21:33 Cargo.toml
-rw-rw-r-- 1 hbina hbina 8 Dec 24 22:33 LICENSE
-rw-rw-r-- 1 hbina hbina 8 Dec 24 22:33 Makefile
-rw-rw-r-- 1 hbina hbina 8 Jan 31 23:43 CONTRIBUTING.md
-rw-rw-r-- 1 hbina hbina 8 Jan 31 23:43 DEVELOPER_INSTRUCTIONS.md
total 384 Edit: Fixed this with this change. Basically the size shown is not the number of blocks allocated, but the minimum number of blocks required for the file size.
|
Okay, this is interesting, but I think it may be outside the scope of this PR, as it addresses the non-block size given in the LongFormat option. I've noticed similar behavior too. Anyway, I think this might be better placed in a separate PR with some tests attached, but appreciate your work. Thank you. |
If you prepare a PR, let me know. I'd be pleased to review. One suggestion -- I would generic-ize the operation of rounding up to make clear what you are doing/not doing, with something like: https://doc.rust-lang.org/std/primitive.u64.html#method.unstable_div_ceil |
I'll create the PR after yours are merged because its based on that. |
@sylvestre @tertsdiepraam Don't mean to rush a review but CICD won't tell me which test is failing. Perhaps I'm missing something. I see:
But no indication which test is newly failing per:
Any assistance you could provide would be appreciated. Thanks! |
@sylvestre @tertsdiepraam I'd like to request a review, when it is convenient. Thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's correct, but it needs some cleanup or documentation in a few places. Nice work!
Co-authored-by: Terts Diepraam <terts.diepraam@gmail.com>
Co-authored-by: Terts Diepraam <terts.diepraam@gmail.com>
I think this may be ready to merge but I think it also needs your all clear, when it is convenient. Thank you for your review. It really needed some more TLC and your comments very much helped. |
@hbina FYI I added your suggestion with a test. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! It looks great now! I found one last thing to change and then it can get merged.
Only reason the GNU test block size (block-size.sh) appears to be failing is because of issues related to
dd
not parsing 'conv' correctly (!).