LIBTRACEFS(3)
π LIBTRACEFS(3) β the libtracefs manual, bestie edition π
okay so you've stumbled into libtracefs(3), the manual for the libtracefs library, and honestly? you're gonna slay this. let's get into it β¨
πΈ NAME πΈ
tracefs_option_enable, tracefs_option_disable, tracefs_option_name β a whole little squad of trace option functions. various. iconic. π
π¦ SYNOPSIS π¦
#include <tracefs.h>
int tracefs_option_enable(struct tracefs_instance *instance, enum tracefs_option_id id);
int tracefs_option_disable(struct tracefs_instance *instance, enum tracefs_option_id id);
const char *tracefs_option_name(enum tracefs_option_id id);
literally just three little functions, no cap. π«Ά
β¨ DESCRIPTION β¨
this set of APIs is your go-to little crew for enabling and disabling ftrace options, and for getting the name of an option. that's the vibe check, that's the whole job. π
the tracefs_option_enable() function enables the option with id in the given instance. and if instance is NULL? it enables the option in the top trace instance instead. cute, right? π
the tracefs_option_disable() function disables the option with id in the given instance. same deal β if instance is NULL, it disables the option in the top trace instance. symmetric queen behavior. π
the tracefs_option_name() function returns a string representing the option with id. and listen β the string must not be freed. i repeat, do not free it. it's not yours, it's not yours to free, leave it alone π
π RETURN VALUE π
tracefs_option_enable() and tracefs_option_disable() return 0 if the state of the option is set successfully, or -1 in case of an error. zero means slay, minus one means π.
tracefs_option_name() returns a string with the option name, or "unknown" in case of an error. and again, bestie, the returned string must not be freed. same rule, same energy. β
π₯ EXAMPLE π₯
#include <tracefs.h>
...
if (tracefs_option_enable(NULL, TRACEFS_OPTION_ANNOTATE)) {
/* Failed to enable annotate option in top trace instance */
}
...
if (tracefs_option_disable(NULL, TRACEFS_OPTION_CONTEXT_INFO)) {
/* Failed to disable context info option in top trace instance */
}
...
char *name = tracefs_option_name(TRACEFS_OPTION_FUNC_STACKTRACE);
if (strcmp(name, "unknown")) {
/* Cannot get the name of the option */
}
see how it's done? enable annotate in the top trace instance, disable context info in the top trace instance, then grab the name of the func stacktrace option and compare it against "unknown". mmhm. ate. π
π FILES π
tracefs.hβ header file to include in order to have access to the library APIs. the little invitation to the party. π-ltracefsβ linker switch to add when building a program that uses the library. yes you need it, no you can't skip it, iykyk. π§
π SEE ALSO π
libtracefs(3), libtraceevent(3), trace-cmd(1)
the whole friend group, honestly. π«Ά
π AUTHOR π
- Steven Rostedt
<rostedt@goodmis.org[1]> - Tzvetomir Stoyanov
<tz.stoyanov@gmail.com[2]>
π REPORTING BUGS π
report bugs to <linux-trace-devel@vger.kernel.org[3]> β they want to hear from you, fr fr. π
πΈ LICENSE πΈ
libtracefs is Free Software licensed under the GNU LGPL 2.1 π
π¦ RESOURCES π¦
https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/
that's the link, go touch grass (the git kind). π±
π COPYING π
Copyright (C) 2020 VMware, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL). π
β NOTES β
rostedt@goodmis.orgmailto:rostedt@goodmis.orgtz.stoyanov@gmail.commailto:tz.stoyanov@gmail.comlinux-trace-devel@vger.kernel.orgmailto:linux-trace-devel@vger.kernel.org
and that's the whole page, bestie!! πΈ this was libtracefs 1.8.4, dated 10/21/2026 β so like, literally write that down. you're welcome, mwah πβ¨
π¦ where this page comes from
- arch rolling: libtracefs 1.8.4-1 Β· GPL-2.0-only AND LGPL-2.1-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms