public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* read_proc issue
@ 2002-02-26 18:21 Laurent
  2002-02-27 19:33 ` Randy.Dunlap
  0 siblings, 1 reply; 14+ messages in thread
From: Laurent @ 2002-02-26 18:21 UTC (permalink / raw)
  To: linux-kernel

Hi everyone, hope I don't disturb too much.

I'm developping a module which uses an entry in /proc (read-only)
Currently my (*read_proc) function just write a integer in my /proc entry  
and increments it. Here is the code:

static int number_read_procmem(char *buf, char **start, off_t offset, int 
count, int *eof, void *data)
{
        int len = 0;

        len = sprintf(buf, "%d\n", number_current++);
        *eof = 1;
        return len;
}

the function is registered in init_module with this:
create_proc_read_entry("number", 0, NULL, number_read_procmem, NULL);

Problem is:
when I 'cat /proc/number' multiple times, instead of getting
0
1
2
3
...

I get
0
2
4
6
...

I've searched the Net for an answer to this but in vain. I'm not sure I 
should post this to this list (and I'm very sorry if I indeed shouldn't have) 
but this list is my last hope :(

Please can you CC: me the answers to this post as I'm not on the list.
Then again, sorry if I'm intruding and thanks for any help.

Regards,
Laurent Sinitambirivoutin
laurent@augias.org

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: read_proc issue
@ 2002-02-27  0:51 Thomas Hood
  0 siblings, 0 replies; 14+ messages in thread
From: Thomas Hood @ 2002-02-27  0:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: Laurent

Don't count on your proc read function being
called only once to read a given piece of information.




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

end of thread, other threads:[~2002-03-01 19:50 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-02-26 18:21 read_proc issue Laurent
2002-02-27 19:33 ` Randy.Dunlap
2002-02-27 21:04   ` Val Henson
2002-02-27 21:42     ` Alan Cox
2002-02-27 21:44       ` Cort Dougan
2002-02-28  0:05       ` Erik Mouw
2002-02-27  3:19         ` Daniel Phillips
2002-03-01  7:14           ` Erik Mouw
2002-03-01  7:47             ` Alexander Viro
2002-03-01  8:18               ` Laurent
2002-03-01  8:18                 ` Alexander Viro
2002-03-01 19:49               ` Cort Dougan
2002-02-27 23:32     ` Laurent
  -- strict thread matches above, loose matches on Subject: below --
2002-02-27  0:51 Thomas Hood

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