diff options
| author | Earl Chew <[email protected]> | 2012-03-21 16:33:43 -0700 |
|---|---|---|
| committer | Linus Torvalds <[email protected]> | 2012-03-21 17:54:54 -0700 |
| commit | 7904ac84244b59f536c2a5d1066a10f46df07b08 (patch) | |
| tree | 82d9c44c26b52954884a70f1ae2b7fa78ea8e633 /tools/perf/scripts/python | |
| parent | dc716e96f5a467835e8121e1caaf25d66a901cb3 (diff) | |
seq_file: fix mishandling of consecutive pread() invocations.
The following program illustrates the problem:
char buf[8192];
int fd = open("/proc/self/maps", O_RDONLY);
n = pread(fd, buf, sizeof(buf), 0);
printf("%d\n", n);
/* lseek(fd, 0, SEEK_CUR); */ /* Uncomment to work around */
n = pread(fd, buf, sizeof(buf), 0);
printf("%d\n", n);
The second printf() prints zero, but uncommenting the lseek() corrects its
behaviour.
To fix, make seq_read() mirror seq_lseek() when processing changes in
*ppos. Restore m->version first, then if required traverse and update
read_pos on success.
Addresses https://bugzilla.kernel.org/show_bug.cgi?id=11856
Signed-off-by: Earl Chew <[email protected]>
Cc: Alexey Dobriyan <[email protected]>
Cc: Al Viro <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions