2 * Copyright (C) 2011 - Julien Desfossez <julien.desfossez@polymtl.ca>
3 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
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.
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.
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.
20 #include <sys/ioctl.h>
22 #include "kernel-ioctl.h"
23 #include "libkernelctl.h"
26 int kernctl_create_channel(int fd
, struct lttng_channel
*chops
)
28 return ioctl(fd
, KERNEL_CREATE_CHANNEL
, chops
);
31 int kernctl_create_event(int fd
, struct lttng_event
*ev
)
33 return ioctl(fd
, KERNEL_CREATE_EVENT
, ev
);
36 int kernctl_create_session(int fd
)
38 return ioctl(fd
, KERNEL_CREATE_SESSION
);
41 int kernctl_create_stream(int fd
)
43 return ioctl(fd
, KERNEL_CREATE_STREAM
);
46 /* returns the maximum size for sub-buffers. */
47 int kernctl_get_max_subbuf_size(int fd
, unsigned long *len
)
49 return ioctl(fd
, RING_BUFFER_GET_MAX_SUBBUF_SIZE
, len
);
52 /* returns the length to mmap. */
53 int kernctl_get_mmap_len(int fd
, unsigned long *len
)
55 return ioctl(fd
, RING_BUFFER_GET_MMAP_LEN
, len
);
58 /* returns the offset of the subbuffer belonging to the mmap reader. */
59 int kernctl_get_mmap_read_offset(int fd
, unsigned long *off
)
61 return ioctl(fd
, RING_BUFFER_GET_MMAP_READ_OFFSET
, off
);
64 /* Get exclusive read access to the next sub-buffer that can be read. */
65 int kernctl_get_next_subbuf(int fd
)
67 return ioctl(fd
, RING_BUFFER_GET_NEXT_SUBBUF
);
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
)
73 return ioctl(fd
, RING_BUFFER_GET_PADDED_SUBBUF_SIZE
, len
);
76 /* Get exclusive read access to the specified sub-buffer position */
77 int kernctl_get_subbuf(int fd
, unsigned long *len
)
79 return ioctl(fd
, RING_BUFFER_GET_SUBBUF
, len
);
82 /* returns the size of the current sub-buffer, without padding (for mmap). */
83 int kernctl_get_subbuf_size(int fd
, unsigned long *len
)
85 return ioctl(fd
, RING_BUFFER_GET_SUBBUF_SIZE
, len
);
88 /* open the metadata global channel */
89 int kernctl_open_metadata(int fd
, struct lttng_channel
*chops
)
91 return ioctl(fd
, KERNEL_OPEN_METADATA
, chops
);
94 /* Release exclusive sub-buffer access, move consumer forward. */
95 int kernctl_put_next_subbuf(int fd
)
97 return ioctl(fd
, RING_BUFFER_PUT_NEXT_SUBBUF
);
100 /* Release exclusive sub-buffer access */
101 int kernctl_put_subbuf(int fd
)
103 return ioctl(fd
, RING_BUFFER_PUT_SUBBUF
);
106 /* Get a snapshot of the current ring buffer producer and consumer positions */
107 int kernctl_snapshot(int fd
)
109 return ioctl(fd
, RING_BUFFER_SNAPSHOT
);
112 /* Get the consumer position (iteration start) */
113 int kernctl_snapshot_get_consumed(int fd
, unsigned long *pos
)
115 return ioctl(fd
, RING_BUFFER_SNAPSHOT_GET_CONSUMED
, pos
);
118 /* Get the producer position (iteration end) */
119 int kernctl_snapshot_get_produced(int fd
, unsigned long *pos
)
121 return ioctl(fd
, RING_BUFFER_SNAPSHOT_GET_PRODUCED
, pos
);
124 int kernctl_start_session(int fd
)
126 return ioctl(fd
, KERNEL_SESSION_START
);
129 int kernctl_stop_session(int fd
)
131 return ioctl(fd
, KERNEL_SESSION_STOP
);