LIBTRACEFS(3)
π LIBTRACEFS(3) β the libtracefs manual, bestie edition β¨
okay so this is the libtracefs manual page, and today we're talking about the binary-writing girlies π (and yes, the manual name is literally libtracefs in case you were wondering π)
β¨ NAME β¨
tracefs_binary_init, tracefs_binary_close, tracefs_binary_write β the trio that opens, closes, and writes binary data into the trace buffer. no cap, that's the whole vibe. π¦
πΈ SYNOPSIS πΈ
#include <tracefs.h>
int tracefs_binary_init(struct tracefs_instance *instance);
int tracefs_binary_write(struct tracefs_instance *instance, void *data, int len);
void tracefs_binary_close(struct tracefs_instance *instance);
π DESCRIPTION π
so this is a little set of functions that write binary data into the trace buffer. if you want the deep lore, go read Documentation/trace/ftrace.rst from the Linux kernel tree β that's where all the writing-from-user-space-into-the-trace-buffer info lives. π
all of these APIs take instance as their first argument. and if you pass NULL as instance? the top trace instance gets used. easy. π
tracefs_binary_init()β initializes the library for writing into the trace buffer of whichever instance you picked. and listen β it is not mandatory to call this before writing data, becausetracefs_binary_write()will call it automatically if the library isn't initialized yet. but callingtracefs_binary_init()in advance will speed up the writing. so likeβ¦ technically optional, but iconically efficient. π₯tracefs_binary_write()β writes a binary blob into the trace buffer of the selected instance.datapoints to the data, and its length islenβ that's what's going into the trace buffer. π«tracefs_binary_close()β closes the resources the library used for writing into the trace buffer of the selected instance. cleanup era, we love to see it. π§Ήβ¨
β RETURN VALUE β
tracefs_binary_init() and tracefs_binary_write() both return 0 if the operation is successful, or -1 if something went wrong. that's it, that's the check. π
π¦ EXAMPLE π¦
#include <tracefs.h>
if (tracefs_binary_init(NULL) < 0) {
/* Failed to initialize the library for writing in the trace buffer of the top trace instance */
}
unsigned int data = 0xdeadbeef;
if (tracefs_binary_write(NULL, &data, sizeof(data)) < 0) {
/* Failed to write in the trace buffer */
}
tracefs_binary_close();
she's writing 0xdeadbeef and closing up shop. main character energy honestly. π
π FILES π
tracefs.hβ the header file you include to get access to the library APIs. manifesting those declarations for you. π-ltracefsβ the linker switch you add when building a program that uses the library. don't forget her, fr fr. π
π SEE ALSO π
libtracefs(3), libtraceevent(3), trace-cmd(1), and Documentation/trace/ftrace.rst from the Linux kernel tree β the whole friend group π«Ά
π AUTHOR π
- Steven Rostedt
<rostedt@goodmis.org[1]> - Tzvetomir Stoyanov
<tz.stoyanov@gmail.com[2]>
π REPORTING BUGS π
found a bug? report it to <linux-trace-devel@vger.kernel.org[3]> β they wanna know, bestie. π
π LICENSE π
libtracefs is Free Software licensed under the GNU LGPL 2.1 π
π₯ RESOURCES π₯
https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/ β go look, it's giving open source excellence β¨
πΈ COPYING πΈ
Copyright (C) 2021 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 version 1.8.4, dated 10/21/2026 β write it down, screenshot it, put it in the group chat, whatever you gotta do. love u, go write some binary data into that trace buffer π
β¨π«Ά
π¦ 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