seq_file.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. u64 version;
  20. struct mutex lock;
  21. const struct seq_operations *op;
  22. void *private;
  23. };
  24. struct seq_operations {
  25. void * (*start) (struct seq_file *m, loff_t *pos);
  26. void (*stop) (struct seq_file *m, void *v);
  27. void * (*next) (struct seq_file *m, void *v, loff_t *pos);
  28. int (*show) (struct seq_file *m, void *v);
  29. };
  30. #define SEQ_SKIP 1
  31. char *mangle_path(char *s, char *p, char *esc);
  32. int seq_open(struct file *, const struct seq_operations *);
  33. ssize_t seq_read(struct file *, char __user *, size_t, loff_t *);
  34. loff_t seq_lseek(struct file *, loff_t, int);
  35. int seq_release(struct inode *, struct file *);
  36. int seq_escape(struct seq_file *, const char *, const char *);
  37. int seq_putc(struct seq_file *m, char c);
  38. int seq_puts(struct seq_file *m, const char *s);
  39. int seq_printf(struct seq_file *, const char *, ...)
  40. __attribute__ ((format (printf,2,3)));
  41. int seq_path(struct seq_file *, struct path *, char *);
  42. int seq_dentry(struct seq_file *, struct dentry *, char *);
  43. int seq_path_root(struct seq_file *m, struct path *path, struct path *root,
  44. char *esc);
  45. int seq_bitmap(struct seq_file *m, const unsigned long *bits,
  46. unsigned int nr_bits);
  47. static inline int seq_cpumask(struct seq_file *m, const struct cpumask *mask)
  48. {
  49. return seq_bitmap(m, mask->bits, NR_CPUS);
  50. }
  51. static inline int seq_nodemask(struct seq_file *m, nodemask_t *mask)
  52. {
  53. return seq_bitmap(m, mask->bits, MAX_NUMNODES);
  54. }
  55. int seq_bitmap_list(struct seq_file *m, unsigned long *bits,
  56. unsigned int nr_bits);
  57. static inline int seq_cpumask_list(struct seq_file *m, cpumask_t *mask)
  58. {
  59. return seq_bitmap_list(m, mask->bits, NR_CPUS);
  60. }
  61. static inline int seq_nodemask_list(struct seq_file *m, nodemask_t *mask)
  62. {
  63. return seq_bitmap_list(m, mask->bits, MAX_NUMNODES);
  64. }
  65. int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
  66. int single_release(struct inode *, struct file *);
  67. void *__seq_open_private(struct file *, const struct seq_operations *, int);
  68. int seq_open_private(struct file *, const struct seq_operations *, int);
  69. int seq_release_private(struct inode *, struct file *);
  70. #define SEQ_START_TOKEN ((void *)1)
  71. /*
  72. * Helpers for iteration over list_head-s in seq_files
  73. */
  74. extern struct list_head *seq_list_start(struct list_head *head,
  75. loff_t pos);
  76. extern struct list_head *seq_list_start_head(struct list_head *head,
  77. loff_t pos);
  78. extern struct list_head *seq_list_next(void *v, struct list_head *head,
  79. loff_t *ppos);
  80. #endif