splice: divorce the splice structure/function definitions from the pipe header
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / include / linux / pipe_fs_i.h
CommitLineData
1da177e4
LT
1#ifndef _LINUX_PIPE_FS_I_H
2#define _LINUX_PIPE_FS_I_H
3
4#define PIPEFS_MAGIC 0x50495045
5
6#define PIPE_BUFFERS (16)
7
1432873a
JA
8#define PIPE_BUF_FLAG_LRU 0x01 /* page is on the LRU */
9#define PIPE_BUF_FLAG_ATOMIC 0x02 /* was atomically mapped */
10#define PIPE_BUF_FLAG_GIFT 0x04 /* page is a gift */
3e7ee3e7 11
1da177e4
LT
12struct pipe_buffer {
13 struct page *page;
14 unsigned int offset, len;
d4c3cca9 15 const struct pipe_buf_operations *ops;
3e7ee3e7 16 unsigned int flags;
1da177e4
LT
17};
18
17374ff1
JA
19struct pipe_inode_info {
20 wait_queue_head_t wait;
21 unsigned int nrbufs, curbuf;
22 struct page *tmp_page;
23 unsigned int readers;
24 unsigned int writers;
25 unsigned int waiting_writers;
26 unsigned int r_counter;
27 unsigned int w_counter;
28 struct fasync_struct *fasync_readers;
29 struct fasync_struct *fasync_writers;
30 struct inode *inode;
31 struct pipe_buffer bufs[PIPE_BUFFERS];
32};
33
f84d7519
JA
34/*
35 * Note on the nesting of these functions:
36 *
37 * ->pin()
38 * ->steal()
39 * ...
40 * ->map()
41 * ...
42 * ->unmap()
43 *
44 * That is, ->map() must be called on a pinned buffer, same goes for ->steal().
45 */
1da177e4
LT
46struct pipe_buf_operations {
47 int can_merge;
f6762b7a
JA
48 void * (*map)(struct pipe_inode_info *, struct pipe_buffer *, int);
49 void (*unmap)(struct pipe_inode_info *, struct pipe_buffer *, void *);
f84d7519 50 int (*pin)(struct pipe_inode_info *, struct pipe_buffer *);
1da177e4 51 void (*release)(struct pipe_inode_info *, struct pipe_buffer *);
5abc97aa 52 int (*steal)(struct pipe_inode_info *, struct pipe_buffer *);
70524490 53 void (*get)(struct pipe_inode_info *, struct pipe_buffer *);
1da177e4
LT
54};
55
1da177e4
LT
56/* Differs from PIPE_BUF in that PIPE_SIZE is the length of the actual
57 memory allocation, whereas PIPE_BUF makes atomicity guarantees. */
58#define PIPE_SIZE PAGE_SIZE
59
1da177e4 60/* Drop the inode semaphore and wait for a pipe event, atomically */
3a326a2c 61void pipe_wait(struct pipe_inode_info *pipe);
1da177e4 62
3a326a2c
IM
63struct pipe_inode_info * alloc_pipe_info(struct inode * inode);
64void free_pipe_info(struct inode * inode);
b92ce558 65void __free_pipe_info(struct pipe_inode_info *);
1da177e4 66
f84d7519 67/* Generic pipe buffer ops functions */
f6762b7a
JA
68void *generic_pipe_buf_map(struct pipe_inode_info *, struct pipe_buffer *, int);
69void generic_pipe_buf_unmap(struct pipe_inode_info *, struct pipe_buffer *, void *);
f84d7519
JA
70void generic_pipe_buf_get(struct pipe_inode_info *, struct pipe_buffer *);
71int generic_pipe_buf_pin(struct pipe_inode_info *, struct pipe_buffer *);
330ab716 72int generic_pipe_buf_steal(struct pipe_inode_info *, struct pipe_buffer *);
f84d7519 73
1da177e4 74#endif