bpftool: Use only nftw for file tree parsing
The bpftool sources include code to walk file trees, but use multiple frameworks to do so: nftw and fts. While nftw conforms to POSIX/SUSv3 and is widely available, fts is not conformant and less common, especially on non-glibc systems. The inconsistent framework usage hampers maintenance and portability of bpftool, in particular for embedded systems. Standardize code usage by rewriting one fts-based function to use nftw and clean up some related function warnings by extending use of "const char *" arguments. This change helps in building bpftool against musl for OpenWrt. Also fix an unsafe call to dirname() by duplicating the string to pass, since some implementations may directly alter it. The same approach is used in libbpf.c. Signed-off-by: Tony Ambardar <Tony.Ambardar@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Reviewed-by: Quentin Monnet <quentin@isovalent.com> Link: https://lore.kernel.org/bpf/20200721024817.13701-1-Tony.Ambardar@gmail.com
This commit is contained in:

committed by
Daniel Borkmann

parent
8fca4f98af
commit
9165e1d70f
@@ -152,8 +152,8 @@ int cmd_select(const struct cmd *cmds, int argc, char **argv,
|
||||
int get_fd_type(int fd);
|
||||
const char *get_fd_type_name(enum bpf_obj_type type);
|
||||
char *get_fdinfo(int fd, const char *key);
|
||||
int open_obj_pinned(char *path, bool quiet);
|
||||
int open_obj_pinned_any(char *path, enum bpf_obj_type exp_type);
|
||||
int open_obj_pinned(const char *path, bool quiet);
|
||||
int open_obj_pinned_any(const char *path, enum bpf_obj_type exp_type);
|
||||
int mount_bpffs_for_pin(const char *name);
|
||||
int do_pin_any(int argc, char **argv, int (*get_fd_by_id)(int *, char ***));
|
||||
int do_pin_fd(int fd, const char *name);
|
||||
|
Reference in New Issue
Block a user