e99e777c3ab0b25221e421db9aaca96cc8508cbc
[lttng-tools.git] / libkernelctl / libkernelctl.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
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 */
19
20 #include <sys/ioctl.h>
21
22 #include "kernel-ioctl.h"
23 #include "libkernelctl.h"
24 #include "lttngerr.h"
25
26 int kernctl_create_channel(int fd, struct lttng_channel *chops)
27 {
28 return ioctl(fd, KERNEL_IO_CREATE_CHANNEL, chops);
29 }
30
31 int kernctl_create_event(int fd, struct lttng_event *ev)
32 {
33 return ioctl(fd, KERNEL_IO_CREATE_EVENT, ev);
34 }
35
36 int kernctl_create_session(int fd)
37 {
38 return ioctl(fd, KERNEL_IO_CREATE_SESSION);
39 }
40
41 int kernctl_create_stream(int fd)
42 {
43 return ioctl(fd, KERNEL_IO_CREATE_STREAM);
44 }
45
46 /* returns the maximum size for sub-buffers. */
47 int kernctl_get_max_subbuf_size(int fd, unsigned long *len)
48 {
49 return ioctl(fd, RING_BUFFER_GET_MAX_SUBBUF_SIZE, len);
50 }
51
52 /* returns the length to mmap. */
53 int kernctl_get_mmap_len(int fd, unsigned long *len)
54 {
55 return ioctl(fd, RING_BUFFER_GET_MMAP_LEN, len);
56 }
57
58 /* returns the offset of the subbuffer belonging to the mmap reader. */
59 int kernctl_get_mmap_read_offset(int fd, unsigned long *off)
60 {
61 return ioctl(fd, RING_BUFFER_GET_MMAP_READ_OFFSET, off);
62 }
63
64 /* Get exclusive read access to the next sub-buffer that can be read. */
65 int kernctl_get_next_subbuf(int fd)
66 {
67 return ioctl(fd, RING_BUFFER_GET_NEXT_SUBBUF);
68 }
69
70 /* returns the size of the current sub-buffer, without padding (for mmap). */
71 int kernctl_get_padded_subbuf_size(int fd, unsigned long *len)
72 {
73 return ioctl(fd, RING_BUFFER_GET_PADDED_SUBBUF_SIZE, len);
74 }
75
76 /* Get exclusive read access to the specified sub-buffer position */
77 int kernctl_get_subbuf(int fd, unsigned long *len)
78 {
79 return ioctl(fd, RING_BUFFER_GET_SUBBUF, len);
80 }
81
82 /* returns the size of the current sub-buffer, without padding (for mmap). */
83 int kernctl_get_subbuf_size(int fd, unsigned long *len)
84 {
85 return ioctl(fd, RING_BUFFER_GET_SUBBUF_SIZE, len);
86 }
87
88 /* Release exclusive sub-buffer access, move consumer forward. */
89 int kernctl_put_next_subbuf(int fd)
90 {
91 return ioctl(fd, RING_BUFFER_PUT_NEXT_SUBBUF);
92 }
93
94 /* Release exclusive sub-buffer access */
95 int kernctl_put_subbuf(int fd)
96 {
97 return ioctl(fd, RING_BUFFER_PUT_SUBBUF);
98 }
99
100 /* Get a snapshot of the current ring buffer producer and consumer positions */
101 int kernctl_snapshot(int fd)
102 {
103 return ioctl(fd, RING_BUFFER_SNAPSHOT);
104 }
105
106 /* Get the consumer position (iteration start) */
107 int kernctl_snapshot_get_consumed(int fd, unsigned long *pos)
108 {
109 return ioctl(fd, RING_BUFFER_SNAPSHOT_GET_CONSUMED, pos);
110 }
111
112 /* Get the producer position (iteration end) */
113 int kernctl_snapshot_get_produced(int fd, unsigned long *pos)
114 {
115 return ioctl(fd, RING_BUFFER_SNAPSHOT_GET_PRODUCED, pos);
116 }
117
118 int kernctl_start_session(int fd)
119 {
120 return ioctl(fd, KERNEL_IO_SESSION_START);
121 }
122
123 int kernctl_stop_session(int fd)
124 {
125 return ioctl(fd, KERNEL_IO_SESSION_STOP);
126 }
127
This page took 0.043736 seconds and 3 git commands to generate.