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