[LTP] [PATCH v2 1/2] openat2: define _GNU_SOURCE and include <fcntl.h>
Petr Vorel
pvorel@suse.cz
Wed Feb 4 23:27:53 CET 2026
Hi Li,
...
> > lapi/openat2.h uses struct open_how directly, shouldn't be included lapi/fcntl.h
> > there?
> From my understand lapi/* are appendix for missing stuff in header file.
Yes, but we agreed in the past, that it's better to include relevant libc/kernel
header in the lapi header [1]:
LAPI header should always include original header.
[1] https://github.com/linux-test-project/ltp/blob/master/doc/old/C-Test-API.asciidoc#lapi-headers
I thought we had a discussion about it, but now I see nobody acked the change in
ML (cfbc41d775), therefore I somehow pushed this approach without consensus with
others. I'm sorry for that, we can revise that. At the moment quite a few lapi
headers use this approach (likely majority).
IMHO it's better to include it than expect that all tests which use lapi header
will include relevant header *before* (otherwise tests can happily always depend
on fallback instead of using a real value from a system header).
It's a minor detail, but being consistent helps for newcomers to understand
LTP code.
And *if* we agree on it, it should be now doc/developers/ground_rules.rst.
Also there is a different approach where should be fallbacks. We use some lapi
headers (e.g. lapi/openat2.h but there are more) which don't have public
equivalent in libc (/usr/include/bits/openat2.h cannot be used directly, but via
<fcntl.h>). Therefore I would put content of lapi/openat2.h into lapi/fcntl.h,
but that's a minor detail.
> Test cases should only include standard header files, and lapi should
> only be used in case of missing or conflicting header files.
But lapi/openat2.h also uses struct open_how. I would either include <fcntl.h>
in both sources or just in lapi/openat2.h. Having it only in tests looks to me
as not ideal.
Kind regards,
Petr
More information about the ltp
mailing list