kernel-ctl: cygwin compatibility compile fix
[lttng-tools.git] / src / common / kernel-ctl / kernel-ctl.c
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 #define __USE_LINUX_IOCTL_DEFS
20 #include <sys/ioctl.h>
21
22 #include "kernel-ctl.h"
23 #include "kernel-ioctl.h"
24
25 int kernctl_create_session(int fd)
26 {
27 return ioctl(fd, LTTNG_KERNEL_SESSION);
28 }
29
30 /* open the metadata global channel */
31 int kernctl_open_metadata(int fd, struct lttng_channel_attr *chops)
32 {
33 return ioctl(fd, LTTNG_KERNEL_METADATA, chops);
34 }
35
36 int kernctl_create_channel(int fd, struct lttng_channel_attr *chops)
37 {
38 return ioctl(fd, LTTNG_KERNEL_CHANNEL, chops);
39 }
40
41 int kernctl_create_stream(int fd)
42 {
43 return ioctl(fd, LTTNG_KERNEL_STREAM);
44 }
45
46 int kernctl_create_event(int fd, struct lttng_kernel_event *ev)
47 {
48 return ioctl(fd, LTTNG_KERNEL_EVENT, ev);
49 }
50
51 int kernctl_add_context(int fd, struct lttng_kernel_context *ctx)
52 {
53 return ioctl(fd, LTTNG_KERNEL_CONTEXT, ctx);
54 }
55
56
57 /* Enable event, channel and session ioctl */
58 int kernctl_enable(int fd)
59 {
60 return ioctl(fd, LTTNG_KERNEL_ENABLE);
61 }
62
63 /* Disable event, channel and session ioctl */
64 int kernctl_disable(int fd)
65 {
66 return ioctl(fd, LTTNG_KERNEL_DISABLE);
67 }
68
69 int kernctl_start_session(int fd)
70 {
71 return ioctl(fd, LTTNG_KERNEL_SESSION_START);
72 }
73
74 int kernctl_stop_session(int fd)
75 {
76 return ioctl(fd, LTTNG_KERNEL_SESSION_STOP);
77 }
78
79
80 int kernctl_tracepoint_list(int fd)
81 {
82 return ioctl(fd, LTTNG_KERNEL_TRACEPOINT_LIST);
83 }
84
85 int kernctl_tracer_version(int fd, struct lttng_kernel_tracer_version *v)
86 {
87 return ioctl(fd, LTTNG_KERNEL_TRACER_VERSION, v);
88 }
89
90 int kernctl_wait_quiescent(int fd)
91 {
92 return ioctl(fd, LTTNG_KERNEL_WAIT_QUIESCENT);
93 }
94
95 int kernctl_calibrate(int fd, struct lttng_kernel_calibrate *calibrate)
96 {
97 return ioctl(fd, LTTNG_KERNEL_CALIBRATE, calibrate);
98 }
99
100
101 int 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
111 /* returns the length to mmap. */
112 int kernctl_get_mmap_len(int fd, unsigned long *len)
113 {
114 return ioctl(fd, RING_BUFFER_GET_MMAP_LEN, len);
115 }
116
117 /* returns the maximum size for sub-buffers. */
118 int 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
128 /* returns the offset of the subbuffer belonging to the mmap reader. */
129 int kernctl_get_mmap_read_offset(int fd, unsigned long *off)
130 {
131 return ioctl(fd, RING_BUFFER_GET_MMAP_READ_OFFSET, off);
132 }
133
134 /* returns the size of the current sub-buffer, without padding (for mmap). */
135 int kernctl_get_subbuf_size(int fd, unsigned long *len)
136 {
137 return ioctl(fd, RING_BUFFER_GET_SUBBUF_SIZE, len);
138 }
139
140 /* returns the size of the current sub-buffer, without padding (for mmap). */
141 int kernctl_get_padded_subbuf_size(int fd, unsigned long *len)
142 {
143 return ioctl(fd, RING_BUFFER_GET_PADDED_SUBBUF_SIZE, len);
144 }
145
146 /* Get exclusive read access to the next sub-buffer that can be read. */
147 int kernctl_get_next_subbuf(int fd)
148 {
149 return ioctl(fd, RING_BUFFER_GET_NEXT_SUBBUF);
150 }
151
152
153 /* Release exclusive sub-buffer access, move consumer forward. */
154 int kernctl_put_next_subbuf(int fd)
155 {
156 return ioctl(fd, RING_BUFFER_PUT_NEXT_SUBBUF);
157 }
158
159 /* snapshot */
160
161 /* Get a snapshot of the current ring buffer producer and consumer positions */
162 int kernctl_snapshot(int fd)
163 {
164 return ioctl(fd, RING_BUFFER_SNAPSHOT);
165 }
166
167 /* Get the consumer position (iteration start) */
168 int 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) */
174 int kernctl_snapshot_get_produced(int fd, unsigned long *pos)
175 {
176 return ioctl(fd, RING_BUFFER_SNAPSHOT_GET_PRODUCED, pos);
177 }
178
179 /* Get exclusive read access to the specified sub-buffer position */
180 int kernctl_get_subbuf(int fd, unsigned long *len)
181 {
182 return ioctl(fd, RING_BUFFER_GET_SUBBUF, len);
183 }
184
185 /* Release exclusive sub-buffer access */
186 int kernctl_put_subbuf(int fd)
187 {
188 return ioctl(fd, RING_BUFFER_PUT_SUBBUF);
189 }
This page took 0.034957 seconds and 6 git commands to generate.