*/
+#include <linux/string.h>
#include <uprobe/swap_uaccess.h>
#include <us_manager/sspt/sspt.h>
#include <us_manager/probes/probe_info_new.h>
};
-/* TODO: configure this from outside (using debugfs) */
-static const char webapp_path[] = "/usr/bin/wrt_launchpad_daemon";
-static const char ewebkit_path[] = "/usr/lib/libewebkit2.so";
+static char *webapp_path = NULL;
+static char *ewebkit_path = NULL;
#define WSP_PROBE_MAKE(__name, __desc) \
};
static struct wsp_bin ewebkit = {
- .name = ewebkit_path,
+ .name = NULL,
.cnt = ewebkit_probes_cnt,
.probe_array = ewebkit_probe_array
};
wsp_probe_unregister(pfg, dentry, &bin->probe_array[i]);
}
+static void do_set_path(char **dest, char *path, size_t len)
+{
+ *dest = kmalloc(len, GFP_KERNEL);
+ if (*dest == NULL) {
+ printk("Not enough memory to init path\n");
+ return;
+ }
+
+ strncpy(*dest, path, len);
+}
+
+static void do_free_path(char **dest)
+{
+ kfree(*dest);
+}
+
static struct pf_group *g_pfg;
{
struct dentry *dentry;
+ if (webapp_path == NULL || ewebkit_path == NULL) {
+ printk("WSP: some required paths are not set!\n");
+ return -EINVAL;
+ }
+
+ ewebkit.name = ewebkit_path;
+
dentry = dentry_by_path(webapp_path);
if (dentry == NULL) {
pr_err("dentry not found (path='%s'\n", webapp_path);
static void wsp_app_unregister(void)
{
+ if (ewebkit.name != NULL) {
+ printk("WSP: ewebkit path is not initialized\n");
+ return;
+ }
+
wsp_bin_unregister(g_pfg, &ewebkit);
put_pf_group(g_pfg);
}
{
wsp_app_unregister();
wsp_res_exit();
+ do_free_path(&webapp_path);
+ do_free_path(&ewebkit_path);
}
return g_mode;
}
+void wsp_set_webapp_path(char *path, size_t len)
+{
+ do_free_path(&webapp_path);
+ do_set_path(&webapp_path, path, len);
+}
+
+void wsp_set_ewebkit_path(char *path, size_t len)
+{
+ do_free_path(&ewebkit_path);
+ do_set_path(&ewebkit_path, path, len);
+}
+
int wsp_init(void)
{
return 0;
int wsp_set_mode(enum wsp_mode mode);
enum wsp_mode wsp_get_mode(void);
+void wsp_set_webapp_path(char *path, size_t len);
+void wsp_set_ewebkit_path(char *path, size_t len);
+
int wsp_init(void);
void wsp_exit(void);
}
/* ============================================================================
- * === DEBUGFS FOR ENABLE ===
+ * === DEBUGFS FOR CMD ===
* ============================================================================
*/
static ssize_t write_cmd(struct file *file, const char __user *user_buf,
};
+
+
+/* ============================================================================
+ * === DEBUGFS FOR WEBAPP_PATH ===
+ * ============================================================================
+ */
+static ssize_t write_webapp_path(struct file *file, const char __user *user_buf,
+ size_t len, loff_t *ppos)
+{
+ ssize_t ret;
+ char *path;
+
+ path = kmalloc(len, GFP_KERNEL);
+ if (path == NULL) {
+ ret = -ENOMEM;
+ goto write_webapp_path_failed;
+ }
+
+ if (copy_from_user(path, user_buf, len)) {
+ ret = -EINVAL;
+ goto write_webapp_path_failed;
+ }
+
+ path[len - 1] = '\0';
+
+ wsp_set_webapp_path(path, len);
+
+ ret = len;
+
+write_webapp_path_failed:
+ kfree(path);
+
+ return ret;
+}
+
+static const struct file_operations fops_webapp_path = {
+ .write = write_webapp_path
+};
+
+
+
+
+/* ============================================================================
+ * === DEBUGFS FOR EWEBKIT_PATH ===
+ * ============================================================================
+ */
+static ssize_t write_ewebkit_path(struct file *file, const char __user *user_buf,
+ size_t len, loff_t *ppos)
+{
+ ssize_t ret;
+ char *path;
+
+ path = kmalloc(len, GFP_KERNEL);
+ if (path == NULL) {
+ ret = -ENOMEM;
+ goto write_ewebkit_path_failed;
+ }
+
+ if (copy_from_user(path, user_buf, len)) {
+ ret = -EINVAL;
+ goto write_ewebkit_path_failed;
+ }
+
+ path[len - 1] = '\0';
+
+ wsp_set_ewebkit_path(path, len);
+
+ ret = len;
+
+write_ewebkit_path_failed:
+ kfree(path);
+
+ return ret;
+}
+
+static const struct file_operations fops_ewebkit_path = {
+ .write = write_ewebkit_path
+};
+
+
+
+
static struct dentry *wsp_dir;
void wsp_debugfs_exit(void)
if (dentry == NULL)
goto fail;
+ dentry = debugfs_create_file("webapp_path", 0600, wsp_dir, NULL,
+ &fops_webapp_path);
+ if (dentry == NULL)
+ goto fail;
+
+ dentry = debugfs_create_file("ewebkit_path", 0600, wsp_dir, NULL,
+ &fops_ewebkit_path);
+ if (dentry == NULL)
+ goto fail;
+
return 0;
fail: