pipe_fs_i.h 2.3 KB

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