Bug 246122 - find -size does not work properly with 'M' unit
find -size does not work properly with 'M' unit
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: findutils (Show other bugs)
5.0
All Linux
low Severity low
: ---
: ---
Assigned To: Vitezslav Crhonek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2007-06-28 13:29 EDT by ladislav
Modified: 2007-11-30 17:07 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-09-25 10:15:11 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description ladislav 2007-06-28 13:29:38 EDT
Description of problem:

find -size [<mod>]<x>M does work

Version-Release number of selected component (if applicable):

4.2.27-4.1

How reproducible:

compare file sizes

Steps to Reproduce:
1. dd if=/bin/false of=onemeg bs=1024 count=1024
   dd if=/bin/false of=onemegplus bs=1024 count=1025
   dd if=/bin/false of=onemegminus bs=1024 count=1023

2. find -size 1M;find -size -1M;find -size +1M
  
Actual results:

foof@e31 m70]$ find -size 1M
./onemeg
./onemegminus
[foof@e31 m70]$ find -size -1M
[foof@e31 m70]$ find -size +1M
./onemegplus


Expected results:

[foof@e31 m70]$ find -size 1M
./onemeg
[foof@e31 m70]$ find -size -1M
./onemegminus
[foof@e31 m70]$ find -size +1M
./onemegplus


Additional info:
Comment 1 Vitezslav Crhonek 2007-09-25 10:15:11 EDT
This behaviour is correct, see the documentation:

http://www.gnu.org/software/findutils/manual/html_mono/find.html.gz#Size

"True if the file uses n units of space, rounding up.". _Rounding up_! In the
package man page (including lates version) this sentence is a bit different
"File uses n units of space.". Try report bug to upstream.

With 1M, onemegminus is round to 1M, that's the reason, why find -size 1M both
files are returned. If you try your example with find {+,-, }1024k, you get what
you expect.
Maybe this will help you understand:

[vcrhonek@norcus tmp]$ ls -alh
total 29M
drwxr-xr-x  2 vcrhonek vcrhonek 4.0K Sep 25 15:47 .
drwx------ 82 vcrhonek vcrhonek 4.0K Sep 25 14:23 ..
-rw-rw-r--  1 vcrhonek vcrhonek 5.0M Sep 25 15:41 fivemeg
-rw-rw-r--  1 vcrhonek vcrhonek 4.0M Sep 25 15:45 fourmeg
-rw-rw-r--  1 vcrhonek vcrhonek 7.0M Sep 25 15:44 sevenmeg
-rw-rw-r--  1 vcrhonek vcrhonek 6.0M Sep 25 15:44 sixmeg
-rw-rw-r--  1 vcrhonek vcrhonek 3.5M Sep 25 15:47 threeandhalf
-rw-rw-r--  1 vcrhonek vcrhonek 3.0M Sep 25 15:44 threemeg
[vcrhonek@norcus tmp]$ find -size 5M
./fivemeg
[vcrhonek@norcus tmp]$ find -size 4M
./fourmeg
./threeandhalf
[vcrhonek@norcus tmp]$ find -size -4M
./threemeg
Comment 2 ladislav 2007-09-25 12:36:34 EDT
Thanks for pointing out the rounding up.

Very counter intuitive and twisted imnsho, but as you point out, correct
behavior per the man page.  (Compare with same in k units for example.)

Note You need to log in before you can comment on or make changes to this bug.