debugfs.c: extend example with toplevel file, fop and kstrtoull_from_user

This commit is contained in:
Ciro Santilli
2018-04-13 07:56:32 +01:00
parent c1c517a1c7
commit 42e634ffd1
3 changed files with 49 additions and 6 deletions

View File

@@ -1,12 +1,22 @@
#!/bin/sh
set -ex
mkdir -p /debugfs
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
insmod /debugfs.ko
cd /debugfs/lkmc_debugfs
cd "${d}/lkmc_debugfs"
cat myfile
# => 42
echo 13 > myfile
cat myfile
# => 13
echo 666 > "${d}/lkmc_debugfs_file"
cat myfile
# => 666