Cleanup trace ust destroy functions
[lttng-tools.git] / libkernelctl / kernelctl.c
CommitLineData
ee0326c0 1/*
16421f6e
DG
2 * Copyright (C) 2011 - Julien Desfossez <julien.desfossez@polymtl.ca>
3 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
ee0326c0
DG
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
82a3637f
DG
7 * as published by the Free Software Foundation; only version 2
8 * of the License.
ee0326c0
DG
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
16421f6e
DG
19
20#include <sys/ioctl.h>
21
1e307fab
DG
22#include <lttng-kernel-ctl.h>
23
16421f6e 24#include "kernel-ioctl.h"
16421f6e 25
964ccb60 26int kernctl_create_session(int fd)
d65106b1 27{
964ccb60 28 return ioctl(fd, LTTNG_KERNEL_SESSION);
d65106b1
DG
29}
30
964ccb60
MD
31/* open the metadata global channel */
32int kernctl_open_metadata(int fd, struct lttng_channel_attr *chops)
f3ed775e 33{
964ccb60 34 return ioctl(fd, LTTNG_KERNEL_METADATA, chops);
f3ed775e
DG
35}
36
37int kernctl_create_channel(int fd, struct lttng_channel_attr *chops)
16421f6e 38{
9cb98350 39 return ioctl(fd, LTTNG_KERNEL_CHANNEL, chops);
16421f6e
DG
40}
41
964ccb60 42int kernctl_create_stream(int fd)
16421f6e 43{
964ccb60 44 return ioctl(fd, LTTNG_KERNEL_STREAM);
16421f6e
DG
45}
46
964ccb60 47int kernctl_create_event(int fd, struct lttng_kernel_event *ev)
16421f6e 48{
964ccb60 49 return ioctl(fd, LTTNG_KERNEL_EVENT, ev);
16421f6e
DG
50}
51
964ccb60 52int kernctl_add_context(int fd, struct lttng_kernel_context *ctx)
16421f6e 53{
964ccb60 54 return ioctl(fd, LTTNG_KERNEL_CONTEXT, ctx);
16421f6e
DG
55}
56
964ccb60 57
f3ed775e
DG
58/* Enable event, channel and session ioctl */
59int kernctl_enable(int fd)
60{
61 return ioctl(fd, LTTNG_KERNEL_ENABLE);
62}
63
64/* Disable event, channel and session ioctl */
65int kernctl_disable(int fd)
66{
67 return ioctl(fd, LTTNG_KERNEL_DISABLE);
68}
69
964ccb60 70int kernctl_start_session(int fd)
16421f6e 71{
964ccb60
MD
72 return ioctl(fd, LTTNG_KERNEL_SESSION_START);
73}
74
75int kernctl_stop_session(int fd)
76{
77 return ioctl(fd, LTTNG_KERNEL_SESSION_STOP);
16421f6e
DG
78}
79
964ccb60
MD
80
81int kernctl_tracepoint_list(int fd)
82{
83 return ioctl(fd, LTTNG_KERNEL_TRACEPOINT_LIST);
84}
85
86int kernctl_tracer_version(int fd, struct lttng_kernel_tracer_version *v)
87{
88 return ioctl(fd, LTTNG_KERNEL_TRACER_VERSION, v);
89}
90
91int kernctl_wait_quiescent(int fd)
92{
93 return ioctl(fd, LTTNG_KERNEL_WAIT_QUIESCENT);
94}
95
96int kernctl_calibrate(int fd, struct lttng_kernel_calibrate *calibrate)
97{
98 return ioctl(fd, LTTNG_KERNEL_CALIBRATE, calibrate);
99}
100
101
102int kernctl_buffer_flush(int fd)
103{
104 return ioctl(fd, RING_BUFFER_FLUSH);
105}
106
107
108/* Buffer operations */
109
110/* For mmap mode, readable without "get" operation */
111
16421f6e
DG
112/* returns the length to mmap. */
113int kernctl_get_mmap_len(int fd, unsigned long *len)
114{
115 return ioctl(fd, RING_BUFFER_GET_MMAP_LEN, len);
116}
117
964ccb60
MD
118/* returns the maximum size for sub-buffers. */
119int kernctl_get_max_subbuf_size(int fd, unsigned long *len)
120{
121 return ioctl(fd, RING_BUFFER_GET_MAX_SUBBUF_SIZE, len);
122}
123
124/*
125 * For mmap mode, operate on the current packet (between get/put or
126 * get_next/put_next).
127 */
128
16421f6e
DG
129/* returns the offset of the subbuffer belonging to the mmap reader. */
130int kernctl_get_mmap_read_offset(int fd, unsigned long *off)
131{
132 return ioctl(fd, RING_BUFFER_GET_MMAP_READ_OFFSET, off);
133}
134
964ccb60
MD
135/* returns the size of the current sub-buffer, without padding (for mmap). */
136int kernctl_get_subbuf_size(int fd, unsigned long *len)
16421f6e 137{
964ccb60 138 return ioctl(fd, RING_BUFFER_GET_SUBBUF_SIZE, len);
16421f6e
DG
139}
140
141/* returns the size of the current sub-buffer, without padding (for mmap). */
142int kernctl_get_padded_subbuf_size(int fd, unsigned long *len)
143{
144 return ioctl(fd, RING_BUFFER_GET_PADDED_SUBBUF_SIZE, len);
145}
146
964ccb60
MD
147/* Get exclusive read access to the next sub-buffer that can be read. */
148int kernctl_get_next_subbuf(int fd)
16421f6e 149{
964ccb60 150 return ioctl(fd, RING_BUFFER_GET_NEXT_SUBBUF);
16421f6e
DG
151}
152
d4a1283e 153
16421f6e
DG
154/* Release exclusive sub-buffer access, move consumer forward. */
155int kernctl_put_next_subbuf(int fd)
156{
157 return ioctl(fd, RING_BUFFER_PUT_NEXT_SUBBUF);
158}
159
964ccb60 160/* snapshot */
16421f6e
DG
161
162/* Get a snapshot of the current ring buffer producer and consumer positions */
163int kernctl_snapshot(int fd)
164{
165 return ioctl(fd, RING_BUFFER_SNAPSHOT);
166}
167
168/* Get the consumer position (iteration start) */
169int kernctl_snapshot_get_consumed(int fd, unsigned long *pos)
170{
171 return ioctl(fd, RING_BUFFER_SNAPSHOT_GET_CONSUMED, pos);
172}
173
174/* Get the producer position (iteration end) */
175int kernctl_snapshot_get_produced(int fd, unsigned long *pos)
176{
177 return ioctl(fd, RING_BUFFER_SNAPSHOT_GET_PRODUCED, pos);
178}
179
964ccb60
MD
180/* Get exclusive read access to the specified sub-buffer position */
181int kernctl_get_subbuf(int fd, unsigned long *len)
f3ed775e 182{
964ccb60 183 return ioctl(fd, RING_BUFFER_GET_SUBBUF, len);
f3ed775e 184}
d0254c7c 185
964ccb60
MD
186/* Release exclusive sub-buffer access */
187int kernctl_put_subbuf(int fd)
d0254c7c 188{
964ccb60 189 return ioctl(fd, RING_BUFFER_PUT_SUBBUF);
d0254c7c 190}
This page took 0.063118 seconds and 4 git commands to generate.