Bug 16045

Summary: find -size <number-without-suffix> handling not POSIX compliant
Product: Busybox Reporter: Stephane Chazelas <stephane+bb>
Component: Standard ComplianceAssignee: unassigned
Status: NEW ---    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: 1.37.x   
Target Milestone: ---   
Hardware: All   
OS: Linux   
See Also: https://github.com/landley/toybox/issues/499
Host: Target:
Build:

Description Stephane Chazelas 2024-04-21 13:57:44 UTC
Per POSIX (https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/find.html)

find . -size n

is meant to return the files whose size rounded up to an integer number of 512-byte units is 1.

For instance, `find . -size 1` is meant to report the files whose size ranges from 1 to 512 bytes (the ones that would typically occupy one sector of disk space in the olden days).

But for busybox (and toybox, which shares the same non-conformance), it only reports files whose size is exactly 512.

There are similar problems for `find . -size +n` and `find . -size -n`.

Note the behaviour when using suffixes other than `c` is fine as out of the POSIX scope and is aligned with most other implementations that support those or some of those suffixes (except GNU `find`).

See https://unix.stackexchange.com/questions/774817/what-are-the-file-size-options-for-find-size-command/774840#774840 for more of the gory details including comparison with other implementations.