seq_file.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #ifndef _LINUX_SEQ_FILE_H
  2. #define _LINUX_SEQ_FILE_H
  3. #include <linux/types.h>
  4. #include <linux/string.h>
  5. #include <linux/mutex.h>
  6. #include <linux/cpumask.h>
  7. #include <linux/nodemask.h>
  8. struct seq_operations;
  9. struct file;
  10. struct path;
  11. struct inode;
  12. struct dentry;
  13. struct seq_file {
  14. char *buf;
  15. size_t size;
  16. size_t from;
  17. size_t count;
  18. loff_t index;
  19. loff_t read_pos;
  20. u64 version;
  21. struct mutex lock;
  22. const struct seq_operations *op;
  23. void *private;
  24. };
  25. struct seq_operations {
  26. void * (*start) (struct seq_file *m, loff_t *pos);
  27. void (*stop) (struct seq_file *m, void *v);
  28. void * (*next) (struct seq_file *m, void *v, loff_t *pos);
  29. int (*show) (struct seq_file *m, void *v);
  30. };
  31. #define SEQ_SKIP 1
  32. char *mangle_path(char *s, char *p, char *esc);
  33. int seq_open(struct file *, const struct seq_operations *);
  34. ssize_t seq_read(struct file *, char __user *, size_t, loff_t *);
  35. loff_t seq_lseek(struct file *, loff_t, int);
  36. int seq_release(struct inode *, struct file *);
  37. int seq_escape(struct seq_file *, const char *, const char *);
  38. int seq_putc(struct seq_file *m, char c);
  39. int seq_puts(struct seq_file *m, const char *s);
  40. int seq_write(struct seq_file *seq, const void *data, size_t len);
  41. int seq_printf(struct seq_file *, const char *, ...)
  42. __attribute__ ((format (printf,2,3)));
  43. int seq_path(struct seq_file *, struct path *, char *);
  44. int seq_dentry(struct seq_file *, struct dentry *, char *);
  45. int seq_path_root(struct seq_file *m, struct path *path, struct path *root,
  46. char *esc);
  47. int seq_bitmap(struct seq_file *m, const unsigned long *bits,
  48. unsigned int nr_bits);
  49. static inline int seq_cpumask(struct seq_file *m, const struct cpumask *mask)
  50. {
  51. return seq_bitmap(m, cpumask_bits(mask), nr_cpu_ids);
  52. }
  53. static inline int seq_nodemask(struct seq_file *m, nodemask_t *mask)
  54. {
  55. return seq_bitmap(m, mask->bits, MAX_NUMNODES);
  56. }
  57. int seq_bitmap_list(struct seq_file *m, const unsigned long *bits,
  58. unsigned int nr_bits);
  59. static inline int seq_cpumask_list(struct seq_file *m,
  60. const struct cpumask *mask)
  61. {
  62. return seq_bitmap_list(m, cpumask_bits(mask), nr_cpu_ids);
  63. }
  64. static inline int seq_nodemask_list(struct seq_file *m, nodemask_t *mask)
  65. {
  66. return seq_bitmap_list(m, mask->bits, MAX_NUMNODES);
  67. }
  68. int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
  69. int single_release(struct inode *, struct file *);
  70. void *__seq_open_private(struct file *, const struct seq_operations *, int);
  71. int seq_open_private(struct file *, const struct seq_operations *, int);
  72. int seq_release_private(struct inode *, struct file *);
  73. #define SEQ_START_TOKEN ((void *)1)
  74. /*
  75. * Helpers for iteration over list_head-s in seq_files
  76. */
  77. extern struct list_head *seq_list_start(struct list_head *head,
  78. loff_t pos);
  79. extern struct list_head *seq_list_start_head(struct list_head *head,
  80. loff_t pos);
  81. extern struct list_head *seq_list_next(void *v, struct list_head *head,
  82. loff_t *ppos);
  83. #endif