1 #ifndef _LINUX_PIPE_FS_I_H 2 #define _LINUX_PIPE_FS_I_H 3 4 #define PIPEFS_MAGIC 0x50495045 5 struct pipe_inode_info { 6 wait_queue_head_t wait; 7 char *base; 8 unsigned int len; 9 unsigned int start; 10 unsigned int readers; 11 unsigned int writers; 12 unsigned int waiting_readers; 13 unsigned int waiting_writers; 14 unsigned int r_counter; 15 unsigned int w_counter; 16 }; 17 18 /* Differs from PIPE_BUF in that PIPE_SIZE is the length of the actual 19 memory allocation, whereas PIPE_BUF makes atomicity guarantees. */ 20 #define PIPE_SIZE PAGE_SIZE 21 22 #define PIPE_SEM(inode) (&(inode).i_sem) 23 #define PIPE_WAIT(inode) (&(inode).i_pipe->wait) 24 #define PIPE_BASE(inode) ((inode).i_pipe->base) 25 #define PIPE_START(inode) ((inode).i_pipe->start) 26 #define PIPE_LEN(inode) ((inode).i_pipe->len) 27 #define PIPE_READERS(inode) ((inode).i_pipe->readers) 28 #define PIPE_WRITERS(inode) ((inode).i_pipe->writers) 29 #define PIPE_WAITING_READERS(inode) ((inode).i_pipe->waiting_readers) 30 #define PIPE_WAITING_WRITERS(inode) ((inode).i_pipe->waiting_writers) 31 #define PIPE_RCOUNTER(inode) ((inode).i_pipe->r_counter) 32 #define PIPE_WCOUNTER(inode) ((inode).i_pipe->w_counter) 33 34 #define PIPE_EMPTY(inode) (PIPE_LEN(inode) == 0) 35 #define PIPE_FULL(inode) (PIPE_LEN(inode) == PIPE_SIZE) 36 #define PIPE_FREE(inode) (PIPE_SIZE - PIPE_LEN(inode)) 37 #define PIPE_END(inode) ((PIPE_START(inode) + PIPE_LEN(inode)) & (PIPE_SIZE-1)) 38 #define PIPE_MAX_RCHUNK(inode) (PIPE_SIZE - PIPE_START(inode)) 39 #define PIPE_MAX_WCHUNK(inode) (PIPE_SIZE - PIPE_END(inode)) 40 41 /* Drop the inode semaphore and wait for a pipe event, atomically */ 42 void pipe_wait(struct inode * inode); 43 44 struct inode* pipe_new(struct inode* inode); 45 46 #endif 47