mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Prasanna Meda <pmeda@akamai.com>
To: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Andrew Morton <akpm@osdl.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: 2.6.10-mm3: lseek broken on /proc/self/maps
Date: Fri, 14 Jan 2005 16:46:22 -0800	[thread overview]
Message-ID: <41E867DE.11F4016A@akamai.com> (raw)
In-Reply-To: <1105737819.11209.9.camel@localhost>

[-- Attachment #1: Type: text/plain, Size: 725 bytes --]

Jeremy Fitzhardinge wrote:

> lseek doesn't seem to have any effect on /proc/<pid>/maps.  It should
> either work as expected, or fail.
>

An oversight, f_version is not reset by seq_lseek as done by generic_lseek.
Please try the attached patch.


>
> I've attached a test program which uses a doubling buffer policy to try
> to read the whole buffer.  If it runs out of buffer, it simply allocates
> a new one, lseeks back to the beginning of the buffer, and tries again.
> However, the lseek seems to have no effect, because the next read
> continues from where the previous one (before the lseek) left off.
>
> Re-opening the file between each attempt works as expected.
>

Thanks a lot  for testing all the corner cases.

[-- Attachment #2: seq_version.patch --]
[-- Type: text/plain, Size: 1180 bytes --]


I missed the point that seq_lseek did not reset the f_version,
like generic_lseek did, until Jeremy proved with an example.

Signed-off-by: Prasanna Meda <pmeda@akamai.com>

--- fs/seq_file.c	Fri Jan 14 23:51:27 2005
+++ fs/seq_file.c	Fri Jan 14 23:51:59 2005
@@ -117,6 +117,7 @@ ssize_t seq_read(struct file *file, char
 		if (!m->buf)
 			goto Enomem;
 		m->count = 0;
+		m->version = 0;
 	}
 	m->op->stop(m, p);
 	m->count = 0;
@@ -173,6 +174,7 @@ static int traverse(struct seq_file *m, 
 	int error = 0;
 	void *p;
 
+	m->version = 0;
 	m->index = 0;
 	m->count = m->from = 0;
 	if (!offset)
@@ -227,6 +229,7 @@ loff_t seq_lseek(struct file *file, loff
 	long long retval = -EINVAL;
 
 	down(&m->sem);
+	m->version = file->f_version;
 	switch (origin) {
 		case 1:
 			offset += file->f_pos;
@@ -240,6 +243,7 @@ loff_t seq_lseek(struct file *file, loff
 				if (retval) {
 					/* with extreme prejudice... */
 					file->f_pos = 0;
+					m->version = 0;
 					m->index = 0;
 					m->count = 0;
 				} else {
@@ -248,6 +252,7 @@ loff_t seq_lseek(struct file *file, loff
 			}
 	}
 	up(&m->sem);
+	file->f_version = m->version;
 	return retval;
 }
 EXPORT_SYMBOL(seq_lseek);

  reply	other threads:[~2005-01-15  0:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-14 21:23 Jeremy Fitzhardinge
2005-01-15  0:46 ` Prasanna Meda [this message]
2005-01-15  1:05   ` Jeremy Fitzhardinge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41E867DE.11F4016A@akamai.com \
    --to=pmeda@akamai.com \
    --cc=akpm@osdl.org \
    --cc=jeremy@goop.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome