{"id":13806547,"url":"https://github.com/spytheman/simple_kernel_module_in_v","last_synced_at":"2025-03-18T16:30:48.905Z","repository":{"id":66643759,"uuid":"420371815","full_name":"spytheman/simple_kernel_module_in_v","owner":"spytheman","description":"An example of writing an external, simple Linux kernel module, in V.","archived":false,"fork":false,"pushed_at":"2022-08-16T08:36:45.000Z","size":17,"stargazers_count":27,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-08T04:47:58.393Z","etag":null,"topics":["kernel-module","linux","proof-of-concept","vlang"],"latest_commit_sha":null,"homepage":"","language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spytheman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-10-23T09:43:46.000Z","updated_at":"2024-11-22T15:52:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"8b56b55d-4e0e-4ba3-9988-a9eede046f84","html_url":"https://github.com/spytheman/simple_kernel_module_in_v","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spytheman%2Fsimple_kernel_module_in_v","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spytheman%2Fsimple_kernel_module_in_v/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spytheman%2Fsimple_kernel_module_in_v/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spytheman%2Fsimple_kernel_module_in_v/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spytheman","download_url":"https://codeload.github.com/spytheman/simple_kernel_module_in_v/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243940088,"owners_count":20372045,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kernel-module","linux","proof-of-concept","vlang"],"created_at":"2024-08-04T01:01:13.152Z","updated_at":"2025-03-18T16:30:48.667Z","avatar_url":"https://github.com/spytheman.png","language":"Makefile","readme":"# A simple Linux kernel module, written in V\n\nThe purpose of this repo, is to show how to write and test\na very simple Linux kernel module,\nusing [the V programming language](https://vlang.io/) .\n\nNB: this is *very* experimental and may break in the future.\nIt works as of 2021/10/23, with `gcc 10.3.0` and `V 0.2.4 008d15d` .\nUpdate: it also works as of 2022/08/16, with `gcc 10.3.0` and `V 0.3.0 3bc01d6` too.\n\nThe `-no-builtin -no-preludes` options produce C code, that may not\neven compile, if it depends on some of V's `builtin` module features, like\ndynamic arrays, maps, array/string methods, string interpolation etc.\n\n## Prerequisites:\nA C compiler, and a V compiler.\n\nOn a Debian system, you can install them with:\n```bash\napt-get install gcc\ngit clone https://github.com/vlang/v \u0026\u0026 cd v \u0026\u0026 make \u0026\u0026 ./v symlink\n```\n\nOnce you have them installed, you can keep them up to date with:\n```bash\napt-get upgrade\nv up\n```\n\n## Building the kernel module:\n`make`\n\nSee also https://www.kernel.org/doc/html/latest/kbuild/modules.html .\n\n## Loading the module in your kernel:\n`sudo insmod vhellokernel.ko`\n\n## Verifying that the module was loaded in the kernel:\n`cat /proc/modules |grep vhellokernel`\n\nIf everything is ok, you should see something like this:\n```\nvhellokernel 16384 0 - Live 0x0000000000000000 (OE)\n```\n\nUse `dmesg | tail` to see the messages that the module wrote.\n\n## Removing the module from your kernel:\n`sudo rmmod vhellokernel.ko`\n\n## `make clean test`\n```\n0[12:47:53] /v/misc/2021_10_22__02/simple_kernel_module_in_v LINUX $ make clean test\nmake -C /lib/modules/`uname -r`/build M=$PWD clean\nmake[1]: Entering directory '/usr/src/linux-headers-5.11.0-38-generic'\n  CLEAN   /v/misc/2021_10_22__02/simple_kernel_module_in_v/Module.symvers\nmake[1]: Leaving directory '/usr/src/linux-headers-5.11.0-38-generic'\nrm -rf vhellokernel.o vhellokernel.c\nv -no-builtin -no-preludes -o vhellokernel.c vhellokernel.v\nmake -C /lib/modules/`uname -r`/build M=$PWD modules\nmake[1]: Entering directory '/usr/src/linux-headers-5.11.0-38-generic'\n  CC [M]  /v/misc/2021_10_22__02/simple_kernel_module_in_v/vhellokernel.o\n  MODPOST /v/misc/2021_10_22__02/simple_kernel_module_in_v/Module.symvers\n  CC [M]  /v/misc/2021_10_22__02/simple_kernel_module_in_v/vhellokernel.mod.o\n  LD [M]  /v/misc/2021_10_22__02/simple_kernel_module_in_v/vhellokernel.ko\nmake[1]: Leaving directory '/usr/src/linux-headers-5.11.0-38-generic'\nmake load\nmake[1]: Entering directory '/v/misc/2021_10_22__02/simple_kernel_module_in_v'\nsudo insmod vhellokernel.ko\nmake[1]: Leaving directory '/v/misc/2021_10_22__02/simple_kernel_module_in_v'\ncat /proc/modules |grep vhellokernel\nvhellokernel 16384 0 - Live 0x0000000000000000 (OE)\nmake unload\nmake[1]: Entering directory '/v/misc/2021_10_22__02/simple_kernel_module_in_v'\nsudo rmmod vhellokernel.ko\nmake[1]: Leaving directory '/v/misc/2021_10_22__02/simple_kernel_module_in_v'\n0[12:47:56] /v/misc/2021_10_22__02/simple_kernel_module_in_v LINUX $\n```\n\n## Further reading:\n1. https://tldp.org/LDP/lkmpg/2.6/lkmpg.pdf\n\n2. https://www.kernel.org/doc/html/latest/kbuild/modules.html\n\n3. https://github.com/vlang/v/blob/master/doc/docs.md\n","funding_links":[],"categories":["Other"],"sub_categories":["Operating Systems \u0026 OS Development Examples"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspytheman%2Fsimple_kernel_module_in_v","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspytheman%2Fsimple_kernel_module_in_v","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspytheman%2Fsimple_kernel_module_in_v/lists"}