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

Support $BLOCKSIZE environment variable #9

Open
2 tasks
duckinator opened this issue Jun 10, 2020 · 0 comments
Open
2 tasks

Support $BLOCKSIZE environment variable #9

duckinator opened this issue Jun 10, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@duckinator
Copy link
Owner

duckinator commented Jun 10, 2020

On the pages for at least df, the standard suggests the use of a BLOCKSIZE environment variable:

The use of 512-byte units is historical practice and maintains compatibility with ls and other utilities in this volume of POSIX.1-2017. This does not mandate that the file system itself be based on 512-byte blocks. The -k option was added as a compromise measure. It was agreed by the standard developers that 512 bytes was the best default unit because of its complete historical consistency on System V (versus the mixed 512/1024-byte usage on BSD systems), and that a -k option to switch to 1024-byte units was a good compromise. Users who prefer the more logical 1024-byte quantity can easily alias df to df -k without breaking many historical scripts relying on the 512-byte units.

It was suggested that df and the various related utilities be modified to access a BLOCKSIZE environment variable to achieve consistency and user acceptance. Since this is not historical practice on any system, it is left as a possible area for system extensions and will be re-evaluated in a future version if it is widely implemented.

I think it's reasonable to only support values of 512 and 1024. To the best of my knowledge, the affected utilities also all have a -k option. Given that information and the way I've implemented Boreutils utililties so far, this seems like a reasonable approach:

// after normal argument parsing is done (to avoid issues if `-k` is passed but $BLOCKSIZE != 1024).
if (!dash_k) { dash_k = strcmp(getenv("BLOCKSIZE"), "1024") == 0; }

The utilities that should have support for this are any which provide information about files and/or has a -k option that switches to 1024 byte blocks. This list should be updated if more are found:

  • df
  • ls
@duckinator duckinator added the enhancement New feature or request label Jun 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant