LIBTRACEFS(3)
π LIBTRACEFS(3) β the tracefs error log trilogy π
okay so bestie, welcome to the libtracefs manual page, section 3 of your fave library docs π«Ά this one's all about the tracefs error log and the three little functions that let you peek at it and wipe it clean β¨
πΈ NAME πΈ
tracefs_error_last, tracefs_error_all, tracefs_error_clear β the trio of functions that read and clear the tracefs error log, periodt π
π SYNOPSIS π
like, here's the vibe in code form:
#include <tracefs.h>
char *tracefs_error_last(struct tracefs_instance *instance);
char *tracefs_error_all(struct tracefs_instance *instance);
int tracefs_error_clear(struct tracefs_instance *instance);
π¦ DESCRIPTION π¦
so tracefs_error_last() hands you back the last error message sitting in the tracefs error log π ngl, a bunch of actions that need proper syntax written into the tracefs file system can produce error messages in that log β messy, ik β and this function shows you the most recent one. main character of the error log, honestly π
then there's tracefs_error_all(), which returns all the messages saved in the error log ποΈ but bestie, heads up β this may not be every message that was ever produced, because the kernel only keeps a limited amount of messages and older ones may get discarded by the kernel π so it's giving "what's still in the group chat, not the whole history."
and tracefs_error_clear()? yeah, that one just clears the error log. poof, gone, clean slate β¨π§Ό
β RETURN VALUE β
both tracefs_error_last() and tracefs_error_all() will return an allocated string when an error exists in the log β otherwise you get NULL, no cap π and if an error occurs, errno will be set; but if there are no error messages to display, then errno is not touched. leave her alone fr π
tracefs_error_clear() returns 0 on success or -1 on error. simple as that π
π₯ EXAMPLE π₯
here's the whole example, verbatim, because we do not play with code around here:
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <tracefs.h>
int main (int argc, char **argv, char **env)
{
struct tracefs_dynevent *kevent;
char *system = NULL;
char *kprobe;
char *format;
char *addr;
int arg = 1;
int ret;
if (argc < 4) {
printf("usage: %s [system] kprobe addr fmt\n", argv[0]);
exit(-1);
}
if (argc > 5)
system = argv[arg++];
kprobe = argv[arg++];
addr = argv[arg++];
format = argv[arg++];
tracefs_error_clear(NULL);
kevent = tracefs_dynevent_get(TRACEFS_DYNEVENT_KPROBE, system, kprobe);
if (kevent) {
tracefs_dynevent_destroy(kevent, true);
tracefs_dynevent_free(kevent);
}
ret = tracefs_kprobe_raw(system, kprobe, addr, format);
if (ret < 0) {
char *err;
perror("Failed creating kprobe");
errno = 0;
err = tracefs_error_last(NULL);
if (err)
fprintf(stderr, "%s\n", err);
else if (errno)
perror("Failed reading error log");
free(err);
}
exit(ret);
}
π FILES π
tracefs.hβ the header file you include so you can have access to the library APIs π«Ά-ltracefsβ the linker switch you add when building a program that uses the library π§
π SEE ALSO π
libtracefs(3), libtraceevent(3), trace-cmd(1) β go read those too, iykyk πβ¨
π 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 wanna hear from you fr π¬
π§ LICENSE π§
libtracefs is Free Software licensed under the GNU LGPL 2.1 βοΈ slay
π RESOURCES π
https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/
π 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
aaaand that's the whole page bestie π this was libtracefs 1.8.4, dated 10/21/2026, section 3 of the manual β go forth and debug your tracefs errors like the icon you are πβ¨π
π¦ 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