[PATCH v6 7/9] Add path filter
Eugene Syromiatnikov
esyr at redhat.com
Mon Aug 7 06:00:18 UTC 2017
On Wed, Aug 02, 2017 at 12:36:47PM +0700, Nikolay Marchuk wrote:
> * 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));
xmalloc+memset -> xcalloc
> + pathtrace_select_set(xstrdup(path), set);
It will leak if equal path is already in table.
> + 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]);
Missing space before "set".
> + 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
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Strace-devel mailing list
> Strace-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/strace-devel
More information about the Strace-devel
mailing list