'\" t .\" Title: libtracefs .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 05/25/2021 .\" Manual: libtracefs Manual .\" Source: libtracefs 1.2.0 .\" Language: English .\" .TH "LIBTRACEFS" "3" "05/25/2021" "libtracefs 1\&.2\&.0" "libtracefs Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" tracefs_instance_get_name, tracefs_instance_get_trace_dir, tracefs_instances_walk, tracefs_instance_exists \- Helper functions for working with tracing instances\&. .SH "SYNOPSIS" .sp .nf \fB#include \fR const char *\fBtracefs_instance_get_name\fR(struct tracefs_instance *\fIinstance\fR); const char *\fBtracefs_instance_get_trace_dir\fR(struct tracefs_instance *\fIinstance\fR); int \fBtracefs_instances_walk\fR(int (*\fIcallback\fR)(const char *, void *), void *\fIcontext)\fR; bool \fBtracefs_instance_exists\fR(const char *\fIname\fR); .fi .SH "DESCRIPTION" .sp Helper functions for working with trace instances\&. .sp The \fItracefs_instance_get_name()\fR function returns the name of the given \fIinstance\fR\&. Note that the top instance has no name, the function returns NULL for it\&. .sp The \fItracefs_instance_get_trace_dir()\fR function returns the tracing directory, where the given \fIinstance\fR is configured\&. .sp The \fItracefs_instances_walk()\fR function walks through all configured tracing instances in the system and calls \fIcallback\fR for each one of them\&. The \fIcontext\fR argument is passed to the \fIcallback\fR, together with the instance name\&. If the \fIcallback\fR returns non\-zero, the iteration stops\&. Note, the \fIcallback\fR is not called for the top top instance\&. .sp The \fItracefs_instance_exists()\fR function checks if an instance with the given \fIname\fR exists in the system\&. .SH "RETURN VALUE" .sp The \fItracefs_instance_get_name()\fR returns a string or NULL in case of the top instance\&. The returned string must \fInot\fR be freed\&. .sp The \fItracefs_instance_get_trace_dir()\fR returns a string or NULL in case of an error\&. The returned string must \fInot\fR be freed\&. .sp The \fItracefs_instances_walk()\fR function returns 0, if all instances were iterated, 1 if the iteration was stopped by the \fIcallback\fR, or \-1 in case of an error\&. .sp The \fItracefs_instance_exists()\fR returns true if an instance with the given name exists in the system or false otherwise\&. .SH "EXAMPLE" .sp .if n \{\ .RS 4 .\} .nf #include struct tracefs_instance *inst; \&.\&.\&.\&. char *name = tracefs_instance_get_name(inst); if(name) { /* Got name of the instance */ } char *dir = tracefs_instance_get_trace_dir(inst); if(dir) { /* Got tracing directory of the instance */ } \&.\&.\&. static int instance_walk(char *name, void *context) { /* Got instance with name */ return 0; } \&.\&.\&. if (tracefs_instances_walk(instance_walk, NULL) < 0) { /* Error walking through the instances */ } \&.\&.\&. if (tracefs_instance_exists("foo")) { /* There is instance with name foo in the system */ } else { /* There is no instance with name foo in the system */ } .fi .if n \{\ .RE .\} .SH "FILES" .sp .if n \{\ .RS 4 .\} .nf \fBtracefs\&.h\fR Header file to include in order to have access to the library APIs\&. \fB\-ltracefs\fR Linker switch to add when building a program that uses the library\&. .fi .if n \{\ .RE .\} .SH "SEE ALSO" .sp \fIlibtracefs(3)\fR, \fIlibtraceevent(3)\fR, \fItrace\-cmd(1)\fR .SH "AUTHOR" .sp .if n \{\ .RS 4 .\} .nf \fBSteven Rostedt\fR <\m[blue]\fBrostedt@goodmis\&.org\fR\m[]\&\s-2\u[1]\d\s+2> \fBTzvetomir Stoyanov\fR <\m[blue]\fBtz\&.stoyanov@gmail\&.com\fR\m[]\&\s-2\u[2]\d\s+2> .fi .if n \{\ .RE .\} .SH "REPORTING BUGS" .sp Report bugs to <\m[blue]\fBlinux\-trace\-devel@vger\&.kernel\&.org\fR\m[]\&\s-2\u[3]\d\s+2> .SH "LICENSE" .sp libtracefs is Free Software licensed under the GNU LGPL 2\&.1 .SH "RESOURCES" .sp \m[blue]\fBhttps://git\&.kernel\&.org/pub/scm/libs/libtrace/libtracefs\&.git/\fR\m[] .SH "COPYING" .sp Copyright (C) 2020 VMware, Inc\&. Free use of this software is granted under the terms of the GNU Public License (GPL)\&. .SH "NOTES" .IP " 1." 4 rostedt@goodmis.org .RS 4 \%mailto:rostedt@goodmis.org .RE .IP " 2." 4 tz.stoyanov@gmail.com .RS 4 \%mailto:tz.stoyanov@gmail.com .RE .IP " 3." 4 linux-trace-devel@vger.kernel.org .RS 4 \%mailto:linux-trace-devel@vger.kernel.org .RE