'\" t
.\" Title: libtracefs
.\" Author: [see the "AUTHOR" section]
.\" Generator: DocBook XSL Stylesheets vsnapshot
.\" Date: 01/16/2024
.\" Manual: libtracefs Manual
.\" Source: libtracefs 1.8.0
.\" Language: English
.\"
.TH "LIBTRACEFS" "3" "01/16/2024" "libtracefs 1\&.8\&.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_get_tracing_file, tracefs_put_tracing_file, tracefs_tracing_dir, tracefs_debug_dir, tracefs_set_tracing_dir, tracefs_tracing_dir_is_mounted \- Find and set locations of trace directory and files\&.
.SH "SYNOPSIS"
.sp
.nf
\fB#include \fR
char *\fBtracefs_get_tracing_file\fR(const char *\fIname\fR);
void \fBtracefs_put_tracing_file\fR(char *\fIname\fR);
const char *\fBtracefs_tracing_dir\fR(void);
const char *\fBtracefs_debug_dir\fR(void);
int \fBtracefs_set_tracing_dir\fR(char *\fItracing_dir\fR)
int \fBtracefs_tracing_dir_is_mounted\fR(bool \fImount\fR, const char **\fIpath\fR);
.fi
.SH "DESCRIPTION"
.sp
This set of APIs can be used to find the full path of the trace file system mount point and trace files in it\&.
.sp
The \fBtracefs_set_tracing_dir()\fR function sets a custom location of the system\(cqs tracing directory mount point\&. Usually, the library auto detects it using the information from the /proc/mounts file\&. Use this API only if the mount point is not standard and cannot be detected by the library\&. The \fItracing_dir\fR argument can be NULL, in that case the custom location is deleted and the library auto detection logic is used\&.
.sp
The \fBtracefs_get_tracing_file()\fR function returns the full path of the file with given \fIname\fR in the trace file system\&. The function works only with files in the tracefs main directory, it is not trace instance aware\&. It is recommended to use \fBtracefs_instance_get_file()\fR and \fBtracefs_instance_get_dir()\fR instead\&. The returned string must be freed with \fBtracefs_put_tracing_file()\fR\&.
.sp
The \fBtracefs_put_tracing_file()\fR function frees trace file name, returned by \fBtracefs_get_tracing_file()\fR\&.
.sp
The \fBtracefs_tracing_dir()\fR function returns the full path to the trace file system\&. In the first function call, the mount point of the tracing file system is located, cached and returned\&. It will mount it, if it is not mounted\&. On any subsequent call the cached path is returned\&. The return string must \fInot\fR be freed\&.
.sp
The \fBtracefs_debug_dir()\fR is similar to \fBtracefs_tracing_dir()\fR except that it will return where the debugfs file system is mounted\&. If it is not mounted it will try to mount it\&. The return string must \fInot\fR be freed\&.
.sp
\fBtracefs_tracing_dir_is_mounted()\fR returns 1 if the tracing directory is already mounted and 0 if it is not\&. If \fImount\fR is true, it will try to mount it if it is not, and returns 0 if it succesfully mounted it and \-1 if it did not\&. If \fIpath\fR is set, it will be assigned to the path where it mounted it\&. \fIpath\fR is internal and should not be freed\&.
.SH "RETURN VALUE"
.sp
The \fBtracefs_set_tracing_dir()\fR function returns 0 on success, \-1 otherwise\&.
.sp
The \fBtracefs_get_tracing_file()\fR function returns a string or NULL in case of an error\&. The returned string must be freed with \fBtracefs_put_tracing_file()\fR\&.
.sp
The \fBtracefs_tracing_dir()\fR function returns a constant string or NULL in case of an error\&. The returned string must \fInot\fR be freed\&.
.sp
The \fBtracefs_debug_dir()\fR function returns a constant string or NULL in case of an error\&. The returned string must \fInot\fR be freed\&.
.sp
The \fBtracefs_tracing_dir_is_mounted()\fR returns 1 if the tracing directory is already mounted, 0 if it is not, and \-1 on error\&.
.SH "EXAMPLE"
.sp
.if n \{\
.RS 4
.\}
.nf
#include
\&.\&.\&.
char *trace_on = tracefs_get_tracing_file("tracing_on");
if (trace_on) {
\&.\&.\&.
tracefs_put_tracing_file(trace_on);
}
\&.\&.\&.
const char *trace_dir = tracefs_tracing_dir();
.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
\fBlibtracefs\fR(3), \fBlibtraceevent\fR(3), \fBtrace\-cmd\fR(1)
.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