splice: divorce the splice structure/function definitions from the pipe header
[safe/jmp/linux-2.6] / include / linux / pipe_fs_i.h
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
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 */
11
12 struct pipe_buffer {
13         struct page *page;
14         unsigned int offset, len;
15         const struct pipe_buf_operations *ops;
16         unsigned int flags;
17 };
18
19 struct 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
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  */
46 struct pipe_buf_operations {
47         int can_merge;
48         void * (*map)(struct pipe_inode_info *, struct pipe_buffer *, int);
49         void (*unmap)(struct pipe_inode_info *, struct pipe_buffer *, void *);
50         int (*pin)(struct pipe_inode_info *, struct pipe_buffer *);
51         void (*release)(struct pipe_inode_info *, struct pipe_buffer *);
52         int (*steal)(struct pipe_inode_info *, struct pipe_buffer *);
53         void (*get)(struct pipe_inode_info *, struct pipe_buffer *);
54 };
55
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
60 /* Drop the inode semaphore and wait for a pipe event, atomically */
61 void pipe_wait(struct pipe_inode_info *pipe);
62
63 struct pipe_inode_info * alloc_pipe_info(struct inode * inode);
64 void free_pipe_info(struct inode * inode);
65 void __free_pipe_info(struct pipe_inode_info *);
66
67 /* Generic pipe buffer ops functions */
68 void *generic_pipe_buf_map(struct pipe_inode_info *, struct pipe_buffer *, int);
69 void generic_pipe_buf_unmap(struct pipe_inode_info *, struct pipe_buffer *, void *);
70 void generic_pipe_buf_get(struct pipe_inode_info *, struct pipe_buffer *);
71 int generic_pipe_buf_pin(struct pipe_inode_info *, struct pipe_buffer *);
72 int generic_pipe_buf_steal(struct pipe_inode_info *, struct pipe_buffer *);
73
74 #endif