From: Florian Weimer <fweimer@redhat.com>
To: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH] linux: Fix sys/mount.h usage with kernel headers
Date: Wed, 10 Aug 2022 17:27:38 +0200 [thread overview]
Message-ID: <87pmh89l05.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <51eb6bd9-829a-9c3c-4191-2f511a86e276@linaro.org> (Adhemerval Zanella Netto's message of "Wed, 10 Aug 2022 11:57:14 -0300")
* Adhemerval Zanella Netto:
>>> diff --git a/sysdeps/unix/sysv/linux/sys/mount.h b/sysdeps/unix/sysv/linux/sys/mount.h
>>> index f965986ba8..ae8406838b 100644
>>> --- a/sysdeps/unix/sysv/linux/sys/mount.h
>>> +++ b/sysdeps/unix/sysv/linux/sys/mount.h
>>> @@ -27,6 +27,19 @@
>>> #include <stddef.h>
>>> #include <sys/ioctl.h>
>>>
>>> +#ifdef __has_include
>>> +# if __has_include ("linux/mount.h")
>>> +# include "linux/mount.h"
>>> +# ifdef FSOPEN_CLOEXEC
>>> +# define __mount_fsopen_cloexec_defined 1
>>> +# endif
>>> +# ifdef MOUNT_ATTR_SIZE_VER0
>>> +# define __mount_attr_size_ver0_defined 1
>>> +# endif
>>> +# endif
>>> +#endif
>>
>> I think those __mount_ defines are not *that* useful.
>
> Not sure I am following, should I remove them? If so it would require
> some more ifdefs on their usage below.
Yes, basically check FSOPEN_CLOEXEC and MOUNT_ATTR_SIZE_VER0 directly.
It's required to get this to work without __has_include, if I'm not
mistkaen.
>>> +
>>> +#undef BLOCK_SIZE
>>> #define BLOCK_SIZE 1024
>>
>> If we don't have enum constants, should we #undef things? If we
>> redefine as the same token as the kernel, there won't be a preprocessor
>> warning.
>
> This is required because of linux/fs.h (I caught it with the new testcase).
> Not sure if this is really required now that kernel is avoid including
> linux/mount.h on linux/fs.h.
Ah. BLOCK_SIZE is special:
#define BLOCK_SIZE_BITS 10
#define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
So not 1024 and hence warning-prone.
But for the other definitions that use integer literals, we should
probably use the same literal as the kernel in our headers and not
#undef these constants (as an additional consistency check).
Thanks,
Florian
prev parent reply other threads:[~2022-08-10 15:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-09 17:22 Adhemerval Zanella
2022-08-09 17:43 ` Yann Droneaud
2022-08-09 18:51 ` Adhemerval Zanella Netto
2022-08-10 9:23 ` Florian Weimer
2022-08-10 14:57 ` Adhemerval Zanella Netto
2022-08-10 15:27 ` Florian Weimer [this message]
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=87pmh89l05.fsf@oldenburg.str.redhat.com \
--to=fweimer@redhat.com \
--cc=adhemerval.zanella@linaro.org \
--cc=libc-alpha@sourceware.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).