This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] <sys/stat.h>: Use Linux kernel UAPI header if available and useful
* Andreas Schwab:
> On Jun 06 2019, Florian Weimer <fweimer@redhat.com> wrote:
>
>> * Andreas Schwab:
>>
>>> On Jun 06 2019, Florian Weimer <fweimer@redhat.com> wrote:
>>>
>>>> diff --git a/sysdeps/unix/sysv/linux/statx.c b/sysdeps/unix/sysv/linux/statx.c
>>>> index b99e30dc3e..5d634960a6 100644
>>>> --- a/sysdeps/unix/sysv/linux/statx.c
>>>> +++ b/sysdeps/unix/sysv/linux/statx.c
>>>> @@ -21,6 +21,11 @@
>>>>
>>>> #include "statx_generic.c"
>>>>
>>>> +/* Ensure that the kernel headers have not changed the struct size.
>>>> + If this ever happens, it may be necessary to introduce a new symbol
>>>> + version. */
>>>> +_Static_assert (sizeof (struct statx) == 256, "struct statx size changed");
>>>
>>> Why is that needed? Isn't the point of statx that only the known parts
>>> are filled?
>>
>> There have been some discussions that future kernel versions might add
>> additional fields to the struct, outside the padding. Userspace would
>> request that by setting an additional flag.
>
> And why is that a problem? Either the kernel knows about the flag and
> happily fills the structure, or it will return an error.
The emulation code in io/statx_generic.c does not know about the new
structure and will initialize the full struct statx object, even if the
new flag is not specified.
Thanks,
Florian