@@ -4,7 +4,7 @@ libtracefs(3)
NAME
----
tracefs_instance_create, tracefs_instance_destroy, tracefs_instance_alloc, tracefs_instance_free,
-tracefs_instance_is_new, tracefs_instances, tracefs_instance_reset - Manage trace instances.
+tracefs_instance_is_new, tracefs_instances, tracefs_instance_clear, tracefs_instance_reset - Manage trace instances.
SYNOPSIS
--------
@@ -18,6 +18,7 @@ struct tracefs_instance pass:[*]*tracefs_instance_alloc*(const char pass:[*]_tra
void *tracefs_instance_free*(struct tracefs_instance pass:[*]_instance_);
bool *tracefs_instance_is_new*(struct tracefs_instance pass:[*]_instance_);
char pass:[**]*tracefs_instances*(const char pass:[*]_regex_);
+void *tracefs_instance_clear*(struct tracefs_instance pass:[*]_instance_);
void *tracefs_instance_reset*(struct tracefs_instance pass:[*]_instance_);
--
@@ -61,6 +62,9 @@ it will match all instances that exist. The returned list must be freed with
*tracefs_list_free*(3). Note, if no instances are found an empty list is returned
and that too needs to be free with *tracefs_list_free*(3).
+The *tracefs_instance_clear()* function clears the ring buffer of the given _instance_
+or the top level ring buffer if _instance_ is NULL.
+
The *tracefs_instance_reset*() function resets the given _instance_ to its default state.
RETURN VALUE
@@ -83,6 +87,9 @@ The list must be freed with *tracefs_list_free*(3). An empty list is returned if
no instance exists that matches _regex_, and this needs to be freed with
*tracefs_list_free*(3) as well. NULL is returned on error.
+The *tracefs_instance_clear()* returns 0 if it successfully cleared the ring buffer,
+or -1 on error.
+
EXAMPLE
-------
[source,c]
@@ -25,6 +25,7 @@ Trace instances:
struct tracefs_instance pass:[*]*tracefs_instance_alloc*(const char pass:[*]_tracing_dir_, const char pass:[*]_name_);
void *tracefs_instance_free*(struct tracefs_instance pass:[*]_instance_);
char pass:[**]*tracefs_instances*(const char pass:[*]_regex_);
+ void *tracefs_instance_clear*(struct tracefs_instance pass:[*]_instance_);
void *tracefs_instance_reset*(struct tracefs_instance pass:[*]_instance_);
bool *tracefs_instance_is_new*(struct tracefs_instance pass:[*]_instance_);
bool *tracefs_file_exists*(struct tracefs_instance pass:[*]_instance_, char pass:[*]_name_);
@@ -25,6 +25,7 @@ struct tracefs_instance;
void tracefs_instance_free(struct tracefs_instance *instance);
void tracefs_instance_reset(struct tracefs_instance *instance);
+int tracefs_instance_clear(struct tracefs_instance *instance);
struct tracefs_instance *tracefs_instance_create(const char *name);
struct tracefs_instance *tracefs_instance_alloc(const char *tracing_dir,
const char *name);
@@ -1409,6 +1409,17 @@ static void clear_func_filters(struct tracefs_instance *instance)
clear_func_filter(instance, files[i]);
}
+/**
+ * tracefs_instance_clear - clear the trace buffer
+ * @instance: The instance to clear the trace for.
+ *
+ * Returns 0 on succes, -1 on error
+ */
+int tracefs_instance_clear(struct tracefs_instance *instance)
+{
+ return tracefs_instance_file_clear(instance, "trace");
+}
+
/**
* tracefs_instance_reset - Reset a ftrace instance to its default state
* @instance - a ftrace instance to be reseted