Fix ring buffer 32/64 bits compat
[lttng-modules.git] / lib / ringbuffer / vfs.h
CommitLineData
886d51a3
MD
1#ifndef _LIB_RING_BUFFER_VFS_H
2#define _LIB_RING_BUFFER_VFS_H
f3bc08c5
MD
3
4/*
886d51a3 5 * lib/ringbuffer/vfs.h
f3bc08c5
MD
6 *
7 * Wait-free ring buffer VFS file operations.
8 *
886d51a3
MD
9 * Copyright (C) 2005-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; only
14 * version 2.1 of the License.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 *
f3bc08c5
MD
25 * Author:
26 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
f3bc08c5
MD
27 */
28
29#include <linux/fs.h>
30#include <linux/poll.h>
31
32/* VFS API */
33
34extern const struct file_operations lib_ring_buffer_file_operations;
35
36/*
37 * Internal file operations.
38 */
39
40int lib_ring_buffer_open(struct inode *inode, struct file *file);
41int lib_ring_buffer_release(struct inode *inode, struct file *file);
42unsigned int lib_ring_buffer_poll(struct file *filp, poll_table *wait);
43ssize_t lib_ring_buffer_splice_read(struct file *in, loff_t *ppos,
44 struct pipe_inode_info *pipe, size_t len,
45 unsigned int flags);
46int lib_ring_buffer_mmap(struct file *filp, struct vm_area_struct *vma);
47
48/* Ring Buffer ioctl() and ioctl numbers */
49long lib_ring_buffer_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
50#ifdef CONFIG_COMPAT
51long lib_ring_buffer_compat_ioctl(struct file *filp, unsigned int cmd,
52 unsigned long arg);
53#endif
54
55/*
56 * Use RING_BUFFER_GET_NEXT_SUBBUF / RING_BUFFER_PUT_NEXT_SUBBUF to read and
57 * consume sub-buffers sequentially.
58 *
59 * Reading sub-buffers without consuming them can be performed with:
60 *
61 * RING_BUFFER_SNAPSHOT
62 * RING_BUFFER_SNAPSHOT_GET_CONSUMED
63 * RING_BUFFER_SNAPSHOT_GET_PRODUCED
64 *
65 * to get the offset range to consume, and then by passing each sub-buffer
66 * offset to RING_BUFFER_GET_SUBBUF, read the sub-buffer, and then release it
67 * with RING_BUFFER_PUT_SUBBUF.
68 *
69 * Note that the "snapshot" API can be used to read the sub-buffer in reverse
70 * order, which is useful for flight recorder snapshots.
71 */
72
73/* Get a snapshot of the current ring buffer producer and consumer positions */
74#define RING_BUFFER_SNAPSHOT _IO(0xF6, 0x00)
216f7feb 75#define RING_BUFFER_COMPAT_SNAPSHOT RING_BUFFER_SNAPSHOT
f3bc08c5
MD
76/* Get the consumer position (iteration start) */
77#define RING_BUFFER_SNAPSHOT_GET_CONSUMED _IOR(0xF6, 0x01, unsigned long)
216f7feb
JD
78#define RING_BUFFER_COMPAT_SNAPSHOT_GET_CONSUMED \
79 _IOR(0xF6, 0x01, compat_ulong_t)
f3bc08c5
MD
80/* Get the producer position (iteration end) */
81#define RING_BUFFER_SNAPSHOT_GET_PRODUCED _IOR(0xF6, 0x02, unsigned long)
216f7feb
JD
82#define RING_BUFFER_COMPAT_SNAPSHOT_GET_PRODUCED \
83 _IOR(0xF6, 0x02, compat_ulong_t)
f3bc08c5
MD
84/* Get exclusive read access to the specified sub-buffer position */
85#define RING_BUFFER_GET_SUBBUF _IOW(0xF6, 0x03, unsigned long)
216f7feb 86#define RING_BUFFER_COMPAT_GET_SUBBUF _IOW(0xF6, 0x03, compat_ulong_t)
f3bc08c5
MD
87/* Release exclusive sub-buffer access */
88#define RING_BUFFER_PUT_SUBBUF _IO(0xF6, 0x04)
216f7feb 89#define RING_BUFFER_COMPAT_PUT_SUBBUF RING_BUFFER_PUT_SUBBUF
f3bc08c5
MD
90
91/* Get exclusive read access to the next sub-buffer that can be read. */
92#define RING_BUFFER_GET_NEXT_SUBBUF _IO(0xF6, 0x05)
216f7feb 93#define RING_BUFFER_COMPAT_GET_NEXT_SUBBUF RING_BUFFER_GET_NEXT_SUBBUF
f3bc08c5
MD
94/* Release exclusive sub-buffer access, move consumer forward. */
95#define RING_BUFFER_PUT_NEXT_SUBBUF _IO(0xF6, 0x06)
216f7feb 96#define RING_BUFFER_COMPAT_PUT_NEXT_SUBBUF RING_BUFFER_PUT_NEXT_SUBBUF
f3bc08c5
MD
97/* returns the size of the current sub-buffer, without padding (for mmap). */
98#define RING_BUFFER_GET_SUBBUF_SIZE _IOR(0xF6, 0x07, unsigned long)
216f7feb 99#define RING_BUFFER_COMPAT_GET_SUBBUF_SIZE _IOR(0xF6, 0x07, compat_ulong_t)
f3bc08c5
MD
100/* returns the size of the current sub-buffer, with padding (for splice). */
101#define RING_BUFFER_GET_PADDED_SUBBUF_SIZE _IOR(0xF6, 0x08, unsigned long)
216f7feb
JD
102#define RING_BUFFER_COMPAT_GET_PADDED_SUBBUF_SIZE \
103 _IOR(0xF6, 0x08, compat_ulong_t)
f3bc08c5
MD
104/* returns the maximum size for sub-buffers. */
105#define RING_BUFFER_GET_MAX_SUBBUF_SIZE _IOR(0xF6, 0x09, unsigned long)
216f7feb 106#define RING_BUFFER_COMPAT_GET_MAX_SUBBUF_SIZE _IOR(0xF6, 0x09, compat_ulong_t)
f3bc08c5
MD
107/* returns the length to mmap. */
108#define RING_BUFFER_GET_MMAP_LEN _IOR(0xF6, 0x0A, unsigned long)
216f7feb 109#define RING_BUFFER_COMPAT_GET_MMAP_LEN _IOR(0xF6, 0x0A, compat_ulong_t)
f3bc08c5
MD
110/* returns the offset of the subbuffer belonging to the mmap reader. */
111#define RING_BUFFER_GET_MMAP_READ_OFFSET _IOR(0xF6, 0x0B, unsigned long)
216f7feb 112#define RING_BUFFER_COMPAT_GET_MMAP_READ_OFFSET _IOR(0xF6, 0x0B, compat_ulong_t)
5c055266
MD
113/* flush the current sub-buffer */
114#define RING_BUFFER_FLUSH _IO(0xF6, 0x0C)
216f7feb 115#define RING_BUFFER_COMPAT_FLUSH RING_BUFFER_FLUSH
f3bc08c5 116
886d51a3 117#endif /* _LIB_RING_BUFFER_VFS_H */
This page took 0.029622 seconds and 4 git commands to generate.