There is no API for clearing filter from event. After adding an API that applys a filter we must provide an identical API for clearing the filter. Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@xxxxxxxxx> --- Documentation/libtracefs-filter.txt | 8 +++++++- include/tracefs.h | 3 ++- src/tracefs-filter.c | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Documentation/libtracefs-filter.txt b/Documentation/libtracefs-filter.txt index 7db3d60..f7bbb17 100644 --- a/Documentation/libtracefs-filter.txt +++ b/Documentation/libtracefs-filter.txt @@ -3,7 +3,7 @@ libtracefs(3) NAME ---- -tracefs_filter_string_append, tracefs_filter_string_verify, tracefs_event_apply_filter - +tracefs_filter_string_append, tracefs_filter_string_verify, tracefs_event_filter_apply tracefs_event_filter_clear - Add, verify and apply event filters SYNOPSIS @@ -17,6 +17,8 @@ int tracefs_filter_string_append(struct tep_event pass:[*]event, char pass:[**] enum tracefs_synth_compare compare, const char pass:[*]val); int tracefs_filter_string_verify(struct tep_event pass:[*]event, const char pass:[*]filter, char pass:[**]err); int tracefs_event_filter_apply(struct tracefs_instance pass:[*]instance, struct tep_event pass:[*]event, const char pass:[*]filter); +int tracefs_event_filter_clear(struct tracefs_instance pass:[*]instance, struct tep_event pass:[*]event); + -- DESCRIPTION @@ -69,6 +71,8 @@ with *free*(). *tracefs_event_filter_apply*() applies given _filter_ string on _event_ in given _instance_. +*tracefs_event_filter_clear*() clear all filters on _event_ in given _instance_. + RETURN VALUE ------------ *tracefs_filter_string_append*() returns 0 on success and -1 on error. @@ -80,6 +84,8 @@ freed with *free*(). *tracefs_event_filter_apply*() returns 0 on success and -1 on error. +*tracefs_event_filter_clear*() returns 0 on success and -1 on error. + EXAMPLE ------- [source,c] diff --git a/include/tracefs.h b/include/tracefs.h index ac92dca..3ac3d9c 100644 --- a/include/tracefs.h +++ b/include/tracefs.h @@ -479,6 +479,8 @@ int tracefs_filter_string_verify(struct tep_event *event, const char *filter, int tracefs_event_filter_apply(struct tracefs_instance *instance, struct tep_event *event, const char *filter); +int tracefs_event_filter_clear(struct tracefs_instance *instance, + struct tep_event *event); /** Deprecated do not use: Instead use tracefs_filter_string_append() **/ int tracefs_event_append_filter(struct tep_event *event, char **filter, @@ -490,7 +492,6 @@ int tracefs_event_append_filter(struct tep_event *event, char **filter, int tracefs_event_verify_filter(struct tep_event *event, const char *filter, char **err); - #define TRACEFS_TIMESTAMP "common_timestamp" #define TRACEFS_TIMESTAMP_USECS "common_timestamp.usecs" diff --git a/src/tracefs-filter.c b/src/tracefs-filter.c index 7bc36fe..85d0be1 100644 --- a/src/tracefs-filter.c +++ b/src/tracefs-filter.c @@ -764,6 +764,20 @@ int tracefs_event_filter_apply(struct tracefs_instance *instance, "filter", filter); } +/** + * tracefs_event_filter_clear - clear the filter on event in given instance + * @instance: The instance in which the filter will be applied (NULL for toplevel). + * @event: The event to apply the filter on. + * + * Returns 0 on succes and -1 on error. + */ +int tracefs_event_filter_clear(struct tracefs_instance *instance, + struct tep_event *event) +{ + return tracefs_event_file_write(instance, event->system, event->name, + "filter", "0"); +} + /** Deprecated **/ int tracefs_event_append_filter(struct tep_event *event, char **filter, enum tracefs_filter type, -- 2.32.0