'\" t .\" Title: libtracefs .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 10/08/2022 .\" Manual: libtracefs Manual .\" Source: libtracefs 1.5.0 .\" Language: English .\" .TH "LIBTRACEFS" "3" "10/08/2022" "libtracefs 1\&.5\&.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_binary_init, tracefs_binary_close, tracefs_binary_write \- Open, close and write binary data in the trace buffer\&. .SH "SYNOPSIS" .sp .nf \fB#include \fR int \fBtracefs_binary_init\fR(struct tracefs_instance *\fIinstance\fR); int \fBtracefs_binary_write\fR(struct tracefs_instance *\fIinstance\fR, void *\fIdata\fR, int \fIlen\fR); void \fBtracefs_binary_close\fR(struct tracefs_instance *\fIinstance\fR); .fi .SH "DESCRIPTION" .sp Set of functions to write binary data in the trace buffer\&. See Documentation/trace/ftrace\&.rst from the Linux kernel tree for more information about writing data from user space in the trace buffer\&. All these APIs have \fIinstance\fR as a first argument\&. If NULL is passed as \fIinstance\fR, the top trace instance is used\&. .sp The \fBtracefs_binary_init()\fR function initializes the library for writing into the trace buffer of the selected \fIinstance\fR\&. It is not mandatory to call this API before writing data, the \fBtracefs_binary_write()\fR will call it automatically, if the library is not yet initialized\&. But calling \fBtracefs_binary_init()\fR in advance will speed up the writing\&. .sp The \fBtracefs_binary_write()\fR function writes a binary data in the trace buffer of the selected \fIinstance\fR\&. The \fIdata\fR points to the data with length \fIlen\fR, that is going to be written in the trace buffer\&. .sp The \fBtracefs_binary_close()\fR function closes the resources, used by the library for writing in the trace buffer of the selected instance\&. .SH "RETURN VALUE" .sp The \fBtracefs_binary_init()\fR, and \fBtracefs_binary_write()\fR functions return 0 if the operation is successful, or \-1 in case of an error\&. .SH "EXAMPLE" .sp .if n \{\ .RS 4 .\} .nf #include 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(); .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), Documentation/trace/ftrace\&.rst from the Linux kernel tree .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) 2021 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