From 91071143916e91d4e37658cc20334ed9f4a4b26c Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Thu, 11 Apr 2013 12:51:47 +0400 Subject: [PATCH] [REFACTOR] redesign /un/register_kernel_probe() --- driver/probes_manager.c | 61 +++++++++++++++---------------------------------- driver/probes_manager.h | 3 --- 2 files changed, 18 insertions(+), 46 deletions(-) diff --git a/driver/probes_manager.c b/driver/probes_manager.c index 7b9d389..82834c8 100644 --- a/driver/probes_manager.c +++ b/driver/probes_manager.c @@ -66,60 +66,35 @@ probes_manager_down (void) storage_down (); } -static int -register_kernel_jprobe (kernel_probe_t * probe) +static int register_kernel_probe(kernel_probe_t *p) { - int result; - result = dbi_register_jprobe (&probe->jprobe); - if (result) - { - EPRINTF ("register_kernel_jprobe(0x%lx) failure %d", probe->addr, result); - return result; - } - return 0; -} + int ret; -static int -unregister_kernel_jprobe (kernel_probe_t * probe) -{ - dbi_unregister_jprobe (&probe->jprobe); - return 0; -} + /* register jprobe */ + ret = dbi_register_jprobe(&p->jprobe); + if (ret) { + EPRINTF("dbi_register_jprobe(0x%lx) failure %d", p->addr, ret); + return ret; + }; -static int -register_kernel_retprobe (kernel_probe_t * probe) -{ - int result; + /* register kretprobe */ + ret = dbi_register_kretprobe(&p->retprobe); + if (ret) { + EPRINTF("dbi_register_kretprobe(0x%lx) failure %d", + p->addr, ret); - result = dbi_register_kretprobe (&probe->retprobe); - if (result) - { - EPRINTF ("register_kernel_retprobe(0x%lx) failure %d", probe->addr, result); - return result; + dbi_unregister_jprobe(&p->jprobe); + return ret; } - return 0; -} -static int -unregister_kernel_retprobe (kernel_probe_t * probe) -{ - dbi_unregister_kretprobe (&probe->retprobe); return 0; } -int -register_kernel_probe (kernel_probe_t * probe) +static int unregister_kernel_probe(kernel_probe_t *p) { - register_kernel_jprobe (probe); - register_kernel_retprobe (probe); - return 0; -} + dbi_unregister_kretprobe(&p->retprobe); + dbi_unregister_jprobe(&p->jprobe); -int -unregister_kernel_probe (kernel_probe_t * probe) -{ - unregister_kernel_retprobe(probe); - unregister_kernel_jprobe(probe); return 0; } diff --git a/driver/probes_manager.h b/driver/probes_manager.h index 9a9bff7..b96f466 100644 --- a/driver/probes_manager.h +++ b/driver/probes_manager.h @@ -38,9 +38,6 @@ extern int remove_probe (unsigned long addr); extern int attach_selected_probes (void); extern int detach_selected_probes (void); -extern int register_kernel_probe (kernel_probe_t * probe); -extern int unregister_kernel_probe (kernel_probe_t * probe); - extern unsigned long def_jprobe_event_pre_handler (kernel_probe_t * probe, struct pt_regs *regs); extern void def_jprobe_event_handler (unsigned long arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5, unsigned long arg6); extern int def_retprobe_event_handler (struct kretprobe_instance *probe, struct pt_regs *regs, kernel_probe_t * p); -- 2.7.4