blob: ec384958d509690090aa1936b4624cb3da05b2d8 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#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 Axboe3e7ee3e2006-04-02 23:11:04 +02008#define PIPE_BUF_FLAG_STOLEN 0x01
9#define PIPE_BUF_FLAG_LRU 0x02
10
Linus Torvalds1da177e2005-04-16 15:20:36 -070011struct pipe_buffer {
12 struct page *page;
13 unsigned int offset, len;
14 struct pipe_buf_operations *ops;
Jens Axboe3e7ee3e2006-04-02 23:11:04 +020015 unsigned int flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -070016};
17
18struct 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 Axboe5abc97a2006-03-30 15:16:46 +020023 int (*steal)(struct pipe_inode_info *, struct pipe_buffer *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070024};
25
26struct pipe_inode_info {
27 wait_queue_head_t wait;
28 unsigned int nrbufs, curbuf;
29 struct pipe_buffer bufs[PIPE_BUFFERS];
30 struct page *tmp_page;
31 unsigned int start;
32 unsigned int readers;
33 unsigned int writers;
34 unsigned int waiting_writers;
35 unsigned int r_counter;
36 unsigned int w_counter;
37 struct fasync_struct *fasync_readers;
38 struct fasync_struct *fasync_writers;
39};
40
41/* Differs from PIPE_BUF in that PIPE_SIZE is the length of the actual
42 memory allocation, whereas PIPE_BUF makes atomicity guarantees. */
43#define PIPE_SIZE PAGE_SIZE
44
Jes Sorensen1b1dcc12006-01-09 15:59:24 -080045#define PIPE_MUTEX(inode) (&(inode).i_mutex)
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#define PIPE_WAIT(inode) (&(inode).i_pipe->wait)
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#define PIPE_READERS(inode) ((inode).i_pipe->readers)
48#define PIPE_WRITERS(inode) ((inode).i_pipe->writers)
49#define PIPE_WAITING_WRITERS(inode) ((inode).i_pipe->waiting_writers)
50#define PIPE_RCOUNTER(inode) ((inode).i_pipe->r_counter)
51#define PIPE_WCOUNTER(inode) ((inode).i_pipe->w_counter)
52#define PIPE_FASYNC_READERS(inode) (&((inode).i_pipe->fasync_readers))
53#define PIPE_FASYNC_WRITERS(inode) (&((inode).i_pipe->fasync_writers))
54
55/* Drop the inode semaphore and wait for a pipe event, atomically */
56void pipe_wait(struct inode * inode);
57
58struct inode* pipe_new(struct inode* inode);
59void free_pipe_info(struct inode* inode);
60
Jens Axboe5abc97a2006-03-30 15:16:46 +020061/*
62 * splice is tied to pipes as a transport (at least for now), so we'll just
63 * add the splice flags here.
64 */
65#define SPLICE_F_MOVE (0x01) /* move pages instead of copying */
Linus Torvalds29e35092006-04-02 12:46:35 -070066#define SPLICE_F_NONBLOCK (0x02) /* don't block on the pipe splicing (but */
67 /* we may still block on the fd we splice */
68 /* from/to, of course */
Jens Axboeb2b39fa2006-04-02 23:05:41 +020069#define SPLICE_F_MORE (0x04) /* expect more data */
Jens Axboe5abc97a2006-03-30 15:16:46 +020070
Linus Torvalds1da177e2005-04-16 15:20:36 -070071#endif