linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Landley <rob@landley.net>
To: Jeff Garzik <jgarzik@pobox.com>
Cc: Linus Torvalds <torvalds@osdl.org>,
	Paul Mackerras <paulus@samba.org>, Greg KH <greg@kroah.com>,
	David Woodhouse <dwmw2@infradead.org>,
	Matthew Wilcox <matthew@wil.cx>,
	David Howells <dhowells@redhat.com>,
	hch@infradead.org, aoliva@redhat.com,
	linux-kernel@vger.kernel.org, libc-hacker@sources.redhat.com,
	Mariusz Mazur <mmazur@kernel.pl>,
	Arjan van de Ven <arjanv@redhat.com>,
	andersen@codepoet.org
Subject: Re: [RFC] Splitting kernel headers and deprecating __KERNEL__
Date: Sat, 4 Dec 2004 19:49:57 -0500	[thread overview]
Message-ID: <200412041949.57466.rob@landley.net> (raw)
In-Reply-To: <41AAA746.5000003@pobox.com>

On Sunday 28 November 2004 11:36 pm, Jeff Garzik wrote:
> Linus Torvalds wrote:
> > In short: having the kernel use the same names as user space is ACTIVELY
> > BAD, exactly because those names have standards-defined visibility, which
> > means that the kernel _cannot_ use them in all places anyway. So don't
> > even _try_.
> >
> > On the bigger question of what to do with kernel headers in general,
> > let's just make one thing clear: the kernel headers are for the kernel,
> > and big and painful re-organizations that don't help _existing_ user
> > space are not going to happen.
> >
> > In particular, any re-organization that breaks _existing_ uses is totally
> > pointless. If you break existing uses, you might as well _not_ re-
> > organize, since if you consider kernel headers to be purely kernel-
> > internal (like they should be, but hey, reality trumps any wishes we
> > might have), then the current organization is perfectly fine.
>
> I don't think any drastic reorganization is even necessary.
>
> Mariusz Mazur <mmazur@kernel.pl> updates
> http://ep09.pld-linux.org/~mmazur/linux-libc-headers/ for each 2.6.x
> kernel release.  linux-libc-headers are the kernel headers, with all the
> kernel-specific stuff stripped out.  i.e. userland ABI only.  Not sure
> how many distros have started picking that up yet...  I think Arjan said
> Fedora Core had, or would.

I've got a problem that mmazur's headers come down on one side of and Eric 
Andersen of the busybox project comes down on the other side of.  How the 
heck do you implement losetup without including linux/loop.h?

The way both busybox and util-linux do it is the to block copy out lots of 
ugly crap, include linux/version.h, and have #ifdefs to fix up differences 
between known kernel versions.  I'm serious.  This is from 
busybox/libbb/loop.c, but you can get an even more obfuscated variant of it 
out of util-linux:

--------------

/* Grumble...  The 2.6.x kernel breaks asm/posix_types.h
 * so we get to try and cope as best we can... */
#include <linux/version.h>
#include <asm/posix_types.h>

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
#define __bb_kernel_dev_t   __kernel_old_dev_t
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
#define __bb_kernel_dev_t   __kernel_dev_t
#else
#define __bb_kernel_dev_t   unsigned short
#endif

/* Stuff stolen from linux/loop.h */
#define LO_NAME_SIZE        64
#define LO_KEY_SIZE         32
#define LOOP_SET_FD         0x4C00
#define LOOP_CLR_FD         0x4C01
#define LOOP_SET_STATUS     0x4C02
#define LOOP_GET_STATUS     0x4C03
struct loop_info {
    int                lo_number;
    __bb_kernel_dev_t  lo_device;
    unsigned long      lo_inode;
    __bb_kernel_dev_t  lo_rdevice;
    int                lo_offset;
    int                lo_encrypt_type;
    int                lo_encrypt_key_size;
    int                lo_flags;
    char               lo_name[LO_NAME_SIZE];
    unsigned char      lo_encrypt_key[LO_KEY_SIZE];
    unsigned long      lo_init[2];
    char               reserved[4];
};

----------------------

