Skip to content
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

Fix ls -h total size bug #510

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

benny8453123
Copy link

@benny8453123 benny8453123 commented Jul 18, 2024

Hi,

I found a bug and tried to fix it: While using ls -h, the total size of the folder shows the wrong value.

Environment

$ ls -l
total 2097156
-rw-rw-r-- 1 benchang benchang 2147483648  七  17 18:09 2G_file

Before:

$ ../toybox/toybox ls -h
total 2.0M
2G_file

$ ../toybox/toybox ls -sh --block-size=4096
total 512K
512K 2G_file

After:

$ ../toybox/toybox ls -h
total 2.0G
2G_filels 

$ ../toybox/toybox ls -sh --block-size=4096
total 2.0G
2.0G 2G_file

I have done several tests, and it looks correct and like there are no other side effects.
E.g.:

ls -h
ls -l
ls -s
ls -ls
ls -lh
ls -hs
ls -lhs
ls -h --block-size=1024
ls -l --block-size=1024
ls -s --block-size=1024
ls -ls --block-size=1024
ls -lh --block-size=1024
ls -hs --block-size=1024
ls -lhs --block-size=1024
ls -h --block-size=4096
ls -l --block-size=4096
ls -s --block-size=4096
ls -ls --block-size=4096
ls -lh --block-size=4096
ls -hs --block-size=4096
ls -lhs --block-size=4096

With the -h option, the value should not be translated to block
count before converting to a human-readable format.
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.

1 participant