Re: find /etc -size -1G return only empty files

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

 



> You are correct.  Doing "-size -1G" on both F11 and F12 return only
> zero-length files.  Yep, that's a bug in my book.

Two explanations given in the bug link that someone posted earlier:

In answer to:

"Would someone please explain -- completely and carefully -- just
exactly how find's behavior is actually correct? It does not
seem to me that the man page (or info) adequately explains this
subtlety."

Post 1:
Step one: How many 1M blocks does the 3200 byte file take? Answer:
one. (Clearly it cannot be zero.)
Step two: Is one stricly lower than 1? No it is not.
Test failed.

Post 2:
I don't believe the behavior is correct, but here's the line of reasoning.
The original find implementation counts disk blocks. A block is either
used (partially or fully), or not.
Blocks are (typically? always?) 512 bytes long.
You are looking for blocks that are used, and therefore cannot be used
by other files, which is the key distinction why this makes sense for
blocks but not for megabytes or whatever.
So if you search for size -2, you are not really searching for
anything that is using less than 1024 bytes, you are searching for
something that is using 1 full block, and no portion of a second
block.
If you apply the same logic to a different unit, gigabytes, you will
end up with the situation where a file of 1 gigabyte + 1 byte is using
a portion of the second gigabyte, therefore the test fails.
This is obviously the wrong logic to use when units are something
other than disk blocks, but that's how it got this way.
The maintainer suggests in the comments below that changing this might
break backward compatibility. Let's just say that I strongly disagree.
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux