From: Li Wang via ltp <ltp@lists.linux.it>
To: Petr Vorel <pvorel@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 1/2] openat2: define _GNU_SOURCE and include <fcntl.h>
Date: Wed, 4 Feb 2026 22:20:34 +0800 [thread overview]
Message-ID: <aYNVsiL4xf2P9R6A@redhat.com> (raw)
In-Reply-To: <20260204122332.GC224465@pevik>
On Wed, Feb 04, 2026 at 01:23:32PM +0100, Petr Vorel wrote:
> hi Li,
>
> > On Fedora Rawhide (glibc 2.43+), libc exposes openat2() and struct open_how,
> > so our configure script defines HAVE_OPENAT2 and the fallback definition in
> > lapi/openat2.h gets skipped. But openat20*.c never included <fcntl.h> (and
> > lacked _GNU_SOURCE), so the libc-provided prototype and struct stayed hidden,
> > so compilation failed:
>
> > # uname -r
> > 6.18.0-65.fc44.x86_64
>
> > # rpm -qf /usr/include/fcntl.h
> > glibc-devel-2.43-1.fc44.x86_64
>
> > # nm -D /usr/lib64/libc.so.6 | grep -w openat2
> > 00000000000eb890 W openat2@@GLIBC_2.43
>
> > # make -C testcase/kernel/syscalls/openat2
> > openat201.c:27:62: error: invalid application of ‘sizeof’ to incomplete type ‘struct open_how’
> > 27 | {&dir_fd, TEST_FILE, O_RDWR, S_IRWXU, 0, &how, sizeof(*how)},
>
> > Define _GNU_SOURCE and include <fcntl.h> in openat2 tests to make the
> > prototype available and fix the build.
>
> > Signed-off-by: Li Wang <liwang@redhat.com>
> > ---
> > testcases/kernel/syscalls/openat2/openat201.c | 3 +++
> > testcases/kernel/syscalls/openat2/openat202.c | 3 +++
> > testcases/kernel/syscalls/openat2/openat203.c | 3 +++
> > 3 files changed, 9 insertions(+)
>
> > diff --git a/testcases/kernel/syscalls/openat2/openat201.c b/testcases/kernel/syscalls/openat2/openat201.c
> > index ecd63b150..40ac2f6d9 100644
> > --- a/testcases/kernel/syscalls/openat2/openat201.c
> > +++ b/testcases/kernel/syscalls/openat2/openat201.c
> > @@ -4,6 +4,9 @@
> > *
> > * Basic openat2() test.
> > */
> > +#define _GNU_SOURCE
>
> Why _GNU_SOURCE? glibc test tst-openat2.c [1] which includes <fcntl.h>, uses
> struct open_how and test openat2() does not define it. Neither openat2() nor
> struct open_how 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.
>
> I mean it's not a big deal, but if it works without it please remove it.
From my test on Fedora-Rawhide, it doesn't work if not define it.
Let me double check. Maybe reply to you tomorrow.
>
> [1] https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/tst-openat2.c
> [2] https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/bits/openat2.h
>
> > +#include <fcntl.h>
>
> Should not we use include lapi/fcntl.h?
>
> > +
> > #include "tst_test.h"
> > #include "lapi/openat2.h"
>
> 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.
Test cases should only include standard header files, and lapi should
only be used in case of missing or conflicting header files.
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-02-04 14:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-03 2:43 [LTP] [PATCH v2 1/2] openat2: define _GNU_SOURCE and include <fcntl.h> Li Wang via ltp
2026-02-03 2:43 ` [LTP] [PATCH v2 2/2] newlib_tests: add tst_filesystems01 to .gitignore Li Wang via ltp
2026-02-04 11:57 ` Petr Vorel
2026-02-04 12:05 ` Li Wang via ltp
2026-02-04 12:26 ` Petr Vorel
2026-02-04 12:23 ` [LTP] [PATCH v2 1/2] openat2: define _GNU_SOURCE and include <fcntl.h> Petr Vorel
2026-02-04 14:20 ` Li Wang via ltp [this message]
2026-02-04 22:27 ` Petr Vorel
2026-02-05 1:44 ` Li Wang via ltp
2026-02-05 10:08 ` Petr Vorel
2026-02-05 10:33 ` Li Wang via ltp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aYNVsiL4xf2P9R6A@redhat.com \
--to=ltp@lists.linux.it \
--cc=liwang@redhat.com \
--cc=pvorel@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.