From: Huang Shijie Date: Sat, 21 May 2016 00:04:33 +0000 (-0700) Subject: samples/kprobes: add a new module parameter X-Git-Tag: v4.7-rc1~89^2~1 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=d04659ac94528e9224dbf1aed37dd11dd952cacc;p=linux-block.git samples/kprobes: add a new module parameter Add a new module parameter which can be used as the symbol name. Without this patch, we can only test the "_do_fork" function with this kernel module. With this patch, the module becomes more flexible; we can test any functions with this module with # insmod kprobe_example.ko symbol="xxx" Link: http://lkml.kernel.org/r/1463535417-29637-1-git-send-email-shijie.huang@arm.com Signed-off-by: Huang Shijie Cc: Petr Mladek Cc: Steve Capper Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/samples/kprobes/kprobe_example.c b/samples/kprobes/kprobe_example.c index 727eb21c9c56..2bb190dee66f 100644 --- a/samples/kprobes/kprobe_example.c +++ b/samples/kprobes/kprobe_example.c @@ -14,9 +14,13 @@ #include #include +#define MAX_SYMBOL_LEN 64 +static char symbol[MAX_SYMBOL_LEN] = "_do_fork"; +module_param_string(symbol, symbol, sizeof(symbol), 0644); + /* For each probe you need to allocate a kprobe structure */ static struct kprobe kp = { - .symbol_name = "_do_fork", + .symbol_name = symbol, }; /* kprobe pre_handler: called just before the probed instruction is executed */