lkml.org 
[lkml]   [2022]   [Feb]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/1] libbpf: ensure F_DUPFD_CLOEXEC is defined
From
Date
Hi James,

On 2/27/22 3:25 PM, James Hilliard wrote:
> This definition seems to be missing from some older toolchains.
>
> Note that the fcntl.h in libbpf_internal.h is not a kernel header
> but rather a toolchain libc header.
>
> Fixes:
> libbpf_internal.h:521:18: error: 'F_DUPFD_CLOEXEC' undeclared (first use in this function); did you mean 'FD_CLOEXEC'?
> fd = fcntl(fd, F_DUPFD_CLOEXEC, 3);
> ^~~~~~~~~~~~~~~
> FD_CLOEXEC
>
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>

Do you have some more info on your env (e.g. libc)? Looks like F_DUPFD_CLOEXEC
was added back in 2.6.24 kernel. When did libc add it?

Should we instead just add an include for <linux/fcntl.h> to libbpf_internal.h
(given it defines F_DUPFD_CLOEXEC as well)?

> ---
> tools/lib/bpf/libbpf_internal.h | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h
> index 4fda8bdf0a0d..d2a86b5a457a 100644
> --- a/tools/lib/bpf/libbpf_internal.h
> +++ b/tools/lib/bpf/libbpf_internal.h
> @@ -31,6 +31,10 @@
> #define EM_BPF 247
> #endif
>
> +#ifndef F_DUPFD_CLOEXEC
> +#define F_DUPFD_CLOEXEC 1030
> +#endif
> +
> #ifndef R_BPF_64_64
> #define R_BPF_64_64 1
> #endif
>

Thanks,
Daniel

\
 
 \ /
  Last update: 2022-02-28 16:00    [W:0.055 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site