[lkml]   [2001]   [Sep]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: read() called twice for /proc files
At 6:34 PM -0700 2001-09-24, Tim Hockin wrote:
>Is there a general solution to the case of read() being called minimum
>twice for a file in /proc? I have a small file in /proc, whose data takes
>a fair time to generate. My read() handler gets called once for the data,
>and once so I can return 0 to terminate read().

I'm guessing you mean that the user is calling read once (and not a
second time to get the 0/eof return), and that proc_file_read() is
calling your read_proc twice. If that's the case, you can just set
the eof flag on the first call (on which you return the data), and
you won't be called again unless the user reads again.

And of course, as David Miller suggests, you can check the offset
first, before generating data.
/Jonathan Lundell.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:03    [W:0.031 / U:1.660 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site