fix .sh typo on kernel module test that accept the module as first argument

This commit is contained in:
Ciro Santilli
2025-05-09 16:27:29 +01:00
parent dd8cef4d24
commit 6513e99438
7 changed files with 18 additions and 10 deletions

View File

@@ -364,15 +364,15 @@ The safe way is to fist <<rebuild-buildroot-while-running,quit QEMU>>, rebuild t
./run --eval-after 'insmod hello.ko' ./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 ./build-modules
./run --eval-after 'insmod /mnt/9p/out_rootfs_overlay/lkmc/hello.ko' ./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: 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:kernel_modules/memfile.c[]
* link:rootfs_overlay/lkmc/memfile.sh[] * 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]]
==== seq_file ==== seq_file

View 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/debugfs.h>
#include <linux/errno.h> /* EFAULT */ #include <linux/errno.h> /* EFAULT */

View File

@@ -4,7 +4,7 @@ set -e
# Setup # Setup
f=/sys/kernel/debug/lkmc_fops f=/sys/kernel/debug/lkmc_fops
mod="${1:-fops.ko}" mod="${1:-fops.ko}"
[ $# -gt 1] && shift [ $# -gt 1 ] && shift
insmod "$mod" "$@" insmod "$mod" "$@"
# read # read

View File

@@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
set -e set -eux
# Helpers # Helpers
odraw() ( odraw() (
@@ -9,7 +9,7 @@ odraw() (
# Setup # Setup
f=/sys/kernel/debug/lkmc_memfile f=/sys/kernel/debug/lkmc_memfile
mod="${1:-memfile.ko}" mod="${1:-memfile.ko}"
[ $# -gt 1] && shift [ $# -gt 1 ] && shift
insmod "$mod" "$@" insmod "$mod" "$@"
# Starts off empty # Starts off empty

View File

@@ -4,7 +4,7 @@ set -eux
name=scull name=scull
mod="${1:-$name.ko}" mod="${1:-$name.ko}"
[ $# -gt 1] && shift [ $# -gt 1 ] && shift
insmod "$mod" "$@" insmod "$mod" "$@"
major="$(awk "\$2==\"$name\" {print \$1}" /proc/devices)" major="$(awk "\$2==\"$name\" {print \$1}" /proc/devices)"

View File

@@ -2,7 +2,7 @@
set -e set -e
f=/sys/kernel/debug/lkmc_seq_file f=/sys/kernel/debug/lkmc_seq_file
mod="${1:-seq_file.ko}" mod="${1:-seq_file.ko}"
[ $# -gt 1] && shift [ $# -gt 1 ] && shift
insmod "$mod" "$@" insmod "$mod" "$@"
[ "$(cat "$f")" = "$(printf '0\n1\n2\n')" ] [ "$(cat "$f")" = "$(printf '0\n1\n2\n')" ]
[ "$(cat "$f")" = "$(printf '0\n1\n2\n')" ] [ "$(cat "$f")" = "$(printf '0\n1\n2\n')" ]

View File

@@ -2,7 +2,7 @@
set -e set -e
f=/sys/kernel/debug/lkmc_seq_file_single_open f=/sys/kernel/debug/lkmc_seq_file_single_open
mod="${1:-seq_file_single_open.ko}" mod="${1:-seq_file_single_open.ko}"
[ $# -gt 1] && shift [ $# -gt 1 ] && shift
insmod "$mod" "$@" insmod "$mod" "$@"
[ "$(cat "$f")" = "$(printf 'ab\ncd\n')" ] [ "$(cat "$f")" = "$(printf 'ab\ncd\n')" ]
[ "$(dd if="$f" bs=1 count=3 skip=1)" = "$(printf "b\nc\n")" ] [ "$(dd if="$f" bs=1 count=3 skip=1)" = "$(printf "b\nc\n")" ]