This commit is contained in:
Ciro Santilli
2017-05-13 14:07:39 +01:00
parent bf3bb0cb18
commit 8d20f8ce30
4 changed files with 105 additions and 25 deletions

View File

@@ -8,6 +8,7 @@
::sysinit:/etc/init.d/rcS
# https://unix.stackexchange.com/questions/299408/how-to-login-automatically-without-typing-root-in-buildroot-x86-64-qemu
console::respawn:/bin/sh
#console::respawn:/sbin/getty -n -L console 0 vt100
::ctrlaltdel:/sbin/reboot
::shutdown:/etc/init.d/rcK
::shutdown:/sbin/swapoff -a

View File

@@ -1,10 +1,12 @@
#!/bin/sh
set -ex
set -x
insmod /fops.ko
mkdir -p /fops
mount -t debugfs none /fops
cd /fops/kernel_module_cheat
## Basic read.
cat fops
# => abcd
# dmesg => open
@@ -12,14 +14,32 @@ cat fops
# dmesg => len = [0-9]+
# dmesg => close
printf a >fops
## Basic write
printf '01' >fops
# dmesg => open
# dmesg => write
# dmesg => len = 1
# dmesg => buf = a
# dmesg => close
cd /
umount /fops
rmdir /fops
rmmod fops
cat fops
# => 01cd
# dmesg => open
# dmesg => read
# dmesg => len = [0-9]+
# dmesg => close
## ENOSPC
printf '1234' >fops
printf '12345' >fops
echo "$?"
# => 8
cat fops
# => 1234
## seek
printf '1234' >fops
printf 'z' | dd bs=1 of=fops seek=2
cat fops
# => 12z4