[LTP] [PATCH] openat2: Move includes to lapi, remove _GNU_SOURCE

Petr Vorel pvorel@suse.cz
Thu Feb 5 10:44:58 CET 2026


> On Wed, Feb 04, 2026 at 01:43:23PM +0100, Petr Vorel wrote:
> > Improve 767b3e519e. struct open_how is also used in lapi/openat2.h,
> > which is used by all openat2*.c tests.  Therefore move <fcntl.h> to the
> > lapi header (and use lapi/fcntl.h instead).

> > Also remove _GNU_SOURCE which should not be needed.

> > While at it, move include "config.h" to the top.

> > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> > ---
> > Hi Li,

> > my points from the original patchset why not use _GNU_SOURCE:

> > glibc test tst-openat2.c [1] which includes <fcntl.h>, uses struct

> Interesting, I haven't figure out why it can be built within glibc itself.

I also checked Makefile, but haven't found that. Never mind, I was wrong, it's
obviously needed.

> > open_how and test openat2() does not define it. Neither openat2() nor
> > struct open_how [2] are guarded by #ifdef __USE_GNU.

> > O_DIRECTORY is guarded by #ifdef __USE_XOPEN2K8 but this should be safe as we
> > compile with -std=gnu99.

> In glibc-2.43, things have changed, only define __USE_GNU can contain the
> <bits/openat2.h> header file, that's why after applying this patch still
> fails to complie on Fedora-Rawhide.

> <fcntl.h> -> <bits/fcntl.h> -> <bits/fcntl-linux.h> -> <bits/openat2.h>

Yeah, I saw this...

>  # cat bits/fcntl-linux.h

>  396 #ifdef __USE_GNU
...but did not check that whole section is guarded by __USE_GNU (=> _GNU_SOURCE).

Kind regards,
Petr

>      ...
>  473 #include <bits/openat2.h>

>  489 #endif	/* use GNU */

> See: https://github.com/bminor/glibc/commit/0f0a5cd338998f4b603f52f3ce2163df0db7b814#diff-a4fc1e1b56b60a2598e320a232e6f631d08e0dafcfe3dd9607dde4bc8ee31eb8R473


More information about the ltp mailing list