Commit | Line | Data |
---|---|---|
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" | |
24 | #include "lttngerr.h" | |
25 | ||
9cb98350 | 26 | int kernctl_create_channel(int fd, struct lttng_kernel_channel *chops) |
16421f6e | 27 | { |
9cb98350 | 28 | return ioctl(fd, LTTNG_KERNEL_CHANNEL, chops); |
16421f6e DG |
29 | } |
30 | ||
9cb98350 | 31 | int kernctl_create_event(int fd, struct lttng_kernel_event *ev) |
16421f6e | 32 | { |
9cb98350 | 33 | return ioctl(fd, LTTNG_KERNEL_EVENT, ev); |
16421f6e DG |
34 | } |
35 | ||
36 | int kernctl_create_session(int fd) | |
37 | { | |
9cb98350 | 38 | return ioctl(fd, LTTNG_KERNEL_SESSION); |
16421f6e DG |
39 | } |
40 | ||
41 | int kernctl_create_stream(int fd) | |
42 | { | |
9cb98350 | 43 | return ioctl(fd, LTTNG_KERNEL_STREAM); |
16421f6e DG |
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 | ||
d4a1283e | 88 | /* open the metadata global channel */ |
9cb98350 | 89 | int kernctl_open_metadata(int fd, struct lttng_kernel_channel *chops) |
d4a1283e | 90 | { |
9cb98350 | 91 | return ioctl(fd, LTTNG_KERNEL_METADATA, chops); |
d4a1283e JD |
92 | } |
93 | ||
16421f6e DG |
94 | /* Release exclusive sub-buffer access, move consumer forward. */ |
95 | int kernctl_put_next_subbuf(int fd) | |
96 | { | |
97 | return ioctl(fd, RING_BUFFER_PUT_NEXT_SUBBUF); | |
98 | } | |
99 | ||
100 | /* Release exclusive sub-buffer access */ | |
101 | int kernctl_put_subbuf(int fd) | |
102 | { | |
103 | return ioctl(fd, RING_BUFFER_PUT_SUBBUF); | |
104 | } | |
105 | ||
106 | /* Get a snapshot of the current ring buffer producer and consumer positions */ | |
107 | int kernctl_snapshot(int fd) | |
108 | { | |
109 | return ioctl(fd, RING_BUFFER_SNAPSHOT); | |
110 | } | |
111 | ||
112 | /* Get the consumer position (iteration start) */ | |
113 | int kernctl_snapshot_get_consumed(int fd, unsigned long *pos) | |
114 | { | |
115 | return ioctl(fd, RING_BUFFER_SNAPSHOT_GET_CONSUMED, pos); | |
116 | } | |
117 | ||
118 | /* Get the producer position (iteration end) */ | |
119 | int kernctl_snapshot_get_produced(int fd, unsigned long *pos) | |
120 | { | |
121 | return ioctl(fd, RING_BUFFER_SNAPSHOT_GET_PRODUCED, pos); | |
122 | } | |
123 | ||
124 | int kernctl_start_session(int fd) | |
125 | { | |
9cb98350 | 126 | return ioctl(fd, LTTNG_KERNEL_SESSION_START); |
16421f6e DG |
127 | } |
128 | ||
129 | int kernctl_stop_session(int fd) | |
130 | { | |
9cb98350 | 131 | return ioctl(fd, LTTNG_KERNEL_SESSION_STOP); |
16421f6e DG |
132 | } |
133 |