Using <linux/stat.h> for _GNU_SOURCE

Carlos O'Donell carlos@redhat.com
Mon Nov 6 17:20:00 GMT 2017


On 11/06/2017 07:58 AM, Joseph Myers wrote:
> On Mon, 6 Nov 2017, Florian Weimer wrote:
> 
>> Would it be possible to include <linux/stat.h> (not <asm/stat.h>) from
>> <sys/stat.h> for _GNU_SOURCE?  We'd need to add redefinition guards for the
>> S_* macros defined in <linux/stat.h>, but otherwise, the header looks quite
>> clean.
> 
> S_* appear to have conditionals
> 
> #if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
> 
> in <linux/stat.h>, so I don't think any guards are needed.
> 
>> This would allow us to obtain the STX_* constants and struct statx from the
>> uapi header, without maintaining our own copy of that information. Or wouldn't
> 
> Note that if you start using any such constants and types in glibc such 
> that they need to be available when glibc is built, that would imply a 
> major change in the minimum supported kernel headers version for building 
> glibc (as opposed to the minimum kernel version supported at runtime, so 
> less problematic), from 3.2 to 4.11.

I would not object to such a requirement. It would mean downstream distributions
might start decoupling their glibc builds from the kernel builds by using the
latest released kernel headers to build glibc. This would be a good thing since
it enables newer features as they appear, and really exercises the newer UAPI
headers.

-- 
Cheers,
Carlos.



More information about the Libc-alpha mailing list