mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-22 17:55:57 +01:00
fix .sh typo on kernel module test that accept the module as first argument
This commit is contained in:
14
README.adoc
14
README.adoc
@@ -364,15 +364,15 @@ The safe way is to fist <<rebuild-buildroot-while-running,quit QEMU>>, rebuild t
|
||||
./run --eval-after 'insmod hello.ko'
|
||||
....
|
||||
|
||||
or for a slightly faster turnaround just leave it on 9p and use it from there:
|
||||
where `./build-buildroot` is required after `./build-modules` because it re-generates the root filesystem with the modules that we compiled at `./build-modules`.
|
||||
|
||||
Alternatively, for a slightly faster turnaround just leave it on 9p and use it from there:
|
||||
|
||||
....
|
||||
./build-modules
|
||||
./run --eval-after 'insmod /mnt/9p/out_rootfs_overlay/lkmc/hello.ko'
|
||||
....
|
||||
|
||||
`./build-buildroot` is required after `./build-modules` because it re-generates the root filesystem with the modules that we compiled at `./build-modules`.
|
||||
|
||||
You can see that `./build` does that as well, by running:
|
||||
|
||||
....
|
||||
@@ -7733,6 +7733,14 @@ This example behaves the same as <<fops>>, except that the in-memory virtual fil
|
||||
* link:kernel_modules/memfile.c[]
|
||||
* link:rootfs_overlay/lkmc/memfile.sh[]
|
||||
|
||||
TODO: this example builds but oopses with out of memory on our currently default kernel v5.9.2 when doing the big allocation at:
|
||||
|
||||
....
|
||||
dd if=/dev/zero of="$f" bs=1k count=1M
|
||||
....
|
||||
|
||||
It works however on kernel 6.8.12, we're not sure why. We do have a potential krealloc vs kvrealloc on version check which is a very likely reason for the issue, but it has not been investigated.
|
||||
|
||||
[[seq-file]]
|
||||
==== seq_file
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* https://cirosantilli.com/linux-kernel-module-cheat#fops */
|
||||
/* https://cirosantilli.com/linux-kernel-module-cheat#memfile */
|
||||
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/errno.h> /* EFAULT */
|
||||
|
||||
@@ -4,7 +4,7 @@ set -e
|
||||
# Setup
|
||||
f=/sys/kernel/debug/lkmc_fops
|
||||
mod="${1:-fops.ko}"
|
||||
[ $# -gt 1] && shift
|
||||
[ $# -gt 1 ] && shift
|
||||
insmod "$mod" "$@"
|
||||
|
||||
# read
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
set -eux
|
||||
|
||||
# Helpers
|
||||
odraw() (
|
||||
@@ -9,7 +9,7 @@ odraw() (
|
||||
# Setup
|
||||
f=/sys/kernel/debug/lkmc_memfile
|
||||
mod="${1:-memfile.ko}"
|
||||
[ $# -gt 1] && shift
|
||||
[ $# -gt 1 ] && shift
|
||||
insmod "$mod" "$@"
|
||||
|
||||
# Starts off empty
|
||||
|
||||
@@ -4,7 +4,7 @@ set -eux
|
||||
name=scull
|
||||
|
||||
mod="${1:-$name.ko}"
|
||||
[ $# -gt 1] && shift
|
||||
[ $# -gt 1 ] && shift
|
||||
insmod "$mod" "$@"
|
||||
major="$(awk "\$2==\"$name\" {print \$1}" /proc/devices)"
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
set -e
|
||||
f=/sys/kernel/debug/lkmc_seq_file
|
||||
mod="${1:-seq_file.ko}"
|
||||
[ $# -gt 1] && shift
|
||||
[ $# -gt 1 ] && shift
|
||||
insmod "$mod" "$@"
|
||||
[ "$(cat "$f")" = "$(printf '0\n1\n2\n')" ]
|
||||
[ "$(cat "$f")" = "$(printf '0\n1\n2\n')" ]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
set -e
|
||||
f=/sys/kernel/debug/lkmc_seq_file_single_open
|
||||
mod="${1:-seq_file_single_open.ko}"
|
||||
[ $# -gt 1] && shift
|
||||
[ $# -gt 1 ] && shift
|
||||
insmod "$mod" "$@"
|
||||
[ "$(cat "$f")" = "$(printf 'ab\ncd\n')" ]
|
||||
[ "$(dd if="$f" bs=1 count=3 skip=1)" = "$(printf "b\nc\n")" ]
|
||||
|
||||
Reference in New Issue
Block a user