aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/seq_file.c34
-rw-r--r--include/linux/seq_file.h11
2 files changed, 45 insertions, 0 deletions
diff --git a/fs/seq_file.c b/fs/seq_file.c
index 0ac22af7afe5..49194a4e6b91 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -447,3 +447,37 @@ int seq_puts(struct seq_file *m, const char *s)
447 return -1; 447 return -1;
448} 448}
449EXPORT_SYMBOL(seq_puts); 449EXPORT_SYMBOL(seq_puts);
450
451struct list_head *seq_list_start(struct list_head *head, loff_t pos)
452{
453 struct list_head *lh;
454
455 list_for_each(lh, head)
456 if (pos-- == 0)
457 return lh;
458
459 return NULL;
460}
461
462EXPORT_SYMBOL(seq_list_start);
463
464struct list_head *seq_list_start_head(struct list_head *head, loff_t pos)
465{
466 if (!pos)
467 return head;
468
469 return seq_list_start(head, pos - 1);
470}
471
472EXPORT_SYMBOL(seq_list_start_head);
473
474struct list_head *seq_list_next(void *v, struct list_head *head, loff_t *ppos)
475{
476 struct list_head *lh;
477
478 lh = ((struct list_head *)v)->next;
479 ++*ppos;
480 return lh == head ? NULL : lh;
481}
482
483EXPORT_SYMBOL(seq_list_next);
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index 3e3cccbb1cac..83783ab0f552 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -50,5 +50,16 @@ int seq_release_private(struct inode *, struct file *);
50 50
51#define SEQ_START_TOKEN ((void *)1) 51#define SEQ_START_TOKEN ((void *)1)
52 52
53/*
54 * Helpers for iteration over list_head-s in seq_files
55 */
56
57extern struct list_head *seq_list_start(struct list_head *head,
58 loff_t pos);
59extern struct list_head *seq_list_start_head(struct list_head *head,
60 loff_t pos);
61extern struct list_head *seq_list_next(void *v, struct list_head *head,
62 loff_t *ppos);
63
53#endif 64#endif
54#endif 65#endif