Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 183980
b: refs/heads/master
c: 66655de
h: refs/heads/master
v: v3
  • Loading branch information
Li Zefan authored and David S. Miller committed Feb 10, 2010
1 parent f46f339 commit 8e41ebf
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b1109bf085c8dd69537b7876ea83f914dd1fe46a
refs/heads/master: 66655de6d132b726be64c324bc3f9ea366d20697
59 changes: 56 additions & 3 deletions trunk/fs/seq_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,6 @@ struct list_head *seq_list_start(struct list_head *head, loff_t pos)

return NULL;
}

EXPORT_SYMBOL(seq_list_start);

struct list_head *seq_list_start_head(struct list_head *head, loff_t pos)
Expand All @@ -684,7 +683,6 @@ struct list_head *seq_list_start_head(struct list_head *head, loff_t pos)

return seq_list_start(head, pos - 1);
}

EXPORT_SYMBOL(seq_list_start_head);

struct list_head *seq_list_next(void *v, struct list_head *head, loff_t *ppos)
Expand All @@ -695,5 +693,60 @@ struct list_head *seq_list_next(void *v, struct list_head *head, loff_t *ppos)
++*ppos;
return lh == head ? NULL : lh;
}

EXPORT_SYMBOL(seq_list_next);

/**
* seq_hlist_start - start an iteration of a hlist
* @head: the head of the hlist
* @pos: the start position of the sequence
*
* Called at seq_file->op->start().
*/
struct hlist_node *seq_hlist_start(struct hlist_head *head, loff_t pos)
{
struct hlist_node *node;

hlist_for_each(node, head)
if (pos-- == 0)
return node;
return NULL;
}
EXPORT_SYMBOL(seq_hlist_start);

/**
* seq_hlist_start_head - start an iteration of a hlist
* @head: the head of the hlist
* @pos: the start position of the sequence
*
* Called at seq_file->op->start(). Call this function if you want to
* print a header at the top of the output.
*/
struct hlist_node *seq_hlist_start_head(struct hlist_head *head, loff_t pos)
{
if (!pos)
return SEQ_START_TOKEN;

return seq_hlist_start(head, pos - 1);
}
EXPORT_SYMBOL(seq_hlist_start_head);

/**
* seq_hlist_next - move to the next position of the hlist
* @v: the current iterator
* @head: the head of the hlist
* @pos: the current posision
*
* Called at seq_file->op->next().
*/
struct hlist_node *seq_hlist_next(void *v, struct hlist_head *head,
loff_t *ppos)
{
struct hlist_node *node = v;

++*ppos;
if (v == SEQ_START_TOKEN)
return head->first;
else
return node->next;
}
EXPORT_SYMBOL(seq_hlist_next);
11 changes: 11 additions & 0 deletions trunk/include/linux/seq_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,15 @@ extern struct list_head *seq_list_start_head(struct list_head *head,
extern struct list_head *seq_list_next(void *v, struct list_head *head,
loff_t *ppos);

/*
* Helpers for iteration over hlist_head-s in seq_files
*/

extern struct hlist_node *seq_hlist_start(struct hlist_head *head,
loff_t pos);
extern struct hlist_node *seq_hlist_start_head(struct hlist_head *head,
loff_t pos);
extern struct hlist_node *seq_hlist_next(void *v, struct hlist_head *head,
loff_t *ppos);

#endif

0 comments on commit 8e41ebf

Please sign in to comment.