License header fixes
[lttng-tools.git] / src / common / kernel-ctl / kernel-ctl.c
CommitLineData
ee0326c0 1/*
16421f6e
DG
2 * Copyright (C) 2011 - Julien Desfossez <julien.desfossez@polymtl.ca>
3 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
ee0326c0 4 *
d14d33bf
AM
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.
ee0326c0
DG
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 *
d14d33bf
AM
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.
ee0326c0 17 */
16421f6e
DG
18
19#include <sys/ioctl.h>
20
10a8a223 21#include "kernel-ctl.h"
16421f6e 22#include "kernel-ioctl.h"
16421f6e 23
964ccb60 24int kernctl_create_session(int fd)
d65106b1 25{
964ccb60 26 return ioctl(fd, LTTNG_KERNEL_SESSION);
d65106b1
DG
27}
28
964ccb60
MD
29/* open the metadata global channel */
30int kernctl_open_metadata(int fd, struct lttng_channel_attr *chops)
f3ed775e 31{
964ccb60 32 return ioctl(fd, LTTNG_KERNEL_METADATA, chops);
f3ed775e
DG
33}
34
35int kernctl_create_channel(int fd, struct lttng_channel_attr *chops)
16421f6e 36{
9cb98350 37 return ioctl(fd, LTTNG_KERNEL_CHANNEL, chops);
16421f6e
DG
38}
39
964ccb60 40int kernctl_create_stream(int fd)
16421f6e 41{
964ccb60 42 return ioctl(fd, LTTNG_KERNEL_STREAM);
16421f6e
DG
43}
44
964ccb60 45int kernctl_create_event(int fd, struct lttng_kernel_event *ev)
16421f6e 46{
964ccb60 47 return ioctl(fd, LTTNG_KERNEL_EVENT, ev);
16421f6e
DG
48}
49
964ccb60 50int kernctl_add_context(int fd, struct lttng_kernel_context *ctx)
16421f6e 51{
964ccb60 52 return ioctl(fd, LTTNG_KERNEL_CONTEXT, ctx);
16421f6e
DG
53}
54
964ccb60 55
f3ed775e
DG
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
964ccb60 68int kernctl_start_session(int fd)
16421f6e 69{
964ccb60
MD
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);
16421f6e
DG
76}
77
964ccb60
MD
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
16421f6e
DG
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
964ccb60
MD
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
16421f6e
DG
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
964ccb60
MD
133/* returns the size of the current sub-buffer, without padding (for mmap). */
134int kernctl_get_subbuf_size(int fd, unsigned long *len)
16421f6e 135{
964ccb60 136 return ioctl(fd, RING_BUFFER_GET_SUBBUF_SIZE, len);
16421f6e
DG
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
964ccb60
MD
145/* Get exclusive read access to the next sub-buffer that can be read. */
146int kernctl_get_next_subbuf(int fd)
16421f6e 147{
964ccb60 148 return ioctl(fd, RING_BUFFER_GET_NEXT_SUBBUF);
16421f6e
DG
149}
150
d4a1283e 151
16421f6e
DG
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
964ccb60 158/* snapshot */
16421f6e
DG
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
964ccb60
MD
178/* Get exclusive read access to the specified sub-buffer position */
179int kernctl_get_subbuf(int fd, unsigned long *len)
f3ed775e 180{
964ccb60 181 return ioctl(fd, RING_BUFFER_GET_SUBBUF, len);
f3ed775e 182}
d0254c7c 183
964ccb60
MD
184/* Release exclusive sub-buffer access */
185int kernctl_put_subbuf(int fd)
d0254c7c 186{
964ccb60 187 return ioctl(fd, RING_BUFFER_PUT_SUBBUF);
d0254c7c 188}
This page took 0.037194 seconds and 4 git commands to generate.