seq_file.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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_printf(struct seq_file *, const char *, ...)
  41. __attribute__ ((format (printf,2,3)));
  42. int seq_path(struct seq_file *, struct path *, char *);
  43. int seq_dentry(struct seq_file *, struct dentry *, char *);
  44. int seq_path_root(struct seq_file *m, struct path *path, struct path *root,
  45. char *esc);
  46. int seq_bitmap(struct seq_file *m, const unsigned long *bits,
  47. unsigned int nr_bits);
  48. static inline int seq_cpumask(struct seq_file *m, const struct cpumask *mask)
  49. {
  50. return seq_bitmap(m, cpumask_bits(mask), nr_cpu_ids);
  51. }
  52. static inline int seq_nodemask(struct seq_file *m, nodemask_t *mask)
  53. {
  54. return seq_bitmap(m, mask->bits, MAX_NUMNODES);
  55. }
  56. int seq_bitmap_list(struct seq_file *m, const unsigned long *bits,
  57. unsigned int nr_bits);
  58. static inline int seq_cpumask_list(struct seq_file *m,
  59. const struct cpumask *mask)
  60. {
  61. return seq_bitmap_list(m, cpumask_bits(mask), nr_cpu_ids);
  62. }
  63. static inline int seq_nodemask_list(struct seq_file *m, nodemask_t *mask)
  64. {
  65. return seq_bitmap_list(m, mask->bits, MAX_NUMNODES);
  66. }
  67. int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
  68. int single_release(struct inode *, struct file *);
  69. void *__seq_open_private(struct file *, const struct seq_operations *, int);
  70. int seq_open_private(struct file *, const struct seq_operations *, int);
  71. int seq_release_private(struct inode *, struct file *);
  72. #define SEQ_START_TOKEN ((void *)1)
  73. /*
  74. * Helpers for iteration over list_head-s in seq_files
  75. */
  76. extern struct list_head *seq_list_start(struct list_head *head,
  77. loff_t pos);
  78. extern struct list_head *seq_list_start_head(struct list_head *head,
  79. loff_t pos);
  80. extern struct list_head *seq_list_next(void *v, struct list_head *head,
  81. loff_t *ppos);
  82. #endif