]> git.ipfire.org Git - people/ms/linux.git/commit
seq_file: properly cope with pread
authorEric Biederman <ebiederm@xmission.com>
Wed, 18 Feb 2009 22:48:16 +0000 (14:48 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 17 Mar 2009 00:52:43 +0000 (17:52 -0700)
commita67036940686aa5df75e3c83fb81e53e60821c51
tree98730e0b801a54e0783484c06d59eea22ba33523
parent62c57441c10cc2b19443e8bbcd1728ae6ea3b83c
seq_file: properly cope with pread

commit 8f19d472935c83d823fa4cf02bcc0a7b9952db30 upstream.

Currently seq_read assumes that the offset passed to it is always the
offset it passed to user space.  In the case pread this assumption is
broken and we do the wrong thing when presented with pread.

To solve this I introduce an offset cache inside of struct seq_file so we
know where our logical file position is.  Then in seq_read if we try to
read from another offset we reset our data structures and attempt to go to
the offset user space wanted.

[akpm@linux-foundation.org: restore FMODE_PWRITE]
[pjt@google.com: seq_open needs its fmode opened up to take advantage of this]
Signed-off-by: Eric Biederman <ebiederm@xmission.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Paul Turner <pjt@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/seq_file.c
include/linux/seq_file.h