https://github.com/holmanb/lkm
linux kernel driver playground
https://github.com/holmanb/lkm
character-devices ioctl linux-driver
Last synced: 11 months ago
JSON representation
linux kernel driver playground
- Host: GitHub
- URL: https://github.com/holmanb/lkm
- Owner: holmanb
- Created: 2018-12-27T21:32:31.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-03-22T13:13:21.000Z (almost 5 years ago)
- Last Synced: 2025-01-20T06:19:00.831Z (about 1 year ago)
- Topics: character-devices, ioctl, linux-driver
- Language: C
- Homepage:
- Size: 13.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
kernel play
===========
*testing grounds for loadable kernel modules (LKM)*
### Dependencies
**Fedora**
```
sudo dnf install git gcc make kernel-devel
```
**Arch**
```
sudo pacman -S git gcc make linux-headers
```
### Install
git clone https://github.com/holmanb/lkm.git
### Usage
each directory contains a Makefile for running tests
each Makefile implements `all`/`clean`/`test`
to quickly test out modules in a VM, one can get up and running quickly with u-root + qemu + kvm
#### Usage
```
# initial setup
go get github.com/u-root/u-root
cd
make all
u-root -files .ko core boot
qemu-system-x86_64 -kernel /boot/vmlinuz-$(uname -r) -initrd /tmp/initramfs.linux_amd64.cpio
...
...
insmod .ko
...
...
rmmod .ko
```
### Resources
Source of Truth
https://github.com/torvalds/linux
Very Dated (2.6) But Valuable
http://tldp.org/LDP/lkmpg/2.6/html/index.html
A Short Character Device Blog Post
https://blog.sourcerer.io/writing-a-simple-linux-kernel-module-d9dc3762c234
Blog Post By Dr. Derek Molloy of Dublin City University, Ireland
www.derekmolloy.ie/writing-a-linux-kernel-module-part-1-introduction
Register A Device Class and Driver of a Dynamically Allocated Major Number From Kernel Space
www.derekmolloy.ie/writing-a-linux-kernel-module-part-2-a-character-device
Shows How To Add Ioctl To Char Device
https://www.tldp.org/LDP/lkmpg/2.4/html/x856.html