[FIX] change nsp functions 23/77423/4
authorAnatolii Nikulin <nikulin.a@samsung.com>
Wed, 29 Jun 2016 13:52:18 +0000 (16:52 +0300)
committerAnatolii Nikulin <nikulin.a@samsung.com>
Thu, 30 Jun 2016 06:17:58 +0000 (09:17 +0300)
Change-Id: I0daf666880368ed290285d3fdc7e90e78bc5639f
Signed-off-by: Anatolii Nikulin <nikulin.a@samsung.com>
nsp/nsp.c
nsp/nsp.h
nsp/nsp_debugfs.c

index dcc42c1..8319997 100644 (file)
--- a/nsp/nsp.c
+++ b/nsp/nsp.c
@@ -101,6 +101,8 @@ static struct dentry *lpad_dentry;
 
 static const char *libappcore_path;
 static struct dentry *libappcore_dentry;
+static const char *libcapi_path;
+static struct dentry *libcapi_dentry;
 
 static void uninit_variables(void)
 {
@@ -111,11 +113,15 @@ static void uninit_variables(void)
        kfree(libappcore_path);
        libappcore_path = NULL;
        libappcore_dentry = NULL;
+
+       kfree(libcapi_path);
+       libcapi_path = NULL;
+       libcapi_dentry = NULL;
 }
 
 static bool is_init(void)
 {
-       return lpad_dentry && libappcore_dentry;
+       return lpad_dentry && libappcore_dentry && libcapi_dentry;
 }
 
 static int do_set_lpad_info(const char *path, unsigned long dlopen,
@@ -146,33 +152,57 @@ static int do_set_lpad_info(const char *path, unsigned long dlopen,
        return 0;
 }
 
-static int do_set_appcore_info(struct appcore_info_data *info)
+static int do_set_appcore_info(struct nsp_info_data *info)
 {
        struct dentry *dentry;
        const char *new_path;
+       int ret = 0;
 
-       dentry = dentry_by_path(info->path);
-       if (dentry == NULL) {
-               pr_err("dentry not found (path='%s')\n", info->path);
-               return -EINVAL;
-       }
-
-       new_path = kstrdup(info->path, GFP_KERNEL);
-       if (new_path == NULL) {
-               pr_err("out of memory\n");
+       new_path = kstrdup(info->appcore_path, GFP_KERNEL);
+       if (!new_path)
                return -ENOMEM;
-       }
-
        kfree(libappcore_path);
-
        libappcore_path = new_path;
+
+       new_path = kstrdup(info->capi_path, GFP_KERNEL);
+       if (!new_path) {
+               ret = -ENOMEM;
+               goto fail_alloc;
+       }
+       kfree(libcapi_path);
+       libcapi_path = new_path;
+
+       dentry = dentry_by_path(info->appcore_path);
+       if (!dentry) {
+               pr_err("dentry not found (path='%s')\n", info->appcore_path);
+               ret = -EINVAL;
+               goto fail;
+       }
        libappcore_dentry = dentry;
-       p_ac_efl_main.offset = info->ac_efl_main;
+
+       dentry = dentry_by_path(info->capi_path);
+       if (!dentry) {
+               pr_err("dentry not found (path='%s')\n", info->capi_path);
+               ret = -EINVAL;
+               goto fail;
+       }
+       libcapi_dentry = dentry;
+
+       p_ac_efl_main.offset = info->ac_efl_init;
+       p_do_app.offset = info->do_app;
        p_ac_init.offset = info->ac_init;
        p_elm_run.offset = info->elm_run;
-       p_do_app.offset = info->do_app;
 
        return 0;
+
+fail:
+       kfree(libcapi_path);
+       libcapi_path = NULL;
+fail_alloc:
+       kfree(libappcore_path);
+       libappcore_path = NULL;
+
+       return ret;
 }
 
 
@@ -288,11 +318,11 @@ static int nsp_data_inst(struct nsp_data *data)
        if (ret)
                goto ur_main;
 
-       ret = pin_register(&p_ac_init, pfg, libappcore_dentry);
+       ret = pin_register(&p_ac_init, pfg, libcapi_dentry);
        if (ret)
                goto ur_ac_efl_main;
 
-       ret = pin_register(&p_elm_run, pfg, libappcore_dentry);
+       ret = pin_register(&p_elm_run, pfg, libcapi_dentry);
        if (ret)
                goto ur_ac_init;
 
@@ -305,9 +335,9 @@ static int nsp_data_inst(struct nsp_data *data)
        return 0;
 
 ur_elm_run:
-       pin_unregister(&p_elm_run, pfg, libappcore_dentry);
+       pin_unregister(&p_elm_run, pfg, libcapi_dentry);
 ur_ac_init:
-       pin_unregister(&p_ac_init, pfg, libappcore_dentry);
+       pin_unregister(&p_ac_init, pfg, libcapi_dentry);
 ur_ac_efl_main:
        pin_unregister(&p_ac_efl_main, pfg, libappcore_dentry);
 ur_main:
@@ -326,8 +356,8 @@ static void nsp_data_uninst(struct nsp_data *data)
        struct pf_group *pfg = data->pfg;
 
        pin_unregister(&p_do_app, pfg, libappcore_dentry);
-       pin_unregister(&p_elm_run, pfg, libappcore_dentry);
-       pin_unregister(&p_ac_init, pfg, libappcore_dentry);
+       pin_unregister(&p_elm_run, pfg, libcapi_dentry);
+       pin_unregister(&p_ac_init, pfg, libcapi_dentry);
        pin_unregister(&p_ac_efl_main, pfg, libappcore_dentry);
        pin_unregister(&data->p_main, pfg, data->app_dentry);
        pin_unregister(&p_dlopen, pfg, lpad_dentry);
@@ -462,7 +492,7 @@ DECLARE_SAFE_FUNC3(nsp_set_lpad_info, do_set_lpad_info,
                   const char *, path, unsigned long, dlopen,
                   unsigned long, dlsym);
 DECLARE_SAFE_FUNC1(nsp_set_appcore_info, do_set_appcore_info,
-                  struct appcore_info_data *, info);
+                  struct nsp_info_data *, info);
 
 
 
