[IMPROVE] add US filter for events
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Thu, 3 Oct 2013 13:57:29 +0000 (17:57 +0400)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Fri, 4 Oct 2013 09:14:23 +0000 (13:14 +0400)
Change-Id: I3ae13a254dc26d104986aeba3f1fcb611f80cd8a
Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
us_manager/us_manager.c

index e8ee608..267cb17 100644 (file)
 #include "pf/pf_group.h"
 #include "sspt/sspt_proc.h"
 #include "helper.h"
+#include <writer/event_filter.h>
 
 /* FIXME: move /un/init_msg() elsewhere and remove this include  */
 #include <writer/swap_writer_module.h>         /* for /un/init_msg() */
 
 
+
 static DEFINE_MUTEX(mutex_inst);
 static int flag_inst = 0;
 
@@ -98,10 +100,52 @@ unlock:
 }
 EXPORT_SYMBOL_GPL(usm_start);
 
+
+
+
+
+/* ============================================================================
+ * ===                              US_FILTER                               ===
+ * ============================================================================
+ */
+static int us_filter(struct task_struct *task)
+{
+       return !!sspt_proc_get_by_task(task);
+}
+
+static struct ev_filter ev_us_filter = {
+       .name = "traced_process_only",
+       .filter = us_filter
+};
+
+static int init_us_filter(void)
+{
+       int ret;
+
+       ret = event_filter_register(&ev_us_filter);
+       if (ret)
+               return ret;
+
+       return event_filter_set(ev_us_filter.name);
+}
+
+static void exit_us_filter(void)
+{
+       event_filter_unregister(&ev_us_filter);
+}
+
+
+
+
+
 static int __init init_us_manager(void)
 {
        int ret;
 
+       ret = init_us_filter();
+       if (ret)
+               return ret;
+
        init_msg(32*1024);
 
        ret = init_helper();
@@ -120,6 +164,7 @@ static void __exit exit_us_manager(void)
 
        uninit_msg();
        uninit_helper();
+       exit_us_filter();
 }
 
 module_init(init_us_manager);