]> git.ipfire.org Git - thirdparty/coreutils.git/commit
stat: don't explicitly request file size for filenames
authorAndreas Dilger <adilger@whamcloud.com>
Thu, 27 Jun 2019 08:25:55 +0000 (02:25 -0600)
committerPádraig Brady <P@draigBrady.com>
Fri, 12 Jul 2019 18:51:09 +0000 (19:51 +0100)
commita1a5e9a32eb9525680edd02fd127240c27ba0999
tree277474f599f25db1aa2137d5bb02fb3d5c4ef91a
parent3ae38a5995c8e8cd01a5410767db6078bef0afb5
stat: don't explicitly request file size for filenames

When calling 'stat -c %N' to print the filename, don't explicitly
request the size of the file via statx(), as it may add overhead on
some filesystems.  The size is only needed to optimize an allocation
for the relatively rare case of reading a symlink name, and the worst
effect is a somewhat-too-large temporary buffer may be allocated for
areadlink_with_size(), or internal retries if buffer is too small.

The file size will be returned by statx() on most filesystems, even
if not requested, unless the filesystem considers this to be too
expensive for that file, in which case the tradeoff is worthwhile.

* src/stat.c: Don't explicitly request STATX_SIZE for filenames.
src/stat.c