@@ -49,6 +49,9 @@ enum {
void tracecmd_record_ref(struct tep_record *record);
void free_record(struct tep_record *record);
+void tracecmd_set_quiet(int quiet);
+int tracecmd_get_quiet(void);
+
struct tracecmd_input;
struct tracecmd_output;
struct tracecmd_recorder;
@@ -1158,7 +1158,7 @@ int tracecmd_write_cpu_data(struct tracecmd_output *handle,
goto out_free;
for (i = 0; i < cpus; i++) {
- if (!quiet)
+ if (!tracecmd_get_quiet())
fprintf(stderr, "CPU%d data recorded at offset=0x%llx\n",
i, (unsigned long long) offsets[i]);
offset = lseek64(handle->fd, offsets[i], SEEK_SET);
@@ -1173,7 +1173,7 @@ int tracecmd_write_cpu_data(struct tracecmd_output *handle,
check_size, sizes[i]);
goto out_free;
}
- if (!quiet)
+ if (!tracecmd_get_quiet())
fprintf(stderr, " %llu bytes in size\n",
(unsigned long long)check_size);
}
@@ -28,6 +28,7 @@
int tracecmd_disable_sys_plugins;
int tracecmd_disable_plugins;
+static int tracecmd_quiet;
static struct registered_plugin_options {
struct registered_plugin_options *next;
@@ -96,6 +97,26 @@ char **trace_util_list_plugin_options(void)
return list;
}
+/**
+ * tracecmd_set_quiet - Set if to print output to the screen
+ * @quiet: If non zero, print no output to the screen
+ *
+ */
+void tracecmd_set_quiet(int quiet)
+{
+ tracecmd_quiet = quiet;
+}
+
+/**
+ * tracecmd_get_quiet - Get if to print output to the screen
+ * Returns non zero, if no output to the screen should be printed
+ *
+ */
+int tracecmd_get_quiet(void)
+{
+ return tracecmd_quiet;
+}
+
void trace_util_free_plugin_options_list(char **list)
{
tracecmd_free_list(list);
@@ -11,8 +11,6 @@
#include "trace-cmd.h"
#include "event-utils.h"
-extern int quiet;
-
static ssize_t __do_write(int fd, const void *data, size_t size)
{
ssize_t tot = 0;
@@ -13,7 +13,6 @@
#include "event-utils.h"
extern int debug;
-extern int quiet;
/* fix stupid glib guint64 typecasts and printf formats */
typedef unsigned long long u64;
@@ -17,7 +17,6 @@ int silence_warnings;
int show_status;
int debug;
-int quiet;
void warning(const char *fmt, ...)
{
@@ -3163,7 +3163,7 @@ static void print_stat(struct buffer_instance *instance)
{
int cpu;
- if (quiet)
+ if (tracecmd_get_quiet())
return;
if (!is_top_instance(instance))
@@ -3979,7 +3979,7 @@ static void check_plugin(const char *plugin)
}
die ("Plugin '%s' does not exist", plugin);
out:
- if (!quiet)
+ if (!tracecmd_get_quiet())
fprintf(stderr, " plugin '%s'\n", plugin);
free(buf);
}
@@ -4913,7 +4913,7 @@ static void parse_record_options(int argc,
break;
case OPT_quiet:
case 'q':
- quiet = 1;
+ tracecmd_set_quiet(1);
break;
default:
usage(argv);
A trace-cmd global variable "quiet" is used from libtracecmd and should be defined there. A new library APIs are implemented to access it: void tracecmd_set_quiet(int quiet); int tracecmd_get_quiet(void); Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> --- include/trace-cmd/trace-cmd.h | 3 +++ lib/trace-cmd/trace-output.c | 4 ++-- lib/trace-cmd/trace-util.c | 21 +++++++++++++++++++++ tracecmd/include/trace-cmd-local.h | 2 -- tracecmd/include/trace-local.h | 1 - tracecmd/trace-cmd.c | 1 - tracecmd/trace-record.c | 6 +++--- 7 files changed, 29 insertions(+), 9 deletions(-)