From 944d37a96fbb4504b94e76c46a3cd6ad543ca367 Mon Sep 17 00:00:00 2001 From: Kaiwan N Billimoria Date: Mon, 11 Oct 2021 11:44:42 +0530 Subject: [PATCH] Check tracing dir and add alternate if usual debugfs one isn't mounted --- kernel/kprobe | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/kernel/kprobe b/kernel/kprobe index b4523d8..fb5035d 100755 --- a/kernel/kprobe +++ b/kernel/kprobe @@ -194,6 +194,21 @@ if (( debug )); then echo "kname: $kname, kprobe: $kprobe" fi +# It's possible - esp on a production kernel - that CONFIG_DEBUG_FS_DISALLOW_MOUNT=y +# which implies that though the debugfs filesystem's APIs are available, the +# fs itself isn't mounted - it's invisible. Take this into account, else the script +# won't work on such systems +if [ ! -d ${tracing} ]; then + if [ -d /sys/kernel/tracing ]; then + tracing=/sys/kernel/tracing + else + die "ISSUE: neither the /sys/kernel/debug/tracing nor /sys/kernel/tracing dir is available" + fi +fi +if (( debug )); then + echo "tracing dir: ${tracing}" +fi + ### check permissions cd $tracing || die "ERROR: accessing tracing. Root user? Kernel has FTRACE? debugfs mounted? (mount -t debugfs debugfs /sys/kernel/debug)"