Rename liblttsessiondcomm to liblttng-sessiond-comm, install it.
[lttng-tools.git] / libkernelctl / libkernelctl.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
22#include "kernel-ioctl.h"
23#include "libkernelctl.h"
16421f6e 24
964ccb60 25int kernctl_create_session(int fd)
d65106b1 26{
964ccb60 27 return ioctl(fd, LTTNG_KERNEL_SESSION);
d65106b1
DG
28}
29
964ccb60
MD
30/* open the metadata global channel */
31int kernctl_open_metadata(int fd, struct lttng_channel_attr *chops)
f3ed775e 32{
964ccb60 33 return ioctl(fd, LTTNG_KERNEL_METADATA, chops);
f3ed775e
DG
34}
35
36int kernctl_create_channel(int fd, struct lttng_channel_attr *chops)
16421f6e 37{
9cb98350 38 return ioctl(fd, LTTNG_KERNEL_CHANNEL, chops);
16421f6e
DG
39}
40
964ccb60 41int kernctl_create_stream(int fd)
16421f6e 42{
964ccb60 43 return ioctl(fd, LTTNG_KERNEL_STREAM);
16421f6e
DG
44}
45
964ccb60 46int kernctl_create_event(int fd, struct lttng_kernel_event *ev)
16421f6e 47{
964ccb60 48 return ioctl(fd, LTTNG_KERNEL_EVENT, ev);
16421f6e
DG
49}
50
964ccb60 51int kernctl_add_context(int fd, struct lttng_kernel_context *ctx)
16421f6e 52{
964ccb60 53 return ioctl(fd, LTTNG_KERNEL_CONTEXT, ctx);
16421f6e
DG
54}
55
964ccb60 56
f3ed775e
DG
57/* Enable event, channel and session ioctl */
58int kernctl_enable(int fd)
59{
60 return ioctl(fd, LTTNG_KERNEL_ENABLE);
61}
62
63/* Disable event, channel and session ioctl */
64int kernctl_disable(int fd)
65{
66 return ioctl(fd, LTTNG_KERNEL_DISABLE);
67}
68
964ccb60 69int kernctl_start_session(int fd)
16421f6e 70{
964ccb60
MD
71 return ioctl(fd, LTTNG_KERNEL_SESSION_START);
72}
73
74int kernctl_stop_session(int fd)
75{
76 return ioctl(fd, LTTNG_KERNEL_SESSION_STOP);
16421f6e
DG
77}
78
964ccb60
MD
79
80int kernctl_tracepoint_list(int fd)
81{
82 return ioctl(fd, LTTNG_KERNEL_TRACEPOINT_LIST);
83}
84
85int kernctl_tracer_version(int fd, struct lttng_kernel_tracer_version *v)
86{
87 return ioctl(fd, LTTNG_KERNEL_TRACER_VERSION, v);
88}
89
90int kernctl_wait_quiescent(int fd)
91{
92 return ioctl(fd, LTTNG_KERNEL_WAIT_QUIESCENT);
93}
94
95int kernctl_calibrate(int fd, struct lttng_kernel_calibrate *calibrate)
96{
97 return ioctl(fd, LTTNG_KERNEL_CALIBRATE, calibrate);
98}
99
100
101int kernctl_buffer_flush(int fd)
102{
103 return ioctl(fd, RING_BUFFER_FLUSH);
104}
105
106
107/* Buffer operations */
108
109/* For mmap mode, readable without "get" operation */
110
16421f6e
DG
111/* returns the length to mmap. */
112int kernctl_get_mmap_len(int fd, unsigned long *len)
113{
114 return ioctl(fd, RING_BUFFER_GET_MMAP_LEN, len);
115}
116
964ccb60
MD
117/* returns the maximum size for sub-buffers. */
118int kernctl_get_max_subbuf_size(int fd, unsigned long *len)
119{
120 return ioctl(fd, RING_BUFFER_GET_MAX_SUBBUF_SIZE, len);
121}
122
123/*
124 * For mmap mode, operate on the current packet (between get/put or
125 * get_next/put_next).
126 */
127
16421f6e
DG
128/* returns the offset of the subbuffer belonging to the mmap reader. */
129int kernctl_get_mmap_read_offset(int fd, unsigned long *off)
130{
131 return ioctl(fd, RING_BUFFER_GET_MMAP_READ_OFFSET, off);
132}
133
964ccb60
MD
134/* returns the size of the current sub-buffer, without padding (for mmap). */
135int kernctl_get_subbuf_size(int fd, unsigned long *len)
16421f6e 136{
964ccb60 137 return ioctl(fd, RING_BUFFER_GET_SUBBUF_SIZE, len);
16421f6e
DG
138}
139
140/* returns the size of the current sub-buffer, without padding (for mmap). */
141int kernctl_get_padded_subbuf_size(int fd, unsigned long *len)
142{
143 return ioctl(fd, RING_BUFFER_GET_PADDED_SUBBUF_SIZE, len);
144}
145
964ccb60
MD
146/* Get exclusive read access to the next sub-buffer that can be read. */
147int kernctl_get_next_subbuf(int fd)
16421f6e 148{
964ccb60 149 return ioctl(fd, RING_BUFFER_GET_NEXT_SUBBUF);
16421f6e
DG
150}
151
d4a1283e 152
16421f6e
DG
153/* Release exclusive sub-buffer access, move consumer forward. */
154int kernctl_put_next_subbuf(int fd)
155{
156 return ioctl(fd, RING_BUFFER_PUT_NEXT_SUBBUF);
157}
158
964ccb60 159/* snapshot */
16421f6e
DG
160
161/* Get a snapshot of the current ring buffer producer and consumer positions */
162int kernctl_snapshot(int fd)
163{
164 return ioctl(fd, RING_BUFFER_SNAPSHOT);
165}
166
167/* Get the consumer position (iteration start) */
168int kernctl_snapshot_get_consumed(int fd, unsigned long *pos)
169{
170 return ioctl(fd, RING_BUFFER_SNAPSHOT_GET_CONSUMED, pos);
171}
172
173/* Get the producer position (iteration end) */
174int kernctl_snapshot_get_produced(int fd, unsigned long *pos)
175{
176 return ioctl(fd, RING_BUFFER_SNAPSHOT_GET_PRODUCED, pos);
177}
178
964ccb60
MD
179/* Get exclusive read access to the specified sub-buffer position */
180int kernctl_get_subbuf(int fd, unsigned long *len)
f3ed775e 181{
964ccb60 182 return ioctl(fd, RING_BUFFER_GET_SUBBUF, len);
f3ed775e 183}
d0254c7c 184
964ccb60
MD
185/* Release exclusive sub-buffer access */
186int kernctl_put_subbuf(int fd)
d0254c7c 187{
964ccb60 188 return ioctl(fd, RING_BUFFER_PUT_SUBBUF);
d0254c7c 189}
This page took 0.034246 seconds and 5 git commands to generate.