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