- Notifications
You must be signed in to change notification settings - Fork2
An example of writing an external, simple Linux kernel module, in V.
License
spytheman/simple_kernel_module_in_v
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
The purpose of this repo, is to show how to write and testa very simple Linux kernel module,usingthe V programming language .
NB: this isvery experimental and may break in the future.It works as of 2021/10/23, withgcc 10.3.0
andV 0.2.4 008d15d
.Update: it also works as of 2022/08/16, withgcc 10.3.0
andV 0.3.0 3bc01d6
too.
The-no-builtin -no-preludes
options produce C code, that may noteven compile, if it depends on some of V'sbuiltin
module features, likedynamic arrays, maps, array/string methods, string interpolation etc.
A C compiler, and a V compiler.
On a Debian system, you can install them with:
apt-get install gccgit clone https://github.com/vlang/v&&cd v&& make&& ./v symlink
Once you have them installed, you can keep them up to date with:
apt-get upgradev up
make
See alsohttps://www.kernel.org/doc/html/latest/kbuild/modules.html .
sudo insmod vhellokernel.ko
cat /proc/modules |grep vhellokernel
If everything is ok, you should see something like this:
vhellokernel 16384 0 - Live 0x0000000000000000 (OE)
Usedmesg | tail
to see the messages that the module wrote.
sudo rmmod vhellokernel.ko
0[12:47:53] /v/misc/2021_10_22__02/simple_kernel_module_in_v LINUX $ make clean testmake -C /lib/modules/`uname -r`/build M=$PWD cleanmake[1]: Entering directory '/usr/src/linux-headers-5.11.0-38-generic' CLEAN /v/misc/2021_10_22__02/simple_kernel_module_in_v/Module.symversmake[1]: Leaving directory '/usr/src/linux-headers-5.11.0-38-generic'rm -rf vhellokernel.o vhellokernel.cv -no-builtin -no-preludes -o vhellokernel.c vhellokernel.vmake -C /lib/modules/`uname -r`/build M=$PWD modulesmake[1]: Entering directory '/usr/src/linux-headers-5.11.0-38-generic' CC [M] /v/misc/2021_10_22__02/simple_kernel_module_in_v/vhellokernel.o MODPOST /v/misc/2021_10_22__02/simple_kernel_module_in_v/Module.symvers CC [M] /v/misc/2021_10_22__02/simple_kernel_module_in_v/vhellokernel.mod.o LD [M] /v/misc/2021_10_22__02/simple_kernel_module_in_v/vhellokernel.komake[1]: Leaving directory '/usr/src/linux-headers-5.11.0-38-generic'make loadmake[1]: Entering directory '/v/misc/2021_10_22__02/simple_kernel_module_in_v'sudo insmod vhellokernel.komake[1]: Leaving directory '/v/misc/2021_10_22__02/simple_kernel_module_in_v'cat /proc/modules |grep vhellokernelvhellokernel 16384 0 - Live 0x0000000000000000 (OE)make unloadmake[1]: Entering directory '/v/misc/2021_10_22__02/simple_kernel_module_in_v'sudo rmmod vhellokernel.komake[1]: Leaving directory '/v/misc/2021_10_22__02/simple_kernel_module_in_v'0[12:47:56] /v/misc/2021_10_22__02/simple_kernel_module_in_v LINUX $
About
An example of writing an external, simple Linux kernel module, in V.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.