Since few days, I am working on a little project in order to discover the kernel programming. However, I read a lot on the internet and asked a question before about kernel compilation and I feel still lost at some point.
If I need to do some kernel programming, I thought that use the Linus Torvalds's Linux sources would be the best point to start. So I did the following (From MacOS High Sierra):
- Download kernel's sources: https://github.com/torvalds/linux
- Unzipped it
- Launch a terminal and run:
vagrant init
vagrant up
vagrant ssh
- Once connected, I typed:
cd /vagrant/linux
In order to get into the Linux sources unzipped foldermake menuconfig
I just pressed ok/savesudo make -j 4 && sudo make modules_install -j 4 && sudo make install -j 4
Now, I just get a little error:
agrant @vagrant-ubuntu-trusty-64:/vagrant/Kernel-Programming/linx-kernel$ sudo make -j 4 && sudo make modules_install -j 4 && sudo make install -j 4
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
CHK scripts/mod/devicetable-offsets.h
CHK include/generated/timeconst.h
CHK include/generated/bounds.h
CHK include/generated/asm-offsets.h
CALL scripts/checksyscalls.sh
CHK include/generated/compile.h
SKIPPED include/generated/compile.h
CC my_syscalls/uptime.o
AR my_syscalls/built-in.o
CC[M] net/ipv4/netfilter/ipt_ECN.o
In file included from net/ipv4/netfilter/ipt_ECN.c:20:0:
net/ipv4/netfilter/ipt_ECN.c: In function 'set_ect_ip':
./include/uapi/linux/netfilter_ipv4/ipt_ECN.h:16:27: error: 'XT_DSCP_MASK' undeclared(first use in this function)
#define IPT_ECN_IP_MASK (~XT_DSCP_MASK)
^
net/ipv4/netfilter/ipt_ECN.c:33:18: note: in expansion of macro 'IPT_ECN_IP_MASK'
if ((iph->tos & IPT_ECN_IP_MASK) != (einfo->ip_ect & IPT_ECN_IP_MASK)) {
^
./include/uapi/linux/netfilter_ipv4/ipt_ECN.h:16:27: note: each undeclared identifier is reported only once for each function it appears in
#define IPT_ECN_IP_MASK (~XT_DSCP_MASK)
^
net/ipv4/netfilter/ipt_ECN.c:33:18: note: in expansion of macro 'IPT_ECN_IP_MASK'
if ((iph->tos & IPT_ECN_IP_MASK) != (einfo->ip_ect & IPT_ECN_IP_MASK)) {
^
net/ipv4/netfilter/ipt_ECN.c: In function 'ecn_tg_check':
./include/uapi/linux/netfilter_ipv4/ipt_ECN.h:16:27: error: 'XT_DSCP_MASK' undeclared(first use in this function)
#define IPT_ECN_IP_MASK (~XT_DSCP_MASK)
^
net/ipv4/netfilter/ipt_ECN.c:105:23: note: in expansion of macro 'IPT_ECN_IP_MASK'
if (einfo->ip_ect & ~IPT_ECN_IP_MASK)
{
^
make[3]: *** [net / ipv4 / netfilter / ipt_ECN.o] Error 1
make[2]: *** [net / ipv4 / netfilter] Error 2
make[1]: *** [net / ipv4] Error 2
make: *** [net] Error 2
make: ***Waiting for unfinished jobs....
However, I don't know if this error breaks everything at all or not. Also, even if the compilation is fully ok, how can I test my "new Linux compiled"? Because I added a syscall and I would like to test if it works or no ... I found something about update-initramfs
but I don't see the link/point since my compiled kernel isn't an Ubuntu.