[PATCH v6 7/9] Add path filter
Nikolay Marchuk
marchuk.nikolay.a at gmail.com
Wed Aug 2 05:36:47 UTC 2017
* basic_filters.c: Add path filter functions.
* filter.c (filter_types): Add path filter entries.
---
basic_filters.c | 31 +++++++++++++++++++++++++++++++
filter.c | 2 ++
2 files changed, 33 insertions(+)
diff --git a/basic_filters.c b/basic_filters.c
index 2761a74..5561574 100644
--- a/basic_filters.c
+++ b/basic_filters.c
@@ -510,3 +510,34 @@ free_fd_filter(void *_priv_data)
free(set);
return;
}
+
+void *
+parse_path_filter(const char *path, const char *const name)
+{
+ struct path_set *set = xmalloc(sizeof(struct path_set));
+
+ memset(set, 0, sizeof(struct path_set));
+ pathtrace_select_set(xstrdup(path), set);
+ return set;
+}
+
+bool
+run_path_filter(struct tcb *tcp, void *_priv_data)
+{
+ struct path_set *set = _priv_data;
+
+ return pathtrace_match_set(tcp, set);
+}
+
+void
+free_path_filter(void *_priv_data)
+{
+ struct path_set *set = _priv_data;
+ unsigned int i;
+
+ for (i = 0; i < set->num_selected; ++i)
+ free((char *)set->paths_selected[i]);
+ free(set->paths_selected);
+ free(set);
+ return;
+}
diff --git a/filter.c b/filter.c
index 590228f..734b735 100644
--- a/filter.c
+++ b/filter.c
@@ -39,6 +39,7 @@ free_ ## name ## _filter(void *) \
DECL_FILTER(syscall);
DECL_FILTER(fd);
+DECL_FILTER(path);
#undef DECL_FILTER
#define FILTER_TYPE(name) \
@@ -53,6 +54,7 @@ static const struct filter_type {
} filter_types[] = {
FILTER_TYPE(syscall),
FILTER_TYPE(fd),
+ FILTER_TYPE(path),
};
#undef FILTER_TYPE
--
2.1.4
More information about the Strace-devel
mailing list