mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
split kernel module api docs to README
This commit is contained in:
27
rootfs_overlay/dep.sh
Executable file
27
rootfs_overlay/dep.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
f=/sys/kernel/debug/lkmc_dep
|
||||
f2=/sys/kernel/debug/lkmc_dep2
|
||||
|
||||
insmod /dep.ko
|
||||
insmod /dep2.ko
|
||||
|
||||
# Initial value.
|
||||
[ "$(cat "$f")" = 0 ]
|
||||
|
||||
# Changhing dep2 also changes dep.
|
||||
printf 1 > "$f2"
|
||||
[ "$(cat "$f")" = 1 ]
|
||||
|
||||
# Changhing dep also changes dep2.
|
||||
printf 2 > "$f"
|
||||
[ "$(cat "$f2")" = 2 ]
|
||||
|
||||
# sysfs shows us that the module has dependants.
|
||||
[ "$(cat /sys/module/dep/refcnt)" = 1 ]
|
||||
[ "$(ls /sys/module/dep/holders)" = dep2 ]
|
||||
rmmod /dep2.ko
|
||||
[ "$(cat /sys/module/dep/refcnt)" = 0 ]
|
||||
[ -z "$(ls /sys/module/dep/holders)" ]
|
||||
|
||||
rmmod /dep.ko
|
||||
@@ -1,8 +1 @@
|
||||
# This file does *not* specify modules to auto-load at startup,
|
||||
# you still need to explicitly load your modules from init.d:
|
||||
# https://superuser.com/questions/397842/automatically-load-kernel-module-at-boot-angstrom/1267464#1267464
|
||||
|
||||
# Default parameters when loading modules.
|
||||
# Especially important due to loading module dependencies:
|
||||
# how else would you specify their parameters?
|
||||
options params i=12 j=34
|
||||
|
||||
4
rootfs_overlay/init_module.sh
Executable file
4
rootfs_overlay/init_module.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
insmod /init_module.ko
|
||||
rmmod init_module
|
||||
20
rootfs_overlay/params.sh
Executable file
20
rootfs_overlay/params.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
d=/sys/module/params/parameters
|
||||
i="${d}/i"
|
||||
j="${d}/j"
|
||||
f=/sys/kernel/debug/lkmc_params
|
||||
|
||||
insmod /params.ko
|
||||
[ "$(cat "$i")" = 0 ]
|
||||
[ "$(cat "$j")" = 0 ]
|
||||
[ "$(cat "$f")" = '0 0' ]
|
||||
printf 1 > "$i"
|
||||
[ "$(cat "$f")" = '1 0' ]
|
||||
printf 2 > "$j"
|
||||
[ "$(cat "$f")" = '1 2' ]
|
||||
rmmod params
|
||||
|
||||
insmod /params.ko i=3 j=4
|
||||
[ "$(cat "$f")" = '3 4' ]
|
||||
rmmod params
|
||||
@@ -4,9 +4,12 @@ for test in \
|
||||
/character_device.sh \
|
||||
/character_device_create.sh \
|
||||
/debugfs.sh \
|
||||
/dep.sh \
|
||||
/fops.sh \
|
||||
/init_module.sh \
|
||||
/ioctl.sh \
|
||||
/mmap.sh \
|
||||
/params.sh \
|
||||
/procfs.sh \
|
||||
/seq_file.sh \
|
||||
/seq_file_single_open.sh \
|
||||
|
||||
4
rootfs_overlay/vermagic.sh
Normal file
4
rootfs_overlay/vermagic.sh
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
insmod /vermagic.ko
|
||||
rmmod vermagic
|
||||
Reference in New Issue
Block a user