mips: Do not malloc on getdents64 fallback
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 24 Jul 2019 16:48:12 +0000 (13:48 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 9 Oct 2019 20:34:38 +0000 (17:34 -0300)
commitedcda4c08ac033f40a91cb4def2fd0fa35a760ca
tree6676392a91b54b7b57253e37edff6262a33a656e
parent00fe3c6657161a96890067666760ea8cf22b791c
mips: Do not malloc on getdents64 fallback

This patch changes how the fallback getdents64 implementation calls
non-LFS getdents by replacing the scratch_buffer with static buffer
plus a loop on getdents calls.  This avoids the potential malloc
call on scratch_buffer_set_array_size for large input buffer size
at the cost of more getdents syscalls.

It also adds a small optimization for older kernels, where the first
ENOSYS failure for getdents64 disable subsequent calls.

Check the dirent tests on a mips64-linux-gnu with getdents64 code
disabled.

* sysdeps/unix/sysv/linux/mips/mips64/getdents64.c (__getdents64):
Add small optimization for older kernel to avoid issuing
__NR_getdents64 on each call and replace scratch_buffer usage with
a static allocated buffer.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
ChangeLog
sysdeps/unix/sysv/linux/mips/mips64/getdents64.c