#include <us_manager/sspt/sspt_file.h>
#include <us_manager/sspt/sspt_ip.h>
#include <us_manager/probes/probe_info_new.h>
+#include <us_manager/us_common_file.h>
#include <loader/loader.h>
#include <master/swap_initializer.h>
#include "gt.h"
return lpd_get(proc);
}
-static struct dentry *get_dentry(const char *filepath)
-{
- struct path path;
- struct dentry *dentry = NULL;
-
- if (kern_path(filepath, LOOKUP_FOLLOW, &path) == 0) {
- dentry = dget(path.dentry);
- path_put(&path);
- }
-
- return dentry;
-}
-
-static void put_dentry(struct dentry *dentry)
-{
- dput(dentry);
-}
-
put_pf_group(l_probe->pfg);
if (l_probe->task_id == GT_SET_BY_DENTRY && l_probe->dentry != NULL)
- put_dentry(l_probe->dentry);
+ swap_put_dentry(l_probe->dentry);
if (l_probe->task_id == GT_SET_BY_ID && l_probe->id != NULL)
kfree(l_probe->id);
{
struct dentry *dentry;
- dentry = get_dentry(path);
+ dentry = swap_get_dentry(path);
if (dentry == NULL)
return -EINVAL;
if (_linker_fixup.dentry != NULL ||
_linker_reloc.dentry != NULL) {
if (_linker_fixup.dentry != NULL)
- put_dentry(_linker_fixup.dentry);
+ swap_put_dentry(_linker_fixup.dentry);
else
- put_dentry(_linker_reloc.dentry);
+ swap_put_dentry(_linker_reloc.dentry);
}
_linker_fixup.dentry = dentry;
struct l_probe_el *l_probe;
int ret;
- dentry = get_dentry(path);
+ dentry = swap_get_dentry(path);
if (dentry == NULL)
return -EINVAL;
put_pf_group(pfg);
add_by_path_put_dentry:
- put_dentry(dentry);
+ swap_put_dentry(dentry);
return ret;
}
struct dentry *dentry;
int ret = 0;
- dentry = get_dentry(path);
+ dentry = swap_get_dentry(path);
if (dentry == NULL)
return -EINVAL;
int ret;
/* We use get_dentry only once, so use put dentry also only once */
- dentry = get_dentry(path);
+ dentry = swap_get_dentry(path);
if (dentry == NULL)
return -EINVAL;
if (_handler_fixup.dentry != NULL ||
_handler_reloc.dentry != NULL) {
if (_handler_fixup.dentry != NULL)
- put_dentry(_handler_fixup.dentry);
+ swap_put_dentry(_handler_fixup.dentry);
else
- put_dentry(_handler_reloc.dentry);
+ swap_put_dentry(_handler_reloc.dentry);
}
_handler_fixup.dentry = dentry;
{
struct dentry *dentry;
- dentry = get_dentry(path);
+ dentry = swap_get_dentry(path);
if (dentry == NULL)
return -EINVAL;
if (_pthread_init.dentry != NULL)
- put_dentry(_pthread_init.dentry);
+ swap_put_dentry(_pthread_init.dentry);
_pthread_init.dentry = dentry;
if (_handler_fixup.dentry != NULL ||
_handler_reloc.dentry != NULL) {
if (_handler_fixup.dentry != NULL)
- put_dentry(_handler_fixup.dentry);
+ swap_put_dentry(_handler_fixup.dentry);
else
- put_dentry(_handler_reloc.dentry);
+ swap_put_dentry(_handler_reloc.dentry);
}
}
#include <linux/limits.h>
#include <asm/uaccess.h>
#include <master/swap_debugfs.h>
+#include <us_manager/us_common_file.h>
#include "loader_defs.h"
#include "loader_debugfs.h"
#include "loader_module.h"
{
__loader_info.path = path;
dentry_lock();
- __loader_info.dentry = get_dentry(__loader_info.path);
+ __loader_info.dentry = swap_get_dentry(__loader_info.path);
dentry_unlock();
}
dentry_lock();
if (__loader_info.dentry != NULL)
- put_dentry(__loader_info.dentry);
+ swap_put_dentry(__loader_info.dentry);
__loader_info.dentry = NULL;
__loader_info.offset = 0;
static int __loader_cbs_stop_h = -1;
-static struct dentry *__get_dentry(struct dentry *dentry)
-{
- atomic_inc(&dentry_balance);
- return dget(dentry);
-}
-
-
bool loader_module_is_running(void)
{
__loader_status = SWAP_LOADER_NOT_READY;
}
-struct dentry *get_dentry(const char *filepath)
-{
- struct path path;
- struct dentry *dentry = NULL;
-
- if (kern_path(filepath, LOOKUP_FOLLOW, &path) == 0) {
- dentry = __get_dentry(path.dentry);
- path_put(&path);
- }
-
- return dentry;
-}
-
-void put_dentry(struct dentry *dentry)
-{
- atomic_dec(&dentry_balance);
- dput(dentry);
-}
-
static inline void __prepare_ujump(struct uretprobe_instance *ri,
struct pt_regs *regs,
unsigned long vaddr)
#include <linux/fs.h>
#include <linux/list.h>
#include <ks_features/ks_map.h>
+#include <us_manager/us_common_file.h>
#include "loader_defs.h"
#include "loader_module.h"
#include "loader_storage.h"
struct bin_info_el *bin;
int ret = 0;
- dentry = get_dentry(path);
+ dentry = swap_get_dentry(path);
if (!dentry) {
ret = -ENOENT;
goto add_handler_out;
kfree(bin);
add_handler_fail_release_dentry:
- put_dentry(dentry);
+ swap_put_dentry(dentry);
add_handler_out:
return ret;
static inline void __remove_handler(struct bin_info_el *bin)
{
list_del(&bin->list);
- put_dentry(bin->dentry);
+ swap_put_dentry(bin->dentry);
kfree(bin->path);
kfree(bin);
}
goto init_linker_fail;
}
- dentry = get_dentry(path);
+ dentry = swap_get_dentry(path);
if (!dentry) {
ret = -ENOENT;
goto init_linker_fail_free;
__linker_info.path = NULL;
if (__linker_info.dentry)
- put_dentry(__linker_info.dentry);
+ swap_put_dentry(__linker_info.dentry);
__linker_info.dentry = NULL;
}
#include <linux/list.h>
#include <us_manager/sspt/sspt_ip.h>
+#include <us_manager/us_common_file.h>
#include "preload.h"
#include "preload_module.h"
list_for_each_entry_safe(p, n, &rm_head, list) {
list_del(&p->list);
- put_dentry(p->dentry);
+ swap_put_dentry(p->dentry);
__free_binary(p);
}
}
int pc_add_instrumented_binary(char *filename)
{
- struct dentry *dentry = get_dentry(filename);
+ struct dentry *dentry = swap_get_dentry(filename);
int res = 0;
if (dentry == NULL)
res = __add_binary(dentry, filename, &target);
if (res != 0)
- put_dentry(dentry);
+ swap_put_dentry(dentry);
return res > 0 ? 0 : res;
}
int pc_add_ignored_binary(char *filename)
{
- struct dentry *dentry = get_dentry(filename);
+ struct dentry *dentry = swap_get_dentry(filename);
int res = 0;
if (dentry == NULL)
res = __add_binary(dentry, filename, &ignored);
if (res != 0)
- put_dentry(dentry);
+ swap_put_dentry(dentry);
return res > 0 ? 0 : res;
}
#include <us_manager/sspt/sspt_ip.h>
#include <us_manager/sspt/sspt_page.h>
#include <us_manager/sspt/sspt_file.h>
+#include <us_manager/us_common_file.h>
#include <loader/loader.h>
#include <master/swap_initializer.h>
#include "preload.h"
-struct dentry *get_dentry(const char *filepath)
-{
- struct path path;
- struct dentry *dentry = NULL;
-
- if (kern_path(filepath, LOOKUP_FOLLOW, &path) == 0) {
- dentry = dget(path.dentry);
- path_put(&path);
- }
-
- return dentry;
-}
-
-void put_dentry(struct dentry *dentry)
-{
- dput(dentry);
-}
-
int pm_get_caller_init(struct sspt_ip *ip)
{
struct uprobe *up = &ip->uprobe;
int ret;
if (handler_dentry != NULL)
- put_dentry(handler_dentry);
+ swap_put_dentry(handler_dentry);
- dentry = get_dentry(path);
+ dentry = swap_get_dentry(path);
if (dentry == NULL) {
printk(KERN_WARNING PRELOAD_PREFIX "Error! Cannot get handler %s\n",
pd_exit();
if (handler_dentry != NULL)
- put_dentry(handler_dentry);
+ swap_put_dentry(handler_dentry);
}
SWAP_LIGHT_INIT_MODULE(NULL, pm_init, pm_exit, NULL, NULL);
void pm_write_msg_exit(struct sspt_ip *ip);
int pm_set_handler(char *path);
-struct dentry *get_dentry(const char *filepath);
-void put_dentry(struct dentry *dentry);
-
#endif /* __PRELOAD_MODULE_H__ */
#include <us_manager/sspt/sspt_ip.h>
#include <us_manager/callbacks.h>
#include <us_manager/probes/probe_info_new.h>
+#include <us_manager/us_common_file.h>
#include <writer/kernel_operations.h>
#include <master/swap_initializer.h>
#include <writer/swap_msg.h>
return 0;
}
-struct dentry *get_dentry(const char *filepath)
-{
- struct path path;
- struct dentry *dentry = NULL;
-
- if (kern_path(filepath, LOOKUP_FOLLOW, &path) == 0) {
- dentry = dget(path.dentry);
- path_put(&path);
- }
-
- return dentry;
-}
-
-void put_dentry(struct dentry *dentry)
-{
- dput(dentry);
-}
-
int uihv_data_set(const char *app_path, unsigned long main_addr)
{
struct dentry *dentry;
int ret;
if (uihv_dentry != NULL)
- put_dentry(uihv_dentry);
+ swap_put_dentry(uihv_dentry);
- dentry = get_dentry(path);
+ dentry = swap_get_dentry(path);
if (dentry == NULL) {
printk(KERN_WARNING UIHV_PREFIX "Error! Cannot get handler %s\n",
path);
static void uihv_exit(void)
{
if (uihv_dentry != NULL)
- put_dentry(uihv_dentry);
+ swap_put_dentry(uihv_dentry);
uihv_dfs_exit();
}
#include <us_manager/img/img_ip.h>
#include <us_manager/sspt/sspt_proc.h>
#include <us_manager/helper.h>
+#include <us_manager/us_common_file.h>
#include <task_ctx/task_ctx.h>
up_write(&task->mm->mmap_sem);
}
-struct dentry *dentry_get(const char *path)
-{
- struct dentry *d;
- 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;
- }
-
- d = st_path.dentry;
- dget(d);
- path_put(&st_path);
-
- return d;
-}
-EXPORT_SYMBOL_GPL(dentry_get);
-
-void dentry_put(struct dentry *d)
-{
- dput(d);
-}
-EXPORT_SYMBOL_GPL(dentry_put);
-
/**
* @brief Get dentry struct by path
{
struct dentry *d;
- d = dentry_get(path);
+ d = swap_get_dentry(path);
if (d)
dput(d);
};
-/* FIXME: create and use get_dentry() and put_dentry() */
+/* FIXME: use swap_get_dentry() and swap_put_dentry() */
struct dentry *dentry_by_path(const char *path);
-struct dentry *dentry_get(const char *path);
-void dentry_put(struct dentry *d);
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);
--- /dev/null
+/*
+ * SWAP uprobe manager
+ * modules/us_manager/us_manager_common_file.h
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) Samsung Electronics, 2017
+ *
+ * 2017 Alexander Aksenov: SWAP us_manager implement
+ *
+ */
+
+#ifndef __US_MANAGER_COMMON_FILE_H__
+#define __US_MANAGER_COMMON_FILE_H__
+
+#include <linux/dcache.h>
+#include <linux/namei.h>
+
+static inline struct dentry *swap_get_dentry(const char *filepath)
+{
+ struct path path;
+ struct dentry *dentry = NULL;
+
+ if (kern_path(filepath, LOOKUP_FOLLOW, &path) == 0) {
+ dentry = dget(path.dentry);
+ path_put(&path);
+ }
+
+ return dentry;
+}
+
+static inline void swap_put_dentry(struct dentry *dentry)
+{
+ dput(dentry);
+}
+
+#endif /* __US_MANAGER_COMMON_FILE_H__ */