[REFACTOR] move dentry_by_path()
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Thu, 6 Nov 2014 12:53:03 +0000 (16:53 +0400)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Mon, 18 May 2015 09:37:50 +0000 (12:37 +0300)
form parser/us_inst.c to us_manager/pf/pf_group.c

Change-Id: I4a9d6fe017debe743874180edd8ec27c7c2db7ec
Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
parser/us_inst.c
us_manager/pf/pf_group.c
us_manager/pf/pf_group.h
webprobe/webprobe_prof.c

index ea0b306..4bf143e 100644 (file)
 #include <linux/module.h>
 #include <linux/version.h>
 #include <linux/errno.h>
-#include <linux/namei.h>
 #include <us_manager/pf/pf_group.h>
 #include <us_manager/probes/probes.h>
 
 #include "msg_parser.h"
 #include "us_inst.h"
 
-/* FIXME: create get_dentry() and put_dentry() */
-static struct dentry *dentry_by_path(const char *path)
-{
-       struct dentry *dentry;
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38)
-       struct path st_path;
-       if (kern_path(path, LOOKUP_FOLLOW, &st_path) != 0) {
-#else /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38) */
-       struct nameidata nd;
-       if (path_lookup(path, LOOKUP_FOLLOW, &nd) != 0) {
-#endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38) */
-               printk(KERN_INFO "failed to lookup dentry for path %s!\n",
-                      path);
-               return NULL;
-       }
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
-       dentry = nd.dentry;
-       path_release(&nd);
-#elif LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 38)
-       dentry = nd.path.dentry;
-       path_put(&nd.path);
-#else /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38) */
-       dentry = st_path.dentry;
-       path_put(&st_path);
-#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) */
-       return dentry;
-}
-
 
 static int mod_func_inst(struct func_inst_data *func, struct pf_group *pfg,
                         struct dentry *dentry, enum MOD_TYPE mt)
index 86d44cc..927b82d 100644 (file)
@@ -26,6 +26,8 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/list.h>
+#include <linux/namei.h>
+
 #include "proc_filters.h"
 #include <us_manager/usm_msg.h>
 #include <us_manager/img/img_proc.h>
@@ -205,6 +207,40 @@ static void subsequent_install(struct task_struct *task,
 }
 
 /**
+ * @brief Get dentry struct by path
+ *
+ * @param path Path to file
+ * @return Pointer on dentry struct on NULL
+ */
+struct dentry *dentry_by_path(const char *path)
+{
+       struct dentry *dentry;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38)
+       struct path st_path;
+       if (kern_path(path, LOOKUP_FOLLOW, &st_path) != 0) {
+#else /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38) */
+       struct nameidata nd;
+       if (path_lookup(path, LOOKUP_FOLLOW, &nd) != 0) {
+#endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38) */
+               printk("failed to lookup dentry for path %s!\n", path);
+               return NULL;
+       }
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
+       dentry = nd.dentry;
+       path_release(&nd);
+#elif LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 38)
+       dentry = nd.path.dentry;
+       path_put(&nd.path);
+#else /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38) */
+       dentry = st_path.dentry;
+       path_put(&st_path);
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) */
+       return dentry;
+}
+EXPORT_SYMBOL_GPL(dentry_by_path);
+
+/**
  * @brief Get pf_group struct by dentry
  *
  * @param dentry Dentry of file
index f69bd0b..9a053d1 100644 (file)
@@ -32,6 +32,9 @@ struct pf_group;
 struct sspt_proc;
 struct probe_info;
 
+/* FIXME: create and use get_dentry() and put_dentry() */
+struct dentry *dentry_by_path(const char *path);
+
 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_by_comm(char *comm, void *priv);
index f105def..1c325b2 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/version.h>
-#include <linux/namei.h>
 
 #include <us_manager/pf/pf_group.h>
 #include <us_manager/probes/probes.h>
@@ -48,19 +47,6 @@ struct web_prof_data {
 static const char *LIBEWEBKIT2_PATH = "/usr/lib/libewebkit2.so.0";
 static struct web_prof_data *web_data;
 
-static struct dentry *dentry_by_path(const char *path)
-{
-       struct dentry *dentry;
-       struct path st_path;
-       if (kern_path(path, LOOKUP_FOLLOW, &st_path) != 0) {
-               pr_err("failed to lookup dentry for path %s!\n", path);
-               return NULL;
-       }
-       dentry = st_path.dentry;
-       path_put(&st_path);
-
-       return dentry;
-}
 
 u64 *web_prof_addr_ptr(enum web_prof_addr_t type)
 {