[PATCH 6/9] libtracefs: Add APIs tracefs_hist_data_keys/value_names()
From: Steven Rostedt
Date: Tue Aug 10 2021 - 16:48:38 EST
From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx>
Add the APIs
tracefs_hist_data_key_names()
tracefs_hist_data_value_names()
To get the names of the keys and values respectively.
Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
---
include/tracefs.h | 3 +++
src/tracefs-hist-data.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/include/tracefs.h b/include/tracefs.h
index 6fb66c44afc7..7aa6a3e5673a 100644
--- a/include/tracefs.h
+++ b/include/tracefs.h
@@ -428,6 +428,9 @@ struct tracefs_hist_data **tracefs_hist_data_read(struct tracefs_instance *insta
void tracefs_hist_data_free(struct tracefs_hist_data *hdata);
void tracefs_hist_data_free_list(struct tracefs_hist_data **hdata_list);
+char **tracefs_hist_data_key_names(struct tracefs_hist_data *hdata);
+char **tracefs_hist_data_value_names(struct tracefs_hist_data *hdata);
+
struct tracefs_synth;
/*
diff --git a/src/tracefs-hist-data.c b/src/tracefs-hist-data.c
index ab1ae824f59b..c93c27453255 100644
--- a/src/tracefs-hist-data.c
+++ b/src/tracefs-hist-data.c
@@ -1093,3 +1093,33 @@ tracefs_hist_data_read(struct tracefs_instance *instance,
return NULL;
}
+/**
+ * tracefs_hist_data_key_names - return key names
+ * @hdata: The hist data descriptor to get the names from
+ *
+ * Returns a copy of the key names of the keys. The list of keys
+ * will be in the same order as the keys are listed.
+ * Returns NULL on error.
+ *
+ * Must be freed with tracefs_list_free();
+ */
+char **tracefs_hist_data_key_names(struct tracefs_hist_data *hdata)
+{
+ return tracefs_list_dup(hdata->key_names);
+}
+
+/**
+ * tracefs_hist_data_value_names - return value names
+ * @hdata: The hist data descriptor to get the names from
+ *
+ * Returns a copy of the value names of the keys. The list of keys
+ * will be in the same order as the values are listed.
+ * Returns NULL on error.
+ *
+ * Must be freed with tracefs_list_free();
+ */
+char **tracefs_hist_data_value_names(struct tracefs_hist_data *hdata)
+{
+ return tracefs_list_dup(hdata->value_names);
+}
+
--
2.30.2