diff --git a/README.md b/README.md index a439c4f..5e53022 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ First build will take a while (GCC, Linux kernel). QEMU opens up, and you can run: + root insmod /hello.ko insmod /hello2.ko rmmod hello diff --git a/kernel_module/test/Makefile b/kernel_module/test/Makefile index 967dd33..62a3275 100644 --- a/kernel_module/test/Makefile +++ b/kernel_module/test/Makefile @@ -1,9 +1,16 @@ -CC = gcc .PHONY: clean -ins_rm_mod: ins_rm_mod.c +CC ?= gcc +IN_EXT ?= .c +OUT_EXT ?= .out + +OUTS := $(addsuffix $(OUT_EXT), $(basename $(wildcard *$(IN_EXT)))) + +all: $(OUTS) + +%$(OUT_EXT): %$(IN_EXT) $(CC) -o '$@' '$<' clean: - rm ins_rm_mod + rm -f *'$(OUT_EXT)' diff --git a/kernel_module/test/ins_rm_mod b/kernel_module/test/ins_rm_mod deleted file mode 100755 index c4f7df7..0000000 Binary files a/kernel_module/test/ins_rm_mod and /dev/null differ diff --git a/rootfs_overlay/debugfs.sh b/rootfs_overlay/debugfs.sh index 60043d7..cc13528 100755 --- a/rootfs_overlay/debugfs.sh +++ b/rootfs_overlay/debugfs.sh @@ -1,6 +1,8 @@ #!/bin/sh set -ex mkdir -p /debugfs +# We also added a fstab entry that mounts this under /sys/kernel/debug autmoatically. +# That is the most common place to mount it. mount -t debugfs none /debugfs insmod /debugfs.ko cd /debugfs/kernel_module_cheat diff --git a/rootfs_overlay/etc/fstab b/rootfs_overlay/etc/fstab new file mode 100644 index 0000000..148a943 --- /dev/null +++ b/rootfs_overlay/etc/fstab @@ -0,0 +1,9 @@ +# +/dev/root / ext2 rw,noauto 0 1 +proc /proc proc defaults 0 0 +devpts /dev/pts devpts defaults,gid=5,mode=620 0 0 +tmpfs /dev/shm tmpfs mode=0777 0 0 +tmpfs /tmp tmpfs mode=1777 0 0 +tmpfs /run tmpfs mode=0755,nosuid,nodev 0 0 +sysfs /sys sysfs defaults 0 0 +debugfs /sys/kernel/debug debugfs defaults 0 0 diff --git a/rootfs_overlay/etc/inittab b/rootfs_overlay/etc/inittab index 58e8a70..a2fec3b 100644 --- a/rootfs_overlay/etc/inittab +++ b/rootfs_overlay/etc/inittab @@ -7,8 +7,8 @@ ::sysinit:/bin/hostname -F /etc/hostname ::sysinit:/etc/init.d/rcS # https://unix.stackexchange.com/questions/299408/how-to-login-automatically-without-typing-root-in-buildroot-x86-64-qemu -console::respawn:/bin/sh -#console::respawn:/sbin/getty -n -L console 0 vt100 +#console::respawn:/bin/sh +console::respawn:/sbin/getty -n -L console 0 vt100 ::ctrlaltdel:/sbin/reboot ::shutdown:/etc/init.d/rcK ::shutdown:/sbin/swapoff -a