[LTP] [PATCH v2 1/2] openat2: define _GNU_SOURCE and include <fcntl.h>
Petr Vorel
pvorel@suse.cz
Thu Feb 5 11:08:25 CET 2026
> On Wed, Feb 04, 2026 at 11:27:53PM +0100, Petr Vorel wrote:
> > 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).
> Yes, I generally agree with this, and here is my understand:
> 1. Testcase should include original <header.h> (but not "lapi/header.h")
> if *only* need the original <header.h> file.
... and don't need any fallback from the lapi header.
> 2. LAPI-header should always include original <header.h>, it handling
> the missing/conflicting part there.
> Thus, we can treat "lapi/header.h" as a patched <header.h> and only
> use it intead of the original <header.h> in testcase if needed.
+1
> 3. We avoid including both original <header.h> and "lapi/header.h" in
> testase at the same time.
+1
> > 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.
> I am ok with it, the advantage merge lapi/openat2.h into lapi/fcntl.h is
> keep things more centralized.
> But also, keep lapi/openat2.h seperated is more modular, and it should
> contains <fcntl.h> as well.
Yeah, I don't have strong opinion about it, both ways would work.
> > > 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.
> Right, thanks for bring up this topic.
Thank you for your time. I try to send a patch to add the outcome to
doc/developers/ground_rules.rst and wait for ack of others to get broader
consensus about it.
Kind regards,
Petr
More information about the ltp
mailing list