* [PATCH] Fix seq_read() in first loop when m->buf is too small
@ 2008-10-10 7:33 Franck Bui-Huu
0 siblings, 0 replies; only message in thread
From: Franck Bui-Huu @ 2008-10-10 7:33 UTC (permalink / raw)
To: viro; +Cc: linux-fsdevel
From: Franck Bui-Huu <fbuihuu@gmail.com>
op->show() has 2 ways to indicate there's not enough space in m->buf:
m->count is always equal to m->size but the ret val of op->show() can
be either 0 or <0.
For the second case, which can happen when op->show() returns directly
seq_printf() return value, the first loop doesn't retry with a bigger
m->buf.
This patch fixes this case.
Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
---
fs/seq_file.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/seq_file.c b/fs/seq_file.c
index bd20f7f..b9d5b37 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -115,9 +115,9 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
if (!p || IS_ERR(p))
break;
err = m->op->show(m, p);
- if (err < 0)
+ if (err < 0 && m->count < m->size)
break;
- if (unlikely(err))
+ if (unlikely(err > 0))
m->count = 0;
if (unlikely(!m->count)) {
p = m->op->next(m, p, &pos);
--
1.6.0.2.GIT
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2008-10-10 7:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-10 7:33 [PATCH] Fix seq_read() in first loop when m->buf is too small Franck Bui-Huu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).