pipe_fs_i.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #ifndef _LINUX_PIPE_FS_I_H
  2. #define _LINUX_PIPE_FS_I_H
  3. #define PIPEFS_MAGIC 0x50495045
  4. #define PIPE_BUFFERS (16)
  5. #define PIPE_BUF_FLAG_LRU 0x01
  6. struct pipe_buffer {
  7. struct page *page;
  8. unsigned int offset, len;
  9. struct pipe_buf_operations *ops;
  10. unsigned int flags;
  11. };
  12. struct pipe_buf_operations {
  13. int can_merge;
  14. void * (*map)(struct file *, struct pipe_inode_info *, struct pipe_buffer *);
  15. void (*unmap)(struct pipe_inode_info *, struct pipe_buffer *);
  16. void (*release)(struct pipe_inode_info *, struct pipe_buffer *);
  17. int (*steal)(struct pipe_inode_info *, struct pipe_buffer *);
  18. void (*get)(struct pipe_inode_info *, struct pipe_buffer *);
  19. };
  20. struct pipe_inode_info {
  21. wait_queue_head_t wait;
  22. unsigned int nrbufs, curbuf;
  23. struct pipe_buffer bufs[PIPE_BUFFERS];
  24. struct page *tmp_page;
  25. unsigned int start;
  26. unsigned int readers;
  27. unsigned int writers;
  28. unsigned int waiting_writers;
  29. unsigned int r_counter;
  30. unsigned int w_counter;
  31. struct fasync_struct *fasync_readers;
  32. struct fasync_struct *fasync_writers;
  33. struct inode *inode;
  34. };
  35. /* Differs from PIPE_BUF in that PIPE_SIZE is the length of the actual
  36. memory allocation, whereas PIPE_BUF makes atomicity guarantees. */
  37. #define PIPE_SIZE PAGE_SIZE
  38. /* Drop the inode semaphore and wait for a pipe event, atomically */
  39. void pipe_wait(struct pipe_inode_info *pipe);
  40. struct pipe_inode_info * alloc_pipe_info(struct inode * inode);
  41. void free_pipe_info(struct inode * inode);
  42. void __free_pipe_info(struct pipe_inode_info *);
  43. /*
  44. * splice is tied to pipes as a transport (at least for now), so we'll just
  45. * add the splice flags here.
  46. */
  47. #define SPLICE_F_MOVE (0x01) /* move pages instead of copying */
  48. #define SPLICE_F_NONBLOCK (0x02) /* don't block on the pipe splicing (but */
  49. /* we may still block on the fd we splice */
  50. /* from/to, of course */
  51. #define SPLICE_F_MORE (0x04) /* expect more data */
  52. /*
  53. * Passed to the actors
  54. */
  55. struct splice_desc {
  56. unsigned int len, total_len; /* current and remaining length */
  57. unsigned int flags; /* splice flags */
  58. struct file *file; /* file to read/write */
  59. loff_t pos; /* file position */
  60. };
  61. typedef int (splice_actor)(struct pipe_inode_info *, struct pipe_buffer *,
  62. struct splice_desc *);
  63. extern ssize_t splice_from_pipe(struct pipe_inode_info *, struct file *,
  64. loff_t *, size_t, unsigned int,
  65. splice_actor *);
  66. #endif