'\" 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_trace_pipe_stream, tracefs_trace_pipe_print, tracefs_trace_pipe_stop \- redirect the stream of trace data to an output or stdout\&.
.SH "SYNOPSIS"
.sp
.nf
\fB#include \fR
ssize_t \fBtracefs_trace_pipe_stream\fR(int \fIfd\fR, struct tracefs_instance *\fIinstance\fR, int \fIflags\fR);
ssize_t \fBtracefs_trace_pipe_print\fR(struct tracefs_instance *\fIinstance\fR, int \fIflags\fR);
void \fBtracefs_trace_pipe_stop\fR(struct tracefs_instance *\fIinstance\fR);
.fi
.SH "DESCRIPTION"
.sp
If NULL is passed as \fIinstance\fR, the top trace instance is used\&.
.sp
The reading of the trace_pipe file can be stopped by calling \fBtracefs_trace_pipe_stop()\fR which could be placed in a signal handler in case the application wants to stop the reading, for example, with the user pressing Ctrl\-C\&.
.sp
The \fBtracefs_trace_pipe_stream()\fR function redirects the stream of trace data to an output file\&. The "splice" system call is used to moves the data without copying between kernel address space and user address space\&. The \fIfd\fR is the file descriptor of the output file and \fIflags\fR is a bit mask of flags to be passed to the open system call of the trace_pipe file (see )\&. If flags contain O_NONBLOCK, then that is also passed to the splice calls that may read the file to the output stream file descriptor\&.
.sp
The \fBtracefs_trace_pipe_print()\fR function is similar to \fBtracefs_trace_pipe_stream()\fR, but the stream of trace data is redirected to stdout\&.
.SH "RETURN VALUE"
.sp
The \fBtracefs_trace_pipe_stream()\fR, and \fBtracefs_trace_pipe_print()\fR functions return the number of bytes transfered if the operation is successful, or \-1 in case of an error\&.
.SH "EXAMPLE"
.sp
.if n \{\
.RS 4
.\}
.nf
#include
#include
#include
#include
#include
#include
void stop(int sig)
{
tracefs_trace_pipe_stop(NULL);
}
int main(int argc, char **argv)
{
mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
const char *filename;
int fd;
int ret;
if (argc < 2) {
fprintf(stderr, "usage: %s output_file\en", argv[0]);
exit(\-1);
}
filename = argv[1];
fd = creat(filename, mode);
if (fd < 0) {
perror(filename);
exit(\-1);
}
signal(SIGINT, stop);
ret = tracefs_trace_pipe_stream(fd, NULL, SPLICE_F_NONBLOCK);
close(fd);
return ret;
}
.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