Re: [PATCH] Re: bug in socket.h (and maybe many other kernel headerfiles)

Michael Elizabeth Chastain (mec@shout.net)
Mon, 20 Sep 1999 15:57:22 -0500


Hi Sean,

> Does this patch fix your problem? BTW, to the powers-that-be: all I'm
> doing is an explicit cast. Since I see this elsewhere in the same
> file (NULL with an explicit cast), I assume this is acceptable. Is
> it?

It Works For Me (tm).

I have the same problem -- a C++ program that includes kernel header
files -- and your patch does indeed fix my problem. If it gets into the
kernel then I can take some nasty preprocessor kludges out of my source.

Here's a little background: I have a program like strace, which monitors
the system calls that *other programs* make. I need to #include
the entire userspace-to-kernel ABI so that I can monitor properly.
Using glibc headers doesn't meet my needs at all, because I am not
calling these services, I am using ptrace to watching other processes
call these services.

I chose to write my program in C++ because I like OO programming.

> I'm happy to look for this problem elsewhere in the kernel headers if
> people think its worthwhile.

If you are interested, here is my list of kernel header files that give
me a little trouble:

linux/if_frad.h userland interface depends on CONFIG_DLCI
linux/if_tunnel.h needs #include <linux/ip.h>
linux/if_ppp.h needs #include <linux/ppp_defs.h>
linux/lp.h userland interface depends on LP_STATS
linux/ncp_fs.h uses reserved word "namespace"
linux/nfsd/syscall.h needs __KERNEL__ wrapping
linux/socket.h needs cast: "(struct cmsghdr *) NULL"
linux/videotext.h uses reserved word "delete"
linux/zftape.h userland interface depends on ZFT_OBSOLETE
scsi/scsi_ioctl.h Scsi_Device definition hidden inside __KERNEL__

Here is how I test:

gcc -c -x c++ -include /usr/include/linux/videotext.h /dev/null -o /dev/null

Also there are some bits of the userland interface which are hidden inside
kernel source and not accessible to userland programs. These bits need to
move into linux/*.h headers so that userland programs can see them.

drivers/cdrom/cm206.h some ioctl definitions
drivers/cdrom/sbpcd.h some ioctl definitions
drivers/char/bttv.h struct bttv_poll_info, BTTV_* ioctls
druvers/char/buz.h some ioctl definitions
drivers/char/pc110pad.h some ioctl definitions
drivers/net/wavelan.p.h some SIOC* ioctl definitions
drivers/sound/dm.h some ioctl definitions
include/net/ax24.h AX25_ADDR_LEN is visible to user space
via some SIOCSIFHWADDR calls

I can live with all this stuff but it would be nice if someone cleaned
this up. If any of these are controversial, just let the system be,
and I will work around it.

The original "(struct cmsghdr *) NULL" cast shouldn't be controversial
though; it's always correct and makes life easier for a few people.

Michael Elizabeth Chastain
<mailto:mec@shout.net>
"love without fear"

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/