mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-25 19:21:35 +01:00
llseek
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user