linux/tools/lib/api
Ian Rogers d118b08f7e tools lib api: Add io_dir an allocation free readdir alternative
glibc's opendir allocates a minimum of 32kb, when called recursively
for a directory tree the memory consumption can add up - nearly 300kb
during perf start-up when processing modules. Add a stack allocated
variant of readdir sized a little more than 1kb.

As getdents64 may be missing from libc, add support using syscall. As
the system call number maybe missing, add #defines for those.

Note, an earlier version of this patch had a feature test for
getdents64 but there were problems on certains distros where
getdents64 would be #define renamed to getdents breaking the code. The
syscall use was made uncondtional to work around this. There is
context in:
https://lore.kernel.org/lkml/20231207050433.1426834-1-irogers@google.com/

Signed-off-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20250222061015.303622-2-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2025-02-24 15:46:33 -08:00
..
fd perf record: Fix way of handling non-perf-event pollfds 2022-10-04 08:55:19 -03:00
fs tool api fs: Correctly encode errno for read/write open failures 2024-12-09 17:52:42 -03:00
Build tools lib api: Add str_error_c to libapi 2016-07-27 17:16:43 -03:00
Makefile tools lib api: Add io_dir an allocation free readdir alternative 2025-02-24 15:46:33 -08:00
cpu.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
cpu.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
debug-internal.h tools lib api: Renaming pr_warning to pr_warn 2019-10-18 15:02:57 +02:00
debug.c tools lib api: Renaming pr_warning to pr_warn 2019-10-18 15:02:57 +02:00
debug.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
io.h tools api io: Ensure line_len_out is always initialized 2024-11-08 22:46:44 -08:00
io_dir.h tools lib api: Add io_dir an allocation free readdir alternative 2025-02-24 15:46:33 -08:00