Commit | Line | Data |
---|---|---|
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 |
12 | struct pipe_buffer { |
13 | struct page *page; | |
14 | unsigned int offset, len; | |
15 | struct pipe_buf_operations *ops; | |
3e7ee3e7 | 16 | unsigned int flags; |
1da177e4 LT |
17 | }; |
18 | ||
f84d7519 JA |
19 | /* |
20 | * Note on the nesting of these functions: | |
21 | * | |
22 | * ->pin() | |
23 | * ->steal() | |
24 | * ... | |
25 | * ->map() | |
26 | * ... | |
27 | * ->unmap() | |
28 | * | |
29 | * That is, ->map() must be called on a pinned buffer, same goes for ->steal(). | |
30 | */ | |
1da177e4 LT |
31 | struct pipe_buf_operations { |
32 | int can_merge; | |
f6762b7a JA |
33 | void * (*map)(struct pipe_inode_info *, struct pipe_buffer *, int); |
34 | void (*unmap)(struct pipe_inode_info *, struct pipe_buffer *, void *); | |
f84d7519 | 35 | int (*pin)(struct pipe_inode_info *, struct pipe_buffer *); |
1da177e4 | 36 | void (*release)(struct pipe_inode_info *, struct pipe_buffer *); |
5abc97aa | 37 | int (*steal)(struct pipe_inode_info *, struct pipe_buffer *); |
70524490 | 38 | void (*get)(struct pipe_inode_info *, struct pipe_buffer *); |
1da177e4 LT |
39 | }; |
40 | ||
41 | struct pipe_inode_info { | |
42 | wait_queue_head_t wait; | |
43 | unsigned int nrbufs, curbuf; | |
44 | struct pipe_buffer bufs[PIPE_BUFFERS]; | |
45 | struct page *tmp_page; | |
46 | unsigned int start; | |
47 | unsigned int readers; | |
48 | unsigned int writers; | |
49 | unsigned int waiting_writers; | |
50 | unsigned int r_counter; | |
51 | unsigned int w_counter; | |
52 | struct fasync_struct *fasync_readers; | |
53 | struct fasync_struct *fasync_writers; | |
3a326a2c | 54 | struct inode *inode; |
1da177e4 LT |
55 | }; |
56 | ||
57 | /* Differs from PIPE_BUF in that PIPE_SIZE is the length of the actual | |
58 | memory allocation, whereas PIPE_BUF makes atomicity guarantees. */ | |
59 | #define PIPE_SIZE PAGE_SIZE | |
60 | ||
1da177e4 | 61 | /* Drop the inode semaphore and wait for a pipe event, atomically */ |
3a326a2c | 62 | void pipe_wait(struct pipe_inode_info *pipe); |
1da177e4 | 63 | |
3a326a2c IM |
64 | struct pipe_inode_info * alloc_pipe_info(struct inode * inode); |
65 | void free_pipe_info(struct inode * inode); | |
b92ce558 | 66 | void __free_pipe_info(struct pipe_inode_info *); |
1da177e4 | 67 | |
f84d7519 | 68 | /* Generic pipe buffer ops functions */ |
f6762b7a JA |
69 | void *generic_pipe_buf_map(struct pipe_inode_info *, struct pipe_buffer *, int); |
70 | void generic_pipe_buf_unmap(struct pipe_inode_info *, struct pipe_buffer *, void *); | |
f84d7519 JA |
71 | void generic_pipe_buf_get(struct pipe_inode_info *, struct pipe_buffer *); |
72 | int generic_pipe_buf_pin(struct pipe_inode_info *, struct pipe_buffer *); | |
330ab716 | 73 | int generic_pipe_buf_steal(struct pipe_inode_info *, struct pipe_buffer *); |
f84d7519 | 74 | |
5abc97aa JA |
75 | /* |
76 | * splice is tied to pipes as a transport (at least for now), so we'll just | |
77 | * add the splice flags here. | |
78 | */ | |
79 | #define SPLICE_F_MOVE (0x01) /* move pages instead of copying */ | |
29e35094 LT |
80 | #define SPLICE_F_NONBLOCK (0x02) /* don't block on the pipe splicing (but */ |
81 | /* we may still block on the fd we splice */ | |
82 | /* from/to, of course */ | |
b2b39fa4 | 83 | #define SPLICE_F_MORE (0x04) /* expect more data */ |
7afa6fd0 | 84 | #define SPLICE_F_GIFT (0x08) /* pages passed in are a gift */ |
5abc97aa | 85 | |
00522fb4 JA |
86 | /* |
87 | * Passed to the actors | |
88 | */ | |
89 | struct splice_desc { | |
90 | unsigned int len, total_len; /* current and remaining length */ | |
91 | unsigned int flags; /* splice flags */ | |
92 | struct file *file; /* file to read/write */ | |
93 | loff_t pos; /* file position */ | |
94 | }; | |
95 | ||
96 | typedef int (splice_actor)(struct pipe_inode_info *, struct pipe_buffer *, | |
97 | struct splice_desc *); | |
98 | ||
99 | extern ssize_t splice_from_pipe(struct pipe_inode_info *, struct file *, | |
100 | loff_t *, size_t, unsigned int, | |
101 | splice_actor *); | |
102 | ||
1da177e4 | 103 | #endif |