index ccda314..35236a4 100644 (file)
--- a/nsp/nsp.h
+++ b/nsp/nsp.h
@@ -33,10 +33,12 @@ enum nsp_stat {
        NS_ON
 };
 
-struct appcore_info_data {
-       const char *path;
-       unsigned long ac_efl_main;
+struct nsp_info_data {
+       const char *appcore_path;
+       unsigned long ac_efl_init;
        unsigned long do_app;
+
+       const char *capi_path;
        unsigned long ac_init;
        unsigned long elm_run;
 };
@@ -46,7 +48,7 @@ void nsp_exit(void);
 
 int nsp_set_lpad_info(const char *path, unsigned long dlopen,
                      unsigned long dlsym);
-int nsp_set_appcore_info(struct appcore_info_data *info);
+int nsp_set_appcore_info(struct nsp_info_data *info);
 
 int nsp_set_stat(enum nsp_stat st);
 enum nsp_stat nsp_get_stat(void);
index 779853d..29b68ab 100644 (file)
@@ -133,41 +133,51 @@ free_lpad_path:
 
 /*
  * format:
- *     appcore_efl_main:__do_app:appcore_init@plt:elm_run@plt:libappcore-efl
+ *     appcore_efl_init:__do_app:libappcore-efl ui_app_init:elm_run@plt:libcapi-appfw-application
  *
  * sample:
- *     0x3730:0x2960:0x1810:0x1c70:/usr/lib/libappcore-efl.so.1
+ *     0x2000:0x2ed0:/usr/lib/libappcore-efl.so.1 0x2b20:0x11f0:/usr/lib/libcapi-appfw-application.so.0
  */
 static int do_set_appcore_info(const char *data, size_t len)
 {
        int n, ret;
-       struct appcore_info_data info;
-       const char fmt[] = "%%lx:%%lx:%%lx:%%lx:/%%%ds";
+       struct nsp_info_data info;
+       const char fmt[] = "%%lx:%%lx:/%%%ds %%lx:%%lx:/%%%ds";
        char fmt_buf[64];
-       char *path;
+       char *appcore_path, *capi_path;
 
-       n = snprintf(fmt_buf, sizeof(fmt_buf), fmt, PATH_MAX - 2);
+       n = snprintf(fmt_buf, sizeof(fmt_buf), fmt, PATH_MAX - 2, PATH_MAX - 2);
        if (n <= 0)
                return -EINVAL;
 
-       path = kmalloc(PATH_MAX, GFP_KERNEL);
-       if (path == NULL)
+       appcore_path = kmalloc(PATH_MAX, GFP_KERNEL);
+       if (!appcore_path)
                return -ENOMEM;
 
+       capi_path = kmalloc(PATH_MAX, GFP_KERNEL);
+       if (!capi_path) {
+               ret = -ENOMEM;
+               goto fail_alloc;
+       }
+
        n = sscanf(data, fmt_buf,
-                  &info.ac_efl_main, &info.do_app,
-                  &info.ac_init, &info.elm_run, path + 1);
-       if (n != 5) {
+                  &info.ac_efl_init, &info.do_app, appcore_path + 1,
+                  &info.ac_init, &info.elm_run, capi_path + 1);
+       if (n != 6) {
                ret = -EINVAL;
-               goto free_lib_path;
+               goto fail;
        }
-       path[0] = '/';
+       appcore_path[0] = '/';
+       capi_path[0] = '/';
 
-       info.path = path;
+       info.appcore_path = appcore_path;
+       info.capi_path = capi_path;
        ret = nsp_set_appcore_info(&info);
 
-free_lib_path:
-       kfree(path);
+fail:
+       kfree(capi_path);
+fail_alloc:
+       kfree(appcore_path);
        return ret;
 }
 
@@ -256,7 +266,7 @@ static ssize_t read_cmd(struct file *file, char __user *user_buf,
                        "\tr $app_path - remove\n"
                        "\tc - remove all\n"
                        "\tb dlopen_addr@plt:dlsym_addr@plt:launchpad_path\n"
-                       "\tl appcore_efl_main:__do_app:appcore_init@plt:elm_run@plt:libappcore-efl_path\n";
+                       "\tl appcore_efl_init:__do_app:libappcore-efl_path ui_app_init:elm_run@plt:libcapi-appfw-application_path\n";
        ssize_t ret;
 
        ret = simple_read_from_buffer(user_buf, count, ppos,