When I submitted a patch to clean it up on the busybox list (fixing a real 
compile problem I had with maszur's 2.6.6.0 kernel headers):
http://www.busybox.net/lists/busybox/2004-November/013128.html

I got this response:
http://www.busybox.net/lists/busybox/2004-November/013132.html

> No no no no no no no no no!
>
> Rule #1: Never ever include kernel header files in user space.
> Rule #2: See Rule #1
> Rule #3: See Rule #2

Apparently, linux/version.h isn't considered a kernel header?

Somehow, including linux/loop.h is considered bad, but including 
linux/version.h and having version specific #ifdefs in our code to fix up a 
block copied header for the specific kernel versions we know about is LESS 
incestuous knowledge.  (After all, the above will OBVIOUSLY work on BSD, is 
guaranteed to continue to compile without modification under the 2.8 kernel, 
and is in generally much cleaner than deleting all that crap and just 
including linux/loop.h.)

I still don't understand the reasoning here.  Mazur's cleaned-up kernel 
headers include a cleaned up version of linux/loop.h because loop_info simply 
isn't defined anywhere else we can #include, and it's something you need in 
order to set up loop devices.  It's a structure userspace and the kernel use 
to pass data back and forth, both need to include it.  Any _new_ header file 
created won't exist on 2.4, but this header IS there on 2.4, and 2.2, and 
2.6.  Including linux/loop.h is the only thing that will _work_, both in 
current and in future versions.

How is this _supposed_ to be done?

Rob

  parent reply	other threads:[~2004-12-05  1:51 UTC|newest]

Thread overview: 185+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-25 15:13 [RFC] Splitting kernel headers and deprecating __KERNEL__ David Howells
2004-11-25 15:23 ` David Woodhouse
2004-11-25 16:54 ` Matthew Wilcox
2004-11-25 18:17   ` David Woodhouse
2004-11-27  3:24     ` Greg KH
2004-11-28 23:37       ` Paul Mackerras
2004-11-29  1:28         ` Linus Torvalds
2004-11-29  4:36           ` Jeff Garzik
2004-11-29  4:57             ` Al Viro
2004-11-29  5:27               ` Tim Hockin
2004-11-29  7:51             ` Arjan van de Ven
2004-12-05  0:49             ` Rob Landley [this message]
2004-12-05  2:26               ` Andries Brouwer
2004-12-05 13:19                 ` David Greaves
2004-12-05 15:57                   ` Andries Brouwer
2004-12-05 23:05                     ` Rob Landley
2004-12-06  9:56                       ` Andries Brouwer
2004-11-29  9:42           ` David Woodhouse
2004-11-30  8:08             ` Alex Riesen
2004-11-30  8:57               ` Alex Riesen
2004-12-01 11:46             ` Ralf Baechle
2004-12-02  1:21               ` H. Peter Anvin
2004-11-29  9:53           ` Paul Mackerras
2004-11-29  9:57             ` Arjan van de Ven
2004-11-29 10:01               ` David Woodhouse
2004-11-29 11:41           ` Mariusz Mazur
2004-11-29 17:09           ` Alexandre Oliva
2004-11-29 17:41             ` Linus Torvalds
2004-11-29 22:44               ` Al Viro
2004-12-01 11:36                 ` Roman Zippel
     [not found]               ` <oract0thnj.fsf@livre.redhat.lsd.ic.unicamp.br>
2004-11-29 23:00                 ` Linus Torvalds
2004-11-30  0:45                   ` H. Peter Anvin
2004-11-30  5:31                   ` Herbert Poetzl
2004-11-30  6:44                   ` bert hubert
2004-11-30 21:22                   ` Alexandre Oliva
2004-11-30 22:22                     ` Linus Torvalds
2004-11-30 22:57                       ` Alexandre Oliva
2004-11-30 23:12                         ` Linus Torvalds
2004-12-01 19:41                           ` Alexandre Oliva
2004-12-01 19:54                             ` Matthew Wilcox
2004-12-02  3:58                             ` Linus Torvalds
2004-12-02  4:28                               ` Bernd Eckenfels
2004-12-02  5:11                                 ` Peter Williams
2004-12-02 11:30                                   ` Tomas Carnecky
2004-12-02 22:17                                     ` Peter Williams
2004-12-02  9:29                               ` Pekka Enberg
2004-12-02 15:35                                 ` Linus Torvalds
2004-12-02 21:46                                   ` Pekka Enberg
2004-11-30 15:35               ` David Woodhouse
2004-11-30 15:58                 ` Linus Torvalds
2004-11-30 16:28                   ` David Woodhouse
2004-11-30 16:53                     ` Linus Torvalds
2004-11-30 17:52                       ` David Woodhouse
2004-11-30 18:21                         ` Linus Torvalds
2004-11-30 20:28                           ` Mariusz Mazur
2004-11-30 20:47                             ` Linus Torvalds
2004-11-30 22:33                               ` Sam Ravnborg
2004-11-30 22:44                                 ` Mariusz Mazur
2004-11-30 23:03                                   ` Al Viro
2004-11-30 23:08                                     ` Mariusz Mazur
2004-12-01  5:23                                       ` Sam Ravnborg
2004-12-01 10:52                                         ` Mariusz Mazur
2004-12-01 18:08                                           ` Sam Ravnborg
2004-11-30 23:13                                     ` Alexandre Oliva
2004-11-30 23:36                                     ` Chris Friesen
2004-12-01  5:50                               ` H. Peter Anvin
2004-11-30 22:48                           ` Matt Mackall
2004-11-30 22:51                             ` Christoph Hellwig
2004-11-30 23:09                               ` Chris Friesen
2004-11-30 23:35                                 ` Matt Mackall
2004-12-01  0:23                                 ` Miquel van Smoorenburg
2004-11-30 22:55                             ` Linus Torvalds
2004-11-30 23:29                               ` Matt Mackall
2004-12-03  1:03                                 ` Krzysztof Halasa
2004-11-30 23:51                               ` David Woodhouse
2004-11-30 17:55                       ` Al Viro
2004-11-30 16:33                 ` David Howells
2004-11-30 16:57                   ` Linus Torvalds
2004-11-30 15:33             ` David Howells
2004-11-30 15:51               ` Linus Torvalds
2004-11-30 20:47                 ` Alexandre Oliva
2004-11-30 20:56                   ` Linus Torvalds
2004-11-30 21:30                     ` Alexandre Oliva
2004-11-30 21:39                       ` Alexandre Oliva
2004-11-30 23:33                         ` Matthew Wilcox
2004-11-30 22:25                       ` Linus Torvalds
2004-11-30 22:34                         ` David Woodhouse
2004-11-30 22:51                           ` Linus Torvalds
2004-11-30 23:50                             ` David Woodhouse
2004-12-01  0:10                               ` Linus Torvalds
2004-12-01  0:18                                 ` Linus Torvalds
2004-12-01  8:10                                   ` Arjan van de Ven
2004-12-01  0:24                                 ` David Woodhouse
2004-12-01  0:37                                   ` Linus Torvalds
2004-12-01  0:47                                     ` David Woodhouse
2004-12-01  0:57                                       ` Linus Torvalds
2004-12-01  1:06                                         ` David Woodhouse
2004-12-01  1:23                                           ` Linus Torvalds
2004-12-01  6:48                                           ` BAIN
2004-12-01  2:02                               ` cdrom.h (was Re: [RFC] Splitting kernel headers...) Matthew Wilcox
2004-11-30 22:52                         ` [RFC] Splitting kernel headers and deprecating __KERNEL__ Mariusz Mazur
2004-11-30 23:05                           ` Linus Torvalds
2004-11-30 23:05                         ` Alexandre Oliva
2004-11-30 16:18               ` David Howells
2004-12-14  5:51           ` Werner Almesberger
2004-12-14 15:49             ` Linus Torvalds
2004-12-14 16:50               ` Werner Almesberger
2004-12-14 17:58                 ` Linus Torvalds
2004-12-14 21:46                   ` Werner Almesberger
2004-12-14 21:58                     ` Linus Torvalds
2004-12-14 23:49                     ` Krzysztof Halasa
2004-12-15  0:09                       ` Werner Almesberger
2004-12-16  0:58                         ` Krzysztof Halasa
2004-12-14 19:23                 ` Horst von Brand
2004-12-14 19:45                   ` Sam Ravnborg
2004-12-14 19:58                     ` Linus Torvalds
2004-12-14 20:25                       ` Andreas Schwab
2004-12-14 20:33                         ` Linus Torvalds
2004-12-14 16:55               ` Andreas Schwab
2004-12-14 17:59                 ` Linus Torvalds
2004-11-27 20:39   ` Sam Ravnborg
2004-11-25 18:20 ` Alexandre Oliva
2004-11-25 21:01   ` Matthew Wilcox
2004-11-25 22:35     ` David Woodhouse
2004-11-26 11:42       ` Alexandre Oliva
2004-11-27  0:13       ` Andreas Steinmetz
2004-11-27  0:26         ` David Woodhouse
2004-11-27  0:30           ` Andreas Steinmetz
2004-11-27  0:38             ` David Woodhouse
2004-11-26 11:47     ` Alexandre Oliva
2004-11-26 11:53       ` David Woodhouse
2004-11-27 16:12       ` Krzysztof Halasa
2004-11-26 11:58   ` David Howells
2004-11-26 12:00     ` David Woodhouse
2004-11-26 14:19       ` Matthew Wilcox
2004-11-26 14:33         ` David Woodhouse
2004-11-27 12:10           ` Alexander Stohr
2004-11-27  3:46         ` Adam Heath
2004-11-30 12:18         ` Horst von Brand
2004-11-29 16:34     ` Alexandre Oliva
2004-11-25 18:45 ` Matthew Wilcox
2004-11-26 11:52 ` David Howells
2004-11-26 23:56 ` Grzegorz Kulewski
2004-11-27  1:27   ` Tomas Carnecky
2004-11-27  1:41     ` Grzegorz Kulewski
2004-11-27  2:03       ` Tomas Carnecky
2004-11-27  3:07 ` Kyle Moffett
2004-11-27  4:29 ` Tonnerre
2004-11-27  3:51   ` Matthew Wilcox
2004-11-27 16:47     ` Randy.Dunlap
2004-11-27 17:16       ` David Woodhouse
2004-11-27 22:53         ` Arnd Bergmann
2004-11-27 23:12           ` David Woodhouse
2004-11-27 23:27           ` Randy.Dunlap
2004-11-27 23:32             ` David Woodhouse
2004-11-27 23:56               ` Arnd Bergmann
2004-11-28  7:13           ` Arjan van de Ven
2004-11-28 12:03             ` Arnd Bergmann
2004-11-28 12:19               ` Arjan van de Ven
2004-11-28 16:34                 ` Kevin Puetz
2004-11-28 12:28               ` Wichert Akkerman
2004-11-28 12:44                 ` Arjan van de Ven
2004-11-28 16:21             ` Jakub Jelinek
2004-11-28  7:20           ` Christoph Hellwig
2004-11-27  4:05   ` Chris Friesen
2004-11-27  4:30   ` Tomas Carnecky
2004-11-27 21:03 ` Sam Ravnborg
2004-11-27 21:11   ` Andreas Steinmetz
2004-11-27 21:19     ` Sam Ravnborg
2004-11-27 21:49       ` Andreas Steinmetz
2004-11-27 23:21         ` Arnd Bergmann
2004-11-28 13:24           ` Andreas Steinmetz
2004-11-28 13:40             ` Arnd Bergmann
2004-11-29 11:08 ` David Howells
2004-11-29 20:01 ` H. Peter Anvin
2004-11-30  0:34   ` Kyle Moffett
2004-11-30  0:51     ` H. Peter Anvin
2004-12-14  7:07   ` Werner Almesberger
2004-11-27 19:43 Dan Kegel
2004-11-27 21:06 ` Sam Ravnborg
     [not found] <34Xo6-2P0-19@gated-at.bofh.it>
     [not found] ` <35i9f-2vZ-25@gated-at.bofh.it>
     [not found]   ` <35iLS-2Uo-1@gated-at.bofh.it>
     [not found]     ` <35kb6-46Q-25@gated-at.bofh.it>
2004-11-28  0:55       ` ak
2004-11-28 13:32         ` Arnd Bergmann
2004-11-30  1:43 Jean Tourrilhes
2004-11-30  4:22 ` Linus Torvalds
2004-11-30  6:51   ` H. Peter Anvin

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=200412041949.57466.rob@landley.net \
    --to=rob@landley.net \
    --cc=andersen@codepoet.org \
    --cc=aoliva@redhat.com \
    --cc=arjanv@redhat.com \
    --cc=dhowells@redhat.com \
    --cc=dwmw2@infradead.org \
    --cc=greg@kroah.com \
    --cc=hch@infradead.org \
    --cc=jgarzik@pobox.com \
    --cc=libc-hacker@sources.redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew@wil.cx \
    --cc=mmazur@kernel.pl \
    --cc=paulus@samba.org \
    --cc=torvalds@osdl.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 NNTP newsgroup(s).