Re: [PATCH] stat: don't explicitly request file size for filenames

2019-07-05 Thread Paul Eggert
Pádraig Brady wrote: It would be nice to have areadlink_with_size treat 0 as auto select some lower bound. Yes, that sounds good. However, I didn't see why that would entail changing SYMLINK_MAX from 1024 to 1023, or why the patch would affect the documented API. How about the attached patc

Re: [PATCH] stat: don't explicitly request file size for filenames

2019-07-05 Thread Bruno Haible
> Therefore I think it would be good to add a "Shrink BUF before returning it." > logic also to > areadlink-with-size.c > areadlinkat-with-size.c > etc. Done as follows: - For areadlink-with-size, areadlinkat-with-size, xgethostname, xgetdomainname by shrinking the result before returning

Re: [PATCH] stat: don't explicitly request file size for filenames

2019-07-04 Thread Bruno Haible
Andreas Dilger wrote: > I was worried if > "ls" or something is saving all of the symlink targets in memory that using a > too-large buffer size would cause excess memory to be allocated for a long > time. Good point. careadlinkat.c has a "Shrink BUF before returning it." logic, but not all simil

Re: [PATCH] stat: don't explicitly request file size for filenames

2019-07-04 Thread Bruno Haible
Hi, Andreas Dilger wrote: > + size_t buf_size = size < initial_limit ? (size ?: 31) + 1 : initial_limit; This syntax is specific to GCC [1]. In patches for gnulib, please stick to portable C99 syntax. Thanks. Bruno [1] https://gcc.gnu.org/onlinedocs/gcc-9.1.0/gcc/Conditionals.html

Re: [PATCH] stat: don't explicitly request file size for filenames

2019-07-04 Thread Andreas Dilger
On Jul 4, 2019, at 04:44, Pádraig Brady wrote: > > diff --git a/lib/areadlink-with-size.c b/lib/areadlink-with-size.c > index eacad3f..2fbe51c 100644 > --- a/lib/areadlink-with-size.c > +++ b/lib/areadlink-with-size.c > @@ -36,14 +36,15 @@ > check, so it's OK to guess too small on hosts where

Re: [PATCH] stat: don't explicitly request file size for filenames

2019-07-04 Thread Andreas Dilger
On Jul 4, 2019, at 04:44, Pádraig Brady wrote: > > On 03/07/19 21:24, Andreas Dilger wrote: >> 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 allo

Re: [PATCH] stat: don't explicitly request file size for filenames

2019-07-04 Thread Pádraig Brady
On 03/07/19 21:24, Andreas Dilger wrote: > 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 symli