提交 4cdfe84b 编写于 作者: A Al Viro

[PATCH] deal with the first call of ->show() generating no output

seq_read() has a subtle bug - we want the first loop there to go
until at least one *non-empty* record had fit entirely into buffer.
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 59af1584
...@@ -108,9 +108,9 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos) ...@@ -108,9 +108,9 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
goto Done; goto Done;
} }
/* we need at least one record in buffer */ /* we need at least one record in buffer */
pos = m->index;
p = m->op->start(m, &pos);
while (1) { while (1) {
pos = m->index;
p = m->op->start(m, &pos);
err = PTR_ERR(p); err = PTR_ERR(p);
if (!p || IS_ERR(p)) if (!p || IS_ERR(p))
break; break;
...@@ -119,6 +119,11 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos) ...@@ -119,6 +119,11 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
break; break;
if (unlikely(err)) if (unlikely(err))
m->count = 0; m->count = 0;
if (unlikely(!m->count)) {
p = m->op->next(m, p, &pos);
m->index = pos;
continue;
}
if (m->count < m->size) if (m->count < m->size)
goto Fill; goto Fill;
m->op->stop(m, p); m->op->stop(m, p);
...@@ -128,6 +133,8 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos) ...@@ -128,6 +133,8 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
goto Enomem; goto Enomem;
m->count = 0; m->count = 0;
m->version = 0; m->version = 0;
pos = m->index;
p = m->op->start(m, &pos);
} }
m->op->stop(m, p); m->op->stop(m, p);
m->count = 0; m->count = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册