[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug in find's -size (+patch)

From: James Youngman
Subject: Re: Bug in find's -size (+patch)
Date: Sun, 6 Feb 2005 15:04:22 +0000
User-agent: Mutt/1.3.28i

On Sun, Feb 06, 2005 at 05:56:54AM -0500, Amir Sela wrote:

> I encountered this bug while trying to find files in a directory which
> are smaller than 2kbytes. I was using -size -2k and it didn't find the
> files with sizes 1024 bytes < file < 2048 bytes. The reason for this (As
> I saw), was that the b and k suffixes to -size's argument caused a
> rounding up. This rounding up occurs because the current code takes the
> file's byte count and changes it to the user's choice of block size, and
> then compares the two. I see no reason for this. 

I see your point, but the reason for this behaviour is that the POSIX
standard requires it for the ordinary case (512 byte blocks).  The
POSIX standard says :-

POSIX> -size n[c] 
POSIX>     The primary shall evaluate as true if the file size in
POSIX>     bytes, divided by 512 and rounded up to the next integer,
POSIX>     is n. If n is followed by the character 'c', the size shall
POSIX>     be in bytes.

This is available online at

> A more logical approach (To my opinion) would be to normalize the
> *user's* choice of blocksize into a byte count. By doing that all
> the comparisons are byte count-based and don't exhibit the bug when
> b and k are used.

I'm not sure we can do that while retaining POSIX compliance.  If you
have some ideas about how find could be more convenient for you
without compromising compliance with the POSIX standard, I'd like to
hear them.

>  PS1 - This is my first attempt at a bug+patch submission, so if I did
>  something wrong here please go easy on me :).

The format of your patch was fine.  However, if you want you can
submit patches via the Findutils project on Savannah (see
http://www.gnu.org/software/findutils/ for details).  That way the
members of the mailing list still get to find out about them, but you
can also see if they have been applied and what release they go into.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]