Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Jens Axboe | 3e7ee3e | 2006-04-02 23:11:04 +0200 | [diff] [blame] | 8 | #define PIPE_BUF_FLAG_STOLEN 0x01 |
| 9 | #define PIPE_BUF_FLAG_LRU 0x02 |
| 10 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | struct pipe_buffer { |
| 12 | struct page *page; |
| 13 | unsigned int offset, len; |
| 14 | struct pipe_buf_operations *ops; |
Jens Axboe | 3e7ee3e | 2006-04-02 23:11:04 +0200 | [diff] [blame] | 15 | unsigned int flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | }; |
| 17 | |
| 18 | struct pipe_buf_operations { |
| 19 | int can_merge; |
| 20 | void * (*map)(struct file *, struct pipe_inode_info *, struct pipe_buffer *); |
| 21 | void (*unmap)(struct pipe_inode_info *, struct pipe_buffer *); |
| 22 | void (*release)(struct pipe_inode_info *, struct pipe_buffer *); |
Jens Axboe | 5abc97a | 2006-03-30 15:16:46 +0200 | [diff] [blame] | 23 | int (*steal)(struct pipe_inode_info *, struct pipe_buffer *); |
Jens Axboe | 7052449 | 2006-04-11 15:51:17 +0200 | [diff] [blame^] | 24 | void (*get)(struct pipe_inode_info *, struct pipe_buffer *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | }; |
| 26 | |
| 27 | struct pipe_inode_info { |
| 28 | wait_queue_head_t wait; |
| 29 | unsigned int nrbufs, curbuf; |
| 30 | struct pipe_buffer bufs[PIPE_BUFFERS]; |
| 31 | struct page *tmp_page; |
| 32 | unsigned int start; |
| 33 | unsigned int readers; |
| 34 | unsigned int writers; |
| 35 | unsigned int waiting_writers; |
| 36 | unsigned int r_counter; |
| 37 | unsigned int w_counter; |
| 38 | struct fasync_struct *fasync_readers; |
| 39 | struct fasync_struct *fasync_writers; |
Ingo Molnar | 3a326a2 | 2006-04-10 15:18:35 +0200 | [diff] [blame] | 40 | struct inode *inode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | /* Differs from PIPE_BUF in that PIPE_SIZE is the length of the actual |
| 44 | memory allocation, whereas PIPE_BUF makes atomicity guarantees. */ |
| 45 | #define PIPE_SIZE PAGE_SIZE |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | /* Drop the inode semaphore and wait for a pipe event, atomically */ |
Ingo Molnar | 3a326a2 | 2006-04-10 15:18:35 +0200 | [diff] [blame] | 48 | void pipe_wait(struct pipe_inode_info *pipe); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
Ingo Molnar | 3a326a2 | 2006-04-10 15:18:35 +0200 | [diff] [blame] | 50 | struct pipe_inode_info * alloc_pipe_info(struct inode * inode); |
| 51 | void free_pipe_info(struct inode * inode); |
Jens Axboe | b92ce55 | 2006-04-11 13:52:07 +0200 | [diff] [blame] | 52 | void __free_pipe_info(struct pipe_inode_info *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
Jens Axboe | 5abc97a | 2006-03-30 15:16:46 +0200 | [diff] [blame] | 54 | /* |
| 55 | * splice is tied to pipes as a transport (at least for now), so we'll just |
| 56 | * add the splice flags here. |
| 57 | */ |
| 58 | #define SPLICE_F_MOVE (0x01) /* move pages instead of copying */ |
Linus Torvalds | 29e3509 | 2006-04-02 12:46:35 -0700 | [diff] [blame] | 59 | #define SPLICE_F_NONBLOCK (0x02) /* don't block on the pipe splicing (but */ |
| 60 | /* we may still block on the fd we splice */ |
| 61 | /* from/to, of course */ |
Jens Axboe | b2b39fa | 2006-04-02 23:05:41 +0200 | [diff] [blame] | 62 | #define SPLICE_F_MORE (0x04) /* expect more data */ |
Jens Axboe | 5abc97a | 2006-03-30 15:16:46 +0200 | [diff] [blame] | 63 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | #endif |