public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* procfs feature or bug?
@ 2001-09-19 10:23 Sandip Bhattacharya
  2001-09-19 16:19 ` Jonathan Lundell
  0 siblings, 1 reply; 2+ messages in thread
From: Sandip Bhattacharya @ 2001-09-19 10:23 UTC (permalink / raw)
  To: linux-kernel

[Do cc me replies. Thanks.]

Hi!

I was trying out the multipage procfs entries, when i found out that i
was having a problem.  

I am trying to use the "hack" by Paul Russell to allow mangling of
filepos using ``*start'' entries as my personal page offset. Now, for
multipage entries, whatever i set as *start should be coming back to
me as offset when the next page is called.

But in fs/proc/generic.c in proc_file_read() at the end we have (
after the first page has been "copied_to_user")

 *ppos += start < page ? (long) start : n;

But this _adds_ the contents of start to the offset, in the case where
I am supplying the offset in ``start''. Shouldn't this just be
_replacing_ ? 'Cause in this case the offsets get cumulatively added,
causing an oops at the end for me :(

Or am I missing something big???

- Sandip

--
-----------------------------------------------------------
Sandip Bhattacharya
Office: sandip@mindsw.com       Home: sandipb@bigfoot.com
Mindframe Software
-----------------------------------------------------------

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: procfs feature or bug?
  2001-09-19 10:23 procfs feature or bug? Sandip Bhattacharya
@ 2001-09-19 16:19 ` Jonathan Lundell
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Lundell @ 2001-09-19 16:19 UTC (permalink / raw)
  To: Sandip Bhattacharya, linux-kernel

At 3:53 PM +0530 2001-09-19, Sandip Bhattacharya wrote:
>I was trying out the multipage procfs entries, when i found out that i
>was having a problem. 
>
>I am trying to use the "hack" by Paul Russell to allow mangling of
>filepos using ``*start'' entries as my personal page offset. Now, for
>multipage entries, whatever i set as *start should be coming back to
>me as offset when the next page is called.
>
>But in fs/proc/generic.c in proc_file_read() at the end we have (
>after the first page has been "copied_to_user")
>
>  *ppos += start < page ? (long) start : n;
>
>But this _adds_ the contents of start to the offset, in the case where
>I am supplying the offset in ``start''. Shouldn't this just be
>_replacing_ ? 'Cause in this case the offsets get cumulatively added,
>causing an oops at the end for me :(
>
>Or am I missing something big???

Per the comment:

>		/* This is a hack to allow mangling of file pos independent
>  		 * of actual bytes read.  Simply place the data at page,
>  		 * return the bytes, and set `start' to the desired offset
>  		 * as an unsigned int. - Paul.Russell@rustcorp.com.au
>		*/

*ppos represents the offset in the *file*, not the buffer, so 
cumulative is correct. So when you do your read, you need to 
interpret it thus. I've been using it in one case as a record number, 
where the records are variable length. I set *start to 1, and treat 
is as an index into a (virtual) array of records.
-- 
/Jonathan Lundell.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-09-19 16:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-09-19 10:23 procfs feature or bug? Sandip Bhattacharya
2001-09-19 16:19 ` Jonathan Lundell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox