make overlay scripts use kernel modules and executables relative to pwd in preparison for 9p

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2018-10-13 00:00:00 +00:00
parent cd9c22f451
commit ddecb1bf5d
27 changed files with 59 additions and 43 deletions

View File

@@ -1,5 +1,5 @@
#!/bin/sh
set -e
insmod /anonymous_inode.ko
insmod anonymous_inode.ko
[ "$(/anonymous_inode.out /sys/kernel/debug/lkmc_anonymous_inode 3)" = "$(printf '1\n10\n100')" ]
rmmod anonymous_inode

View File

@@ -1,6 +1,6 @@
#!/bin/sh
set -e
insmod /character_device.ko
insmod character_device.ko
/mknoddev.sh lkmc_character_device
[ "$(cat /dev/lkmc_character_device)" = 'abcd' ]
rm /dev/lkmc_character_device

View File

@@ -1,6 +1,6 @@
#!/bin/sh
set -e
insmod /character_device_create.ko
insmod character_device_create.ko
dev='/dev/lkmc_character_device_create_dev'
[ "$(cat "$dev")" = abcd ]
rmmod character_device_create

View File

@@ -3,7 +3,7 @@ set -e
d=/debugfs
mkdir -p "$d"
mount -t debugfs none "$d"
insmod /debugfs.ko
insmod debugfs.ko
[ "$(cat "${d}/lkmc_debugfs/myfile")" = 42 ]
echo 13 > "${d}/lkmc_debugfs/myfile"
[ "$(cat "${d}/lkmc_debugfs/myfile")" = 13 ]

View File

@@ -3,8 +3,8 @@ set -e
f=/sys/kernel/debug/lkmc_dep
f2=/sys/kernel/debug/lkmc_dep2
insmod /dep.ko
insmod /dep2.ko
insmod dep.ko
insmod dep2.ko
# Initial value.
[ "$(cat "$f")" = 0 ]
@@ -20,8 +20,8 @@ printf 2 > "$f"
# sysfs shows us that the module has dependants.
[ "$(cat /sys/module/dep/refcnt)" = 1 ]
[ "$(ls /sys/module/dep/holders)" = dep2 ]
rmmod /dep2.ko
rmmod dep2.ko
[ "$(cat /sys/module/dep/refcnt)" = 0 ]
[ -z "$(ls /sys/module/dep/holders)" ]
rmmod /dep.ko
rmmod dep.ko

View File

@@ -11,7 +11,7 @@ eval "$lkmc_eval"
# However, the kernel CLI parsing is crap, and the 4.14 docs lie.
#
# In particular, not all that is passed after "-" goes to an argument to init,
# e.g. stuff with dots like "- /poweroff.out" still gets treated specially and
# e.g. stuff with dots like "- ./poweroff.out" still gets treated specially and
# does not go to init.
#
# This also likely means that the above solution is also unreliable in some cases,

View File

@@ -3,7 +3,7 @@ set -e
# Setup
f=/sys/kernel/debug/lkmc_fops
insmod /fops.ko
insmod fops.ko
# read
[ "$(cat "$f")" = abcd ]

View File

@@ -1,4 +1,4 @@
#!/bin/sh
set -e
insmod /init_module.ko
insmod init_module.ko
rmmod init_module

View File

@@ -1,7 +1,7 @@
#!/bin/sh
set -e
f=/sys/kernel/debug/lkmc_ioctl
insmod /ioctl.ko
insmod ioctl.ko
[ "$(/ioctl.out "$f" 0 1)" = 2 ]
[ "$(/ioctl.out "$f" 1 1 1)" = '2 0' ]
rmmod ioctl

View File

@@ -1,5 +1,5 @@
#!/bin/sh
insmod /fops.ko
insmod fops.ko
cd /sys/kernel/debug/lkmc_fops
i=0
while true; do

View File

@@ -1,7 +1,7 @@
#!/bin/sh
set -e
f=/sys/kernel/debug/lkmc_kstrto
insmod /kstrto.ko
insmod kstrto.ko
printf 123 > "$f"
[ "$(cat "$f")" = 124 ]
echo foobar > "$f" && exit 1

View File

@@ -1,5 +1,5 @@
#!/bin/sh
set -e
insmod /mmap.ko
/mmap.out /proc/lkmc_mmap 2>&1 1>/dev/null
rmmod /mmap.ko
insmod mmap.ko
./mmap.out /proc/lkmc_mmap 2>&1 1>/dev/null
rmmod mmap.ko

