Because those programs are build to use things defined in the kernel headers:
busybox-1.22.1]$ egrep -RHn '^#include <linux'
modutils/modutils-24.c:194:#include <linux/elf-em.h>
include/fix_u32.h:17:#include <linux/types.h>
libbb/loop.c:11:#include <linux/version.h>
console-tools/openvt.c:23:#include <linux/vt.h>
console-tools/kbd_mode.c:23:#include <linux/kd.h>
console-tools/showkey.c:19:#include <linux/kd.h>
util-linux/blockdev.c:36:#include <linux/fs.h>
util-linux/mkfs_ext2.c:50:#include <linux/fs.h>
util-linux/mkfs_vfat.c:28:#include <linux/hdreg.h> /* HDIO_GETGEO */
util-linux/mkfs_vfat.c:29:#include <linux/fd.h> /* FDGETPRM */
....
For each specific tool, you'd need to read the source of the tool and the relevant kernel header to figure out exactly what.
You can see a few things are commented to make it easy.
For example, mkfs_vfat
includes linux/fd.h
to get FDGETPRM
:
$ egrep -RHn FDGETPRM util-linux/mkfs_vfat.c
util-linux/mkfs_vfat.c:29:#include <linux/fd.h> /* FDGETPRM */
util-linux/mkfs_vfat.c:351: int not_floppy = ioctl(dev, FDGETPRM, ¶m);
You could probably remove the relevant #include
and watch for compiler errors to make it easier, you'll get warnings that some things are not defined. Those things likely come from the kernel headers.
include <linux/*.h>
to open a socket? (I was aiming for sys/socket.h)