sys/mount.h vs fcntl.h
DJ Delorie
dj@redhat.com
Tue Feb 3 18:34:35 GMT 2026
Florian Weimer <fweimer@redhat.com> writes:
> I suggest this instead:
>
> #include <bits/cloexec.h>
> #define O_CLOEXEC __O_CLOEXEC
> #define OPEN_TREE_CLOEXEC O_CLOEXEC
>
> So it's identical to the kernel macro definition and no #undef is
> needed.
Do we need an #undef before that first #define, in case it's already
defined? I assume no, since the definitions would be identical (the
user can include fcntl.h before sys/mount.h), but in case they
aren't (because future kernel header conflicts).
> > +/* Both fcntl.h and sys/mount.h include APIs that need O_CLOEXEC.
> > +
> > + So, there's an arch-specific header for this constant, just for
> > + this purpose. We test that it is defined correctly here, and that
> > + fcntl.h can use it. */
>
> You can include both <bits/cloexec.h> and the kernel header
> <linux/fcntl.h> and use static_assert.
That's not what I was testing. The test specifically tests user-level
includes to make sure all the changes I made result in a workable
solution.
> Or write a tst-fcntl-consts.py test that checks all constants. This
> would completely break the build if there's an inconsistency.
I don't think that would be useful for most constants. It would just
mean "any change has to be made twice" without solving any problems.
More information about the Libc-alpha
mailing list