diff mbox series

[1/1] libtracefs: New API for clearing filter on event

Message ID 20211130143422.127433-2-y.karadz@gmail.com (mailing list archive)
State Superseded
Headers show
Series libtracefs: New API for clearing filters | expand

Commit Message

Yordan Karadzhov Nov. 30, 2021, 2:34 p.m. UTC
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@gmail.com>
---
 Documentation/libtracefs-filter.txt |  7 ++++++-
 include/tracefs.h                   |  2 ++
 src/tracefs-filter.c                | 14 ++++++++++++++
 3 files changed, 22 insertions(+), 1 deletion(-)

Comments

Steven Rostedt Dec. 2, 2021, 2:59 p.m. UTC | #1
On Tue, 30 Nov 2021 16:34:22 +0200
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:

> @@ -81,6 +84,8 @@ freed with *free*().
>  
>  *tracefs_event_apply_filter*() returns 0 on success and -1 on error.
>  
> +*tracefs_event_clear_filter*() returns 0 on success and -1 on error.
> +

I just applied Tzvetomir's patches, and he renamed the function to:

  tracefs_event_filter_apply()

Can you resubmit a rebased version of this patch and rename he function to:

  tracefs_event_filter_clear()

Thanks,

-- Steve
diff mbox series

Patch

diff --git a/Documentation/libtracefs-filter.txt b/Documentation/libtracefs-filter.txt
index 7532c96..cdb0bcf 100644
--- a/Documentation/libtracefs-filter.txt
+++ b/Documentation/libtracefs-filter.txt
@@ -3,7 +3,7 @@  libtracefs(3)
 
 NAME
 ----
-tracefs_event_append_filter, tracefs_event_verify_filter tracefs_event_apply_filter -
+tracefs_event_append_filter, tracefs_event_verify_filter tracefs_event_apply_filter tracefs_event_clear_filter -
 Add, verify and apply event filters
 
 SYNOPSIS
@@ -17,6 +17,7 @@  int tracefs_event_append_filter(struct tep_event pass:[*]event, char pass:[**] f
 				 enum tracefs_synth_compare compare, const char pass:[*]val);
 int tracefs_event_verify_filter(struct tep_event pass:[*]event, const char pass:[*]filter, char pass:[**]err);
 int tracefs_event_apply_filter(struct tracefs_instance pass:[*]instance, struct tep_event pass:[*]event, const char pass:[*]filter);
+int tracefs_event_clear_filter(struct tracefs_instance pass:[*]instance, struct tep_event pass:[*]event);
 
 --
 
@@ -70,6 +71,8 @@  with *free*().
 
 *tracefs_event_apply_filter*() applies given _filter_ string on _event_ in given _instance_.
 
+*tracefs_event_clear_filter*() clear all filters on _event_ in given _instance_.
+
 RETURN VALUE
 ------------
 *tracefs_event_append_filter*() returns 0 on success and -1 on error.
@@ -81,6 +84,8 @@  freed with *free*().
 
 *tracefs_event_apply_filter*() returns 0 on success and -1 on error.
 
+*tracefs_event_clear_filter*() returns 0 on success and -1 on error.
+
 EXAMPLE
 -------
 [source,c]
diff --git a/include/tracefs.h b/include/tracefs.h
index 8ac9694..effc3e5 100644
--- a/include/tracefs.h
+++ b/include/tracefs.h
@@ -477,6 +477,8 @@  int tracefs_event_verify_filter(struct tep_event *event, const char *filter,
 				char **err);
 int tracefs_event_apply_filter(struct tracefs_instance *instance,
 			       struct tep_event *event, const char *filter);
+int tracefs_event_clear_filter(struct tracefs_instance *instance,
+			       struct tep_event *event);
 
 
 #define TRACEFS_TIMESTAMP "common_timestamp"
diff --git a/src/tracefs-filter.c b/src/tracefs-filter.c
index 43683d0..6d8c66f 100644
--- a/src/tracefs-filter.c
+++ b/src/tracefs-filter.c
@@ -764,3 +764,17 @@  int tracefs_event_apply_filter(struct tracefs_instance *instance,
 					 "filter", filter);
 }
 
+/**
+ * tracefs_event_clear_filter - 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 clear the filter on.
+ *
+ * Returns 0 on succes and -1 on error.
+ */
+int tracefs_event_clear_filter(struct tracefs_instance *instance,
+			       struct tep_event *event)
+{
+	return tracefs_event_file_write(instance, event->system, event->name,
+					"filter", "0");
+}
+