Move debugfs, rootfs and procfs documentation to README

This commit is contained in:
Ciro Santilli
2018-06-29 09:55:25 +01:00
parent 0cd1a2b602
commit 9a4eae50c8
11 changed files with 149 additions and 98 deletions

View File

@@ -1,22 +1,13 @@
#!/bin/sh
set -ex
set -e
d=/debugfs
mkdir -p "$d"
# We also added a fstab entry that mounts this under /sys/kernel/debug autmoatically.
# That is the most common place to mount it.
# The /sys/kernel/debug directory gets created automatically when debugfs is
# compiled into the kernel, but it does not get mounted automatically.
mount -t debugfs none /debugfs
mount -t debugfs none "$d"
insmod /debugfs.ko
cd "${d}/lkmc_debugfs"
cat myfile
# => 42
echo 13 > myfile
cat myfile
# => 13
[ "$(cat "${d}/lkmc_debugfs/myfile")" = 42 ]
echo 13 > "${d}/lkmc_debugfs/myfile"
[ "$(cat "${d}/lkmc_debugfs/myfile")" = 13 ]
echo 666 > "${d}/lkmc_debugfs_file"
cat myfile
# => 666
[ "$(cat "${d}/lkmc_debugfs/myfile")" = 666 ]
rmmod debugfs
umount "$d"

5
rootfs_overlay/procfs.sh Executable file
View File

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

View File

@@ -1,11 +1,11 @@
#!/bin/sh
set -x
set -e
insmod /sysfs.ko
cd /sys/kernel/lkmc_sysfs
printf 12345 >foo
cat foo
# => 1234
dd if=foo bs=1 count=2 skip=1 status=none
# => 23
f=/sys/kernel/lkmc_sysfs/foo
# write
printf 12345 > "$f"
# read
[ "$(cat "$f")" = 1234 ]
# seek
[ "$(dd if="$f" bs=1 count=2 skip=1 status=none)" = 23 ]
rmmod sysfs

View File

@@ -1,14 +1,15 @@
#!/bin/sh
(
set -ex
/character_device.sh
/character_device_create.sh
/fops.sh
)
if [ "$?" -eq 0 ]; then
echo lkmc_test_pass
exit 0
else
echo lkmc_test_fail
exit 1
fi
for test in \
/character_device.sh \
/character_device_create.sh \
/debugfs.sh \
/fops.sh \
/procfs.sh \
/sysfs.sh
do
if ! "$test"; then
echo "lkmc_test_fail: ${test}"
exit 1
fi
done
echo lkmc_test_pass