diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2008-03-28 00:46:41 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2008-04-21 23:14:02 -0400 |
commit | 521b5d0c40386f4a9805cdec7bd979fc96a86aeb (patch) | |
tree | 2193c12ee3dc0551790c79370603acb57e0f59e7 /fs | |
parent | 4e1b36fb485dd81b0818ef1bc8fb5c0f2923a283 (diff) |
[PATCH] teach seq_file to discard entries
Allow ->show() return SEQ_SKIP; that will discard all
output from that element and move on.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/pnode.h | 1 | ||||
-rw-r--r-- | fs/seq_file.c | 16 |
2 files changed, 13 insertions, 4 deletions
diff --git a/fs/pnode.h b/fs/pnode.h index f249be2fee7a..973c3f825e7d 100644 --- a/fs/pnode.h +++ b/fs/pnode.h | |||
@@ -35,4 +35,5 @@ int propagate_mnt(struct vfsmount *, struct dentry *, struct vfsmount *, | |||
35 | struct list_head *); | 35 | struct list_head *); |
36 | int propagate_umount(struct list_head *); | 36 | int propagate_umount(struct list_head *); |
37 | int propagate_mount_busy(struct vfsmount *, int); | 37 | int propagate_mount_busy(struct vfsmount *, int); |
38 | void mnt_release_group_id(struct vfsmount *); | ||
38 | #endif /* _LINUX_PNODE_H */ | 39 | #endif /* _LINUX_PNODE_H */ |
diff --git a/fs/seq_file.c b/fs/seq_file.c index 853770274f20..bf2bcfd4bcfb 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c | |||
@@ -25,6 +25,7 @@ | |||
25 | * into the buffer. In case of error ->start() and ->next() return | 25 | * into the buffer. In case of error ->start() and ->next() return |
26 | * ERR_PTR(error). In the end of sequence they return %NULL. ->show() | 26 | * ERR_PTR(error). In the end of sequence they return %NULL. ->show() |
27 | * returns 0 in case of success and negative number in case of error. | 27 | * returns 0 in case of success and negative number in case of error. |
28 | * Returning SEQ_SKIP means "discard this element and move on". | ||
28 | */ | 29 | */ |
29 | int seq_open(struct file *file, const struct seq_operations *op) | 30 | int seq_open(struct file *file, const struct seq_operations *op) |
30 | { | 31 | { |
@@ -114,8 +115,10 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos) | |||
114 | if (!p || IS_ERR(p)) | 115 | if (!p || IS_ERR(p)) |
115 | break; | 116 | break; |
116 | err = m->op->show(m, p); | 117 | err = m->op->show(m, p); |
117 | if (err) | 118 | if (err < 0) |
118 | break; | 119 | break; |
120 | if (unlikely(err)) | ||
121 | m->count = 0; | ||
119 | if (m->count < m->size) | 122 | if (m->count < m->size) |
120 | goto Fill; | 123 | goto Fill; |
121 | m->op->stop(m, p); | 124 | m->op->stop(m, p); |
@@ -140,9 +143,10 @@ Fill: | |||
140 | break; | 143 | break; |
141 | } | 144 | } |
142 | err = m->op->show(m, p); | 145 | err = m->op->show(m, p); |
143 | if (err || m->count == m->size) { | 146 | if (m->count == m->size || err) { |
144 | m->count = offs; | 147 | m->count = offs; |
145 | break; | 148 | if (likely(err <= 0)) |
149 | break; | ||
146 | } | 150 | } |
147 | pos = next; | 151 | pos = next; |
148 | } | 152 | } |
@@ -199,8 +203,12 @@ static int traverse(struct seq_file *m, loff_t offset) | |||
199 | if (IS_ERR(p)) | 203 | if (IS_ERR(p)) |
200 | break; | 204 | break; |
201 | error = m->op->show(m, p); | 205 | error = m->op->show(m, p); |
202 | if (error) | 206 | if (error < 0) |
203 | break; | 207 | break; |
208 | if (unlikely(error)) { | ||
209 | error = 0; | ||
210 | m->count = 0; | ||
211 | } | ||
204 | if (m->count == m->size) | 212 | if (m->count == m->size) |
205 | goto Eoverflow; | 213 | goto Eoverflow; |
206 | if (pos + m->count > offset) { | 214 | if (pos + m->count > offset) { |