Re: PATCH: linux-2.4.0-test12pre8/include/linux/module.h breaks sysklogd compilation

Peter Samuelson
2000-12-12T02:24:16Z

[Mohammad A. Haque]
> Wasn't there discussion that user space apps shouldn't include kernel
> headers?

Oh, it's been discussed, many times. Here is my executive summary of
why nobody needs to use kernel headers in userspace programs, *EVER*:

Q: I want to #include <linux/foo.h> but I get compile errors, please
apply this patch to foo.h.

A: Make a copy of foo.h, fix it up to compile properly in your
application and ship it in your tarball.

Q: What if foo.h changes? My copy will be out of date and my app will
not work properly on new kernels.

A: This is exactly the same problem as userspace ABI drift. And it has
exactly the same solution: make sure userspace interfaces to kernel
functionality are as stable as possible. We really *do* try not to
gratuitously break binaries ... except certain system utilities
which are low-level enough to justify telling the user to upgrade
(and that's a short list -- see Documentation/Changes.)

Q: What about new features? What if foo.h gets some new ioctl
definitions? My copy won't have these and my app won't be able to
use them.

A: So resync with the kernel copy, when the need arises. Obviously
your app won't magically be able to just use the new functionality
without other changes on your part -- resyncing foo.h is just a
small part of the changes you are already making anyway.

Q: I maintain a subsystem with tightly-coupled userspace and kernel
components.

A: So maintain *your* header files however you wish, but just ship
separate copies in your kernel patches and userspace tarballs.

Peter