seq_file.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef _LINUX_SEQ_FILE_H
  2. #define _LINUX_SEQ_FILE_H
  3. #ifdef __KERNEL__
  4. #include <linux/types.h>
  5. #include <linux/string.h>
  6. #include <linux/mutex.h>
  7. struct seq_operations;
  8. struct file;
  9. struct path;
  10. struct inode;
  11. struct seq_file {
  12. char *buf;
  13. size_t size;
  14. size_t from;
  15. size_t count;
  16. loff_t index;
  17. u64 version;
  18. struct mutex lock;
  19. const struct seq_operations *op;
  20. void *private;
  21. };
  22. struct seq_operations {
  23. void * (*start) (struct seq_file *m, loff_t *pos);
  24. void (*stop) (struct seq_file *m, void *v);
  25. void * (*next) (struct seq_file *m, void *v, loff_t *pos);
  26. int (*show) (struct seq_file *m, void *v);
  27. };
  28. int seq_open(struct file *, const struct seq_operations *);
  29. ssize_t seq_read(struct file *, char __user *, size_t, loff_t *);
  30. loff_t seq_lseek(struct file *, loff_t, int);
  31. int seq_release(struct inode *, struct file *);
  32. int seq_escape(struct seq_file *, const char *, const char *);
  33. int seq_putc(struct seq_file *m, char c);
  34. int seq_puts(struct seq_file *m, const char *s);
  35. int seq_printf(struct seq_file *, const char *, ...)
  36. __attribute__ ((format (printf,2,3)));
  37. int seq_path(struct seq_file *, struct path *, char *);
  38. int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
  39. int single_release(struct inode *, struct file *);
  40. void *__seq_open_private(struct file *, const struct seq_operations *, int);
  41. int seq_open_private(struct file *, const struct seq_operations *, int);
  42. int seq_release_private(struct inode *, struct file *);
  43. #define SEQ_START_TOKEN ((void *)1)
  44. /*
  45. * Helpers for iteration over list_head-s in seq_files
  46. */
  47. extern struct list_head *seq_list_start(struct list_head *head,
  48. loff_t pos);
  49. extern struct list_head *seq_list_start_head(struct list_head *head,
  50. loff_t pos);
  51. extern struct list_head *seq_list_next(void *v, struct list_head *head,
  52. loff_t *ppos);
  53. struct net;
  54. struct seq_net_private {
  55. struct net *net;
  56. };
  57. int seq_open_net(struct inode *, struct file *,
  58. const struct seq_operations *, int);
  59. int seq_release_net(struct inode *, struct file *);
  60. static inline struct net *seq_file_net(struct seq_file *seq)
  61. {
  62. return ((struct seq_net_private *)seq->private)->net;
  63. }
  64. #endif
  65. #endif