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 ⭐

  1. rostedt@goodmis.org mailto:rostedt@goodmis.org
  2. tz.stoyanov@gmail.com mailto:tz.stoyanov@gmail.com
  3. linux-trace-devel@vger.kernel.org mailto: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