Add disable kernel channel support
[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
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
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
f3ed775e
DG
25int kernctl_buffer_flush(int fd)
26{
27 return ioctl(fd, RING_BUFFER_FLUSH);
28}
29
30int kernctl_create_channel(int fd, struct lttng_channel_attr *chops)
16421f6e 31{
9cb98350 32 return ioctl(fd, LTTNG_KERNEL_CHANNEL, chops);
16421f6e
DG
33}
34
9cb98350 35int kernctl_create_event(int fd, struct lttng_kernel_event *ev)
16421f6e 36{
9cb98350 37 return ioctl(fd, LTTNG_KERNEL_EVENT, ev);
16421f6e
DG
38}
39
40int kernctl_create_session(int fd)
41{
9cb98350 42 return ioctl(fd, LTTNG_KERNEL_SESSION);
16421f6e
DG
43}
44
45int kernctl_create_stream(int fd)
46{
9cb98350 47 return ioctl(fd, LTTNG_KERNEL_STREAM);
16421f6e
DG
48}
49
f3ed775e
DG
50/* Enable event, channel and session ioctl */
51int kernctl_enable(int fd)
52{
53 return ioctl(fd, LTTNG_KERNEL_ENABLE);
54}
55
56/* Disable event, channel and session ioctl */
57int kernctl_disable(int fd)
58{
59 return ioctl(fd, LTTNG_KERNEL_DISABLE);
60}
61
16421f6e
DG
62/* returns the maximum size for sub-buffers. */
63int kernctl_get_max_subbuf_size(int fd, unsigned long *len)
64{
65 return ioctl(fd, RING_BUFFER_GET_MAX_SUBBUF_SIZE, len);
66}
67
68/* returns the length to mmap. */
69int kernctl_get_mmap_len(int fd, unsigned long *len)
70{
71 return ioctl(fd, RING_BUFFER_GET_MMAP_LEN, len);
72}
73
74/* returns the offset of the subbuffer belonging to the mmap reader. */
75int kernctl_get_mmap_read_offset(int fd, unsigned long *off)
76{
77 return ioctl(fd, RING_BUFFER_GET_MMAP_READ_OFFSET, off);
78}
79
80/* Get exclusive read access to the next sub-buffer that can be read. */
81int kernctl_get_next_subbuf(int fd)
82{
83 return ioctl(fd, RING_BUFFER_GET_NEXT_SUBBUF);
84}
85
86/* returns the size of the current sub-buffer, without padding (for mmap). */
87int kernctl_get_padded_subbuf_size(int fd, unsigned long *len)
88{
89 return ioctl(fd, RING_BUFFER_GET_PADDED_SUBBUF_SIZE, len);
90}
91
92/* Get exclusive read access to the specified sub-buffer position */
93int kernctl_get_subbuf(int fd, unsigned long *len)
94{
95 return ioctl(fd, RING_BUFFER_GET_SUBBUF, len);
96}
97
98/* returns the size of the current sub-buffer, without padding (for mmap). */
99int kernctl_get_subbuf_size(int fd, unsigned long *len)
100{
101 return ioctl(fd, RING_BUFFER_GET_SUBBUF_SIZE, len);
102}
103
d4a1283e 104/* open the metadata global channel */
f3ed775e 105int kernctl_open_metadata(int fd, struct lttng_channel_attr *chops)
d4a1283e 106{
9cb98350 107 return ioctl(fd, LTTNG_KERNEL_METADATA, chops);
d4a1283e
JD
108}
109
16421f6e
DG
110/* Release exclusive sub-buffer access, move consumer forward. */
111int kernctl_put_next_subbuf(int fd)
112{
113 return ioctl(fd, RING_BUFFER_PUT_NEXT_SUBBUF);
114}
115
116/* Release exclusive sub-buffer access */
117int kernctl_put_subbuf(int fd)
118{
119 return ioctl(fd, RING_BUFFER_PUT_SUBBUF);
120}
121
122/* Get a snapshot of the current ring buffer producer and consumer positions */
123int kernctl_snapshot(int fd)
124{
125 return ioctl(fd, RING_BUFFER_SNAPSHOT);
126}
127
128/* Get the consumer position (iteration start) */
129int kernctl_snapshot_get_consumed(int fd, unsigned long *pos)
130{
131 return ioctl(fd, RING_BUFFER_SNAPSHOT_GET_CONSUMED, pos);
132}
133
134/* Get the producer position (iteration end) */
135int kernctl_snapshot_get_produced(int fd, unsigned long *pos)
136{
137 return ioctl(fd, RING_BUFFER_SNAPSHOT_GET_PRODUCED, pos);
138}
139
140int kernctl_start_session(int fd)
141{
9cb98350 142 return ioctl(fd, LTTNG_KERNEL_SESSION_START);
16421f6e
DG
143}
144
145int kernctl_stop_session(int fd)
146{
9cb98350 147 return ioctl(fd, LTTNG_KERNEL_SESSION_STOP);
16421f6e
DG
148}
149
8d609afd
JD
150int kernctl_tracepoint_list(int fd)
151{
152 return ioctl(fd, LTTNG_KERNEL_TRACEPOINT_LIST);
153}
154
155int kernctl_tracer_version(int fd, struct lttng_kernel_tracer_version *v)
156{
157 return ioctl(fd, LTTNG_KERNEL_TRACER_VERSION, v);
158}
f3ed775e
DG
159
160int kernctl_wait_quiescent(int fd)
161{
162 return ioctl(fd, LTTNG_KERNEL_WAIT_QUIESCENT);
163}
This page took 0.043722 seconds and 4 git commands to generate.