[IMPROVE] Us_manager: implement 'dumb' filter 50/16750/3
authorAlexander Aksenov <a.aksenov@samsung.com>
Mon, 24 Feb 2014 11:50:15 +0000 (15:50 +0400)
committerDmitry Kovalenko <d.kovalenko@samsung.com>
Thu, 27 Mar 2014 08:32:56 +0000 (01:32 -0700)
All apps passes through this filter. Works like there is no filter

Change-Id: Iacfc58cfa8f8c72c9d74facf05d5ce9b237fd6bf
Signed-off-by: Alexander Aksenov <a.aksenov@samsung.com>
us_manager/pf/pf_group.c
us_manager/pf/pf_group.h
us_manager/pf/proc_filters.c
us_manager/pf/proc_filters.h

index 4bd2c3e..fafd699 100644 (file)
@@ -198,6 +198,25 @@ struct pf_group *get_pf_group_by_tgid(pid_t tgid, void *priv)
 }
 EXPORT_SYMBOL_GPL(get_pf_group_by_tgid);
 
+struct pf_group *get_pf_group_dumb(void *priv)
+{
+       struct pf_group *pfg;
+       struct proc_filter *filter;
+
+       list_for_each_entry(pfg, &pfg_list, list) {
+               if (check_pf_dumb(pfg->filter))
+                       return pfg;
+       }
+
+       filter = create_pf_dumb(pfg->filter);
+       pfg = create_pfg(filter);
+
+       add_pfg_by_list(pfg);
+
+       return pfg;
+}
+EXPORT_SYMBOL_GPL(get_pf_group_dumb);
+
 void put_pf_group(struct pf_group *pfg)
 {
 
index bf6438f..07e448f 100644 (file)
@@ -34,6 +34,7 @@ struct sspt_proc;
 
 struct pf_group *get_pf_group_by_dentry(struct dentry *dentry, void *priv);
 struct pf_group *get_pf_group_by_tgid(pid_t tgid, void *priv);
+struct pf_group *get_pf_group_dumb(void *priv);
 void put_pf_group(struct pf_group *pfg);
 
 int pf_register_probe(struct pf_group *pfg, struct dentry *dentry,
index cce88ec..c916625 100644 (file)
@@ -70,6 +70,13 @@ static struct task_struct *call_by_tgid(struct proc_filter *self,
        return NULL;
 }
 
+/* Dumb call. Each task is exactly what we are looking for :) */
+static struct task_struct *call_dumb(struct proc_filter *self,
+                                    struct task_struct *task)
+{
+       return task;
+}
+
 static struct proc_filter *create_pf(void)
 {
        struct proc_filter *pf = kmalloc(sizeof(*pf), GFP_KERNEL);
@@ -98,6 +105,17 @@ struct proc_filter *create_pf_by_tgid(pid_t tgid, void *priv)
        return pf;
 }
 
+struct proc_filter *create_pf_dumb(void *priv)
+{
+       struct proc_filter *pf = create_pf();
+
+       pf->call = &call_dumb;
+       pf->data = NULL;
+       pf->priv = priv;
+
+       return pf;
+}
+
 void free_pf(struct proc_filter *pf)
 {
        kfree(pf);
@@ -114,6 +132,11 @@ int check_pf_by_tgid(struct proc_filter *filter, pid_t tgid)
        return filter->data == (void *)tgid && filter->call == &call_by_tgid;
 }
 
+int check_pf_dumb(struct proc_filter *filter)
+{
+       return filter->call == &call_dumb;
+}
+
 struct dentry *get_dentry_by_pf(struct proc_filter *filter)
 {
        if (filter->call == &call_by_dentry)
index 2857419..2a007d0 100644 (file)
@@ -42,10 +42,12 @@ struct proc_filter {
 
 struct proc_filter *create_pf_by_dentry(struct dentry *dentry, void *priv);
 struct proc_filter *create_pf_by_tgid(pid_t tgid, void *priv);
+struct proc_filter *create_pf_dumb(void *priv);
 void free_pf(struct proc_filter *pf);
 
 int check_pf_by_dentry(struct proc_filter *filter, struct dentry *dentry);
 int check_pf_by_tgid(struct proc_filter *filter, pid_t tgid);
+int check_pf_dumb(struct proc_filter *filter);
 struct dentry *get_dentry_by_pf(struct proc_filter *filter);
 
 #endif /* _PROC_FILTERS_H */