pipe_fs_i.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 /* page is on the LRU */
  6. #define PIPE_BUF_FLAG_ATOMIC 0x02 /* was atomically mapped */
  7. #define PIPE_BUF_FLAG_GIFT 0x04 /* page is a gift */
  8. struct pipe_buffer {
  9. struct page *page;
  10. unsigned int offset, len;
  11. const struct pipe_buf_operations *ops;
  12. unsigned int flags;
  13. unsigned long private;
  14. };
  15. struct pipe_inode_info {
  16. wait_queue_head_t wait;
  17. unsigned int nrbufs, curbuf;
  18. struct page *tmp_page;
  19. unsigned int readers;
  20. unsigned int writers;
  21. unsigned int waiting_writers;
  22. unsigned int r_counter;
  23. unsigned int w_counter;
  24. struct fasync_struct *fasync_readers;
  25. struct fasync_struct *fasync_writers;
  26. struct inode *inode;
  27. struct pipe_buffer bufs[PIPE_BUFFERS];
  28. };
  29. /*
  30. * Note on the nesting of these functions:
  31. *
  32. * ->confirm()
  33. * ->steal()
  34. * ...
  35. * ->map()
  36. * ...
  37. * ->unmap()
  38. *
  39. * That is, ->map() must be called on a confirmed buffer,
  40. * same goes for ->steal().
  41. */
  42. struct pipe_buf_operations {
  43. int can_merge;
  44. void * (*map)(struct pipe_inode_info *, struct pipe_buffer *, int);
  45. void (*unmap)(struct pipe_inode_info *, struct pipe_buffer *, void *);
  46. int (*confirm)(struct pipe_inode_info *, struct pipe_buffer *);
  47. void (*release)(struct pipe_inode_info *, struct pipe_buffer *);
  48. int (*steal)(struct pipe_inode_info *, struct pipe_buffer *);
  49. void (*get)(struct pipe_inode_info *, struct pipe_buffer *);
  50. };
  51. /* Differs from PIPE_BUF in that PIPE_SIZE is the length of the actual
  52. memory allocation, whereas PIPE_BUF makes atomicity guarantees. */
  53. #define PIPE_SIZE PAGE_SIZE
  54. /* Drop the inode semaphore and wait for a pipe event, atomically */
  55. void pipe_wait(struct pipe_inode_info *pipe);
  56. struct pipe_inode_info * alloc_pipe_info(struct inode * inode);
  57. void free_pipe_info(struct inode * inode);
  58. void __free_pipe_info(struct pipe_inode_info *);
  59. /* Generic pipe buffer ops functions */
  60. void *generic_pipe_buf_map(struct pipe_inode_info *, struct pipe_buffer *, int);
  61. void generic_pipe_buf_unmap(struct pipe_inode_info *, struct pipe_buffer *, void *);
  62. void generic_pipe_buf_get(struct pipe_inode_info *, struct pipe_buffer *);
  63. int generic_pipe_buf_confirm(struct pipe_inode_info *, struct pipe_buffer *);
  64. int generic_pipe_buf_steal(struct pipe_inode_info *, struct pipe_buffer *);
  65. #endif