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 | |
| 8 | struct pipe_buffer { |
| 9 | struct page *page; |
| 10 | unsigned int offset, len; |
| 11 | struct pipe_buf_operations *ops; |
Jens Axboe | 5abc97a | 2006-03-30 15:16:46 +0200 | [diff] [blame] | 12 | unsigned int stolen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | }; |
| 14 | |
| 15 | struct pipe_buf_operations { |
| 16 | int can_merge; |
| 17 | void * (*map)(struct file *, struct pipe_inode_info *, struct pipe_buffer *); |
| 18 | void (*unmap)(struct pipe_inode_info *, struct pipe_buffer *); |
| 19 | void (*release)(struct pipe_inode_info *, struct pipe_buffer *); |
Jens Axboe | 5abc97a | 2006-03-30 15:16:46 +0200 | [diff] [blame] | 20 | int (*steal)(struct pipe_inode_info *, struct pipe_buffer *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | }; |
| 22 | |
| 23 | struct pipe_inode_info { |
| 24 | wait_queue_head_t wait; |
| 25 | unsigned int nrbufs, curbuf; |
| 26 | struct pipe_buffer bufs[PIPE_BUFFERS]; |
| 27 | struct page *tmp_page; |
| 28 | unsigned int start; |
| 29 | unsigned int readers; |
| 30 | unsigned int writers; |
| 31 | unsigned int waiting_writers; |
| 32 | unsigned int r_counter; |
| 33 | unsigned int w_counter; |
| 34 | struct fasync_struct *fasync_readers; |
| 35 | struct fasync_struct *fasync_writers; |
| 36 | }; |
| 37 | |
| 38 | /* Differs from PIPE_BUF in that PIPE_SIZE is the length of the actual |
| 39 | memory allocation, whereas PIPE_BUF makes atomicity guarantees. */ |
| 40 | #define PIPE_SIZE PAGE_SIZE |
| 41 | |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 42 | #define PIPE_MUTEX(inode) (&(inode).i_mutex) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | #define PIPE_WAIT(inode) (&(inode).i_pipe->wait) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #define PIPE_READERS(inode) ((inode).i_pipe->readers) |
| 45 | #define PIPE_WRITERS(inode) ((inode).i_pipe->writers) |
| 46 | #define PIPE_WAITING_WRITERS(inode) ((inode).i_pipe->waiting_writers) |
| 47 | #define PIPE_RCOUNTER(inode) ((inode).i_pipe->r_counter) |
| 48 | #define PIPE_WCOUNTER(inode) ((inode).i_pipe->w_counter) |
| 49 | #define PIPE_FASYNC_READERS(inode) (&((inode).i_pipe->fasync_readers)) |
| 50 | #define PIPE_FASYNC_WRITERS(inode) (&((inode).i_pipe->fasync_writers)) |
| 51 | |
| 52 | /* Drop the inode semaphore and wait for a pipe event, atomically */ |
| 53 | void pipe_wait(struct inode * inode); |
| 54 | |
| 55 | struct inode* pipe_new(struct inode* inode); |
| 56 | void free_pipe_info(struct inode* inode); |
| 57 | |
Jens Axboe | 5abc97a | 2006-03-30 15:16:46 +0200 | [diff] [blame] | 58 | /* |
| 59 | * splice is tied to pipes as a transport (at least for now), so we'll just |
| 60 | * add the splice flags here. |
| 61 | */ |
| 62 | #define SPLICE_F_MOVE (0x01) /* move pages instead of copying */ |
| 63 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | #endif |