View File

@@ -1,6 +1,6 @@
#!/bin/sh
set -e
insmod /netlink.ko
insmod netlink.ko
[ "$(/netlink.out)" = 0 ]
[ "$(/netlink.out)" = 1 ]
[ "$(/netlink.out)" = 2 ]

View File

@@ -5,7 +5,7 @@ i="${d}/i"
j="${d}/j"
f=/sys/kernel/debug/lkmc_params
insmod /params.ko
insmod params.ko
[ "$(cat "$i")" = 0 ]
[ "$(cat "$j")" = 0 ]
[ "$(cat "$f")" = '0 0' ]
@@ -15,6 +15,6 @@ printf 2 > "$j"
[ "$(cat "$f")" = '1 2' ]
rmmod params
insmod /params.ko i=3 j=4
insmod params.ko i=3 j=4
[ "$(cat "$f")" = '3 4' ]
rmmod params

View File

@@ -1,4 +1,4 @@
#!/bin/sh
insmod /pmccntr.ko
insmod pmccntr.ko
cd /sys/kernel/debug
cat lkmc_pmccntr

View File

@@ -1,5 +1,5 @@
#!/bin/sh
set -e
insmod /poll.ko
/poll.out /sys/kernel/debug/lkmc_poll
insmod poll.ko
./poll.out /sys/kernel/debug/lkmc_poll
#rmmod poll

View File

@@ -1,5 +1,5 @@
#!/bin/sh
set -e
insmod /procfs.ko
insmod procfs.ko
[ "$(cat "/proc/lkmc_procfs")" = abcd ]
rmmod procfs

View File

@@ -10,7 +10,7 @@ lspci -k
cat /proc/interrupts
# Setup.
insmod /pci.ko
insmod pci.ko
/mknoddev.sh lkmc_pci
# Shows that this module owns the PCI device.

View File

@@ -1,6 +1,6 @@
#!/bin/sh
set -ex
/rand_check.out
./rand_check.out
# Check if network is being replayed.
# https://superuser.com/questions/635020/how-to-know-current-time-from-internet-from-command-line-in-linux
@@ -9,4 +9,4 @@ set -ex
# busybox's poweroff panics, TODO why. Likely tries to kill shell.
# So just use our super raw command.
/poweroff.out
./poweroff.out

View File

@@ -1,7 +1,7 @@
#!/bin/sh
set -e
f=/sys/kernel/debug/lkmc_seq_file
insmod /seq_file.ko
insmod seq_file.ko
[ "$(cat "$f")" = "$(printf '0\n1\n2\n')" ]
[ "$(cat "$f")" = "$(printf '0\n1\n2\n')" ]
[ "$(dd if="$f" bs=1 count=2 skip=0 status=none)" = "$(printf '0\n')" ]

View File

@@ -1,7 +1,7 @@
#!/bin/sh
set -e
f=/sys/kernel/debug/lkmc_seq_file_single_open
insmod /seq_file_single_open.ko
insmod seq_file_single_open.ko
[ "$(cat "$f")" = "$(printf 'ab\ncd\n')" ]
[ "$(dd if="$f" bs=1 count=3 skip=1)" = "$(printf "b\nc\n")" ]
rmmod seq_file_single_open

View File

@@ -1,6 +1,6 @@
#!/bin/sh
set -e
insmod /sysfs.ko
insmod sysfs.ko
f=/sys/kernel/lkmc_sysfs/foo
# write
printf 12345 > "$f"

View File

@@ -4,9 +4,9 @@ set -e
modprobe uio_pci_generic
# pci_min device
echo '1234 11e9' > /sys/bus/pci/drivers/uio_pci_generic/new_id
/uio_read.out &
./uio_read.out &
# Helper to observe interrupts.
insmod /irq.ko
insmod irq.ko
base="$(setpci -d 1234:11e9 BASE_ADDRESS_0)"
# Start generating interrupt.
devmem "0x${base}" w 0x12345678

View File

@@ -1,4 +1,4 @@
#!/bin/sh
set -e
insmod /vermagic.ko
insmod vermagic.ko
rmmod vermagic

View File

@@ -1,6 +1,6 @@
#!/bin/sh
set -ex
insmod /virt_to_phys.ko
insmod virt_to_phys.ko
cd /sys/kernel/debug
cat lkmc_virt_to_phys
# k = 0x12345678