include/linux/xattr.h: how much userpace visible?
Hi,
how much of include/linux/xattr.h has to be part of the userspace kernel headers?
The function prototypes should no longer be visible in userspace. But how much of the rest of this file is usable for userspace?
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedQuoted 5 lines · Adrian Bunk
how much of
include/linux/xattr.hhas to be part of the userspace kernel headers?The function prototypes should no longer be visible in userspace. But how much of the rest of this file is usable for userspace?
XATTR_CREATE, XATTR_REPLACE are passed to sys_setxattr syscall. struct xattr_handler is ours (it uses struct inode *). Prototypes are ours.
Quoted 4 lines · Adrian Bunk
Hi,
how much of
include/linux/xattr.hhas to be part of the userspace kernel headers?
None, I think.
Quoted 2 lines
The function prototypes should no longer be visible in userspace. But how much of the rest of this file is usable for userspace?
The attr package has its own distinct copy of this file, which has no kernel pieces - I'm not sure whether libc ended up copying this or doing its own thing though.
cheers.
Signature · 1 line
Nathan
Quoted 7 lines · Nathan Scott
Quoted 4 lines · Adrian Bunk
Hi,
how much of
include/linux/xattr.hhas to be part of the userspace kernel headers?None, I think.
None, indeed. The attr package comes with it own version of xattr.h that also includes definitions of XATTR_CREATE and XATTR_REPLACE.
Andreas
Quoted 11 lines · Andreas Gruenbacher
Quoted 7 lines · Nathan Scott
Quoted 4 lines · Adrian Bunk
Hi,
how much of
include/linux/xattr.hhas to be part of the userspace kernel headers?None, I think.
None, indeed. The attr package comes with it own version of
xattr.hthat also includes definitions ofXATTR_CREATEandXATTR_REPLACE.
The userspace headers are supposed to hold the part of the kernel definitions that glibc (and mayby the attr package) uses. If they happen to have their own copy now should not impct the decision what is part of the userspace interface for the kernel. So actual usage does not decide what is part of the userspace kernel headers but what definitionas are definitions the userspace <-> kernel interface.
Sam
Quoted 6 lines · Sam Ravnborg
The userspace headers are supposed to hold the part of the kernel definitions that glibc (and mayby the attr package) uses. If they happen to have their own copy now should not impct the decision what is part of the userspace interface for the kernel. So actual usage does not decide what is part of the userspace kernel headers but what definitionas are definitions the userspace <-> kernel interface.
Sure, fine by me.
Andreas
Quoted 10 lines · Andreas Gruenbacher
Quoted 6 lines · Nathan Scott
Quoted 4 lines · Adrian Bunk
Hi,
how much of
include/linux/xattr.hhas to be part of the userspace kernel headers?None, I think.
None, indeed. The attr package comes with it own version of
xattr.hthat also includes definitions ofXATTR_CREATEandXATTR_REPLACE.
However, it would be better if the ABI constants were exported, or at least *exportable* (using a __KERNEL_XATTR_MACROS test macro or something like that.)
-hpa
Quoted 6 lines · Sam Ravnborg
The userspace headers are supposed to hold the part of the kernel definitions that glibc (and mayby the attr package) uses. If they happen to have their own copy now should not impct the decision what is part of the userspace interface for the kernel. So actual usage does not decide what is part of the userspace kernel headers but what definitionas are definitions the userspace <-> kernel interface.
glibc, or another libc.
Basically, the kernel should be able to export the things that userspace needs to be able to correctly speak the ABI.
-hpa
From: "H. Peter Anvin" <[email protected]>
Date: Mon, 26 Feb 2007 15:28:57 -0800
Quoted 9 lines
Quoted 8 lines · Andreas Gruenbacher
Quoted 6 lines · Nathan Scott
Quoted 4 lines · Adrian Bunk
Hi,
how much of
include/linux/xattr.hhas to be part of the userspace kernel headers?None, I think.
Quoted 7 lines
Quoted 3 lines
None, indeed. The attr package comes with it own version of
xattr.hthat also includes definitions ofXATTR_CREATEandXATTR_REPLACE.However, it would be better if the ABI constants were exported, or at least *exportable* (using a
__KERNEL_XATTR_MACROStest macro or something like that.)
This is the same situation as the socket.h issue we're trying to figure out what to do about.
wrt. the socket.h case I think I'm going to revert the guilty changeset for now until a better scheme is implemented
Quoted 8 lines · David Miller
Quoted 2 lines
Quoted 1 line
However, it would be better if the ABI constants were exported, or at least *exportable* (using a
__KERNEL_XATTR_MACROStest macro or something like that.)This is the same situation as the
socket.hissue we're trying to figure out what to do about.wrt. the
socket.hcase I think I'm going to revert the guilty changeset for now until a better scheme is implemented
Indeed it is (as well as <linux/stat.h>).
I believe the use of feature macros is probably the way to go; that way userspace can request subsets, which can vary from libc to libc.
There is, of course, the "ABI language" variant, but I don't see that happening unless someone has a lot of time to spend on it.
-hpa
Quoted 12 lines · H. Peter Anvin
Quoted 10 lines · David Miller
Quoted 4 lines
Quoted 1 line
However, it would be better if the ABI constants were exported, or at least *exportable* (using a
__KERNEL_XATTR_MACROStest macro or something like that.)This is the same situation as the
socket.hissue we're trying to figure out what to do about.wrt. the
socket.hcase I think I'm going to revert the guilty changeset for now until a better scheme is implemented
Quoted 7 lines
Indeed it is (as well as <
linux/stat.h>).I believe the use of feature macros is probably the way to go; that way userspace can request subsets, which can vary from libc to libc.
There is, of course, the "ABI language" variant, but I don't see that happening unless someone has a lot of time to spend on it.
What's the problem of exposing all these APIs unconditionally? glibcs should either use all information from the linux/ headers or nothing at all, but not depend on hiding some bits.
Quoted 3 lines · Christoph Hellwig
What's the problem of exposing all these APIs unconditionally? glibcs should either use all information from the linux/ headers or nothing at all, but not depend on hiding some bits.
It's not always that simple. In particular, in some files there might be typedefs or structure tags that step on libc's namespace (but are useful to other libcs), but ABI constants that are universally useful.
One way to deal with the particular issue of structure tags which is probably even more useful is:
#if defined(__KERNEL__) || defined(__KERNEL_EXPORT_STRUCTURES)
# define __kstruct_stat stat #endif
struct __kstruct_stat {
/* ...foo... */
};... which lets the libc export it into whatever namespace it wants by #defining __kstruct macros accordingly.
-hpa
Quoted 8 lines · H. Peter Anvin
Quoted 1 line · Christoph Hellwig
What's the problem of exposing all these APIs unconditionally? glibcs should either use all information from the linux/ headers or nothing at all, but not depend on hiding some bits.
It's not always that simple. In particular, in some files there might be typedefs or structure tags that step on libc's namespace (but are useful to other libcs), but ABI constants that are universally useful.
One way to deal with the particular issue of structure tags which is probably even more useful is:
#if
defined(__KERNEL__)||defined(__KERNEL_EXPORT_STRUCTURES)
Quoted 8 lines
# define __kstruct_stat stat #endifstruct __kstruct_stat { /* ...foo... */ };... which lets the libc export it into whatever namespace it wants by #defining
__kstructmacros accordingly.
Not a bad idea, but it could use some extra error checking to make sure that somebody remembers to "#define __kstruct_foo" before "#include <linux/foo.h>" (perhaps indirectly through linux/bar.h). Maybe something like this (plays nice with the very-basic unifdef parsing too):
#ifdef __KERNEL__
# define __kstruct_stat stat # define __kstruct_foo foo # define __kstruct_bar bar #endif
#ifdef __LINUX_KERNEL_EXPORT
# define __kstruct_stat stat # define __kstruct_foo foo # define __kstruct_bar bar #endif
#ifndef __kstruct_stat
# error "Missing definition of __kstruct_stat, please insert:"
# error " #define __kstruct_stat <name-for-stat-struct>"
# error "into your C file before '#include <linux/foo.h>'"
#endif
struct __kstruct_stat {
}Someone who wanted to keep the name __kstruct_stat could of course "#define __kstruct_stat __kstruct_stat" easily.
Cheers,
Kyle Moffett
Quoted 16 lines · Kyle Moffett
Not a bad idea, but it could use some extra error checking to make sure that somebody remembers to "#define
__kstruct_foo" before "#include <linux/foo.h>" (perhaps indirectly throughlinux/bar.h). Maybe something like this (plays nice with the very-basic unifdef parsing too):#ifdef
__KERNEL__# define __kstruct_stat stat # define __kstruct_foo foo # define __kstruct_bar bar #endif#ifdef
__LINUX_KERNEL_EXPORT# define __kstruct_stat stat # define __kstruct_foo foo # define __kstruct_bar bar #endif#ifndef
__kstruct_stat
Quoted 9 lines
# error "Missing definition of __kstruct_stat, please insert:" # error " #define __kstruct_stat <name-for-stat-struct>" # error "into your C file before '#include <linux/foo.h>'" #endif struct __kstruct_stat { }Someone who wanted to keep the name
__kstruct_statcould of course "#define__kstruct_stat__kstruct_stat" easily.
True, but if someone makes errors on that level in your libc, don't you think the fact that gcc will throw an error is sufficient? Writing that kind of error generators is a lot of work, and probably for little gain.
-hpa