mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Lundell <jlundell@pobox.com>
To: Tim Hockin <thockin@sun.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: read() called twice for /proc files
Date: Mon, 24 Sep 2001 19:16:36 -0700	[thread overview]
Message-ID: <p0510030eb7d598d54e0f@[10.128.7.49]> (raw)
In-Reply-To: <3BAFDF16.4BD38E7C@sun.com>
In-Reply-To: <3BAFDF16.4BD38E7C@sun.com>

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.

  reply	other threads:[~2001-09-25  2:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-25  1:34 Tim Hockin
2001-09-25  2:16 ` Jonathan Lundell [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-09-25  1:29 Tim Hockin
2001-09-25  1:35 ` David S. Miller

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='p0510030eb7d598d54e0f@[10.128.7.49]' \
    --to=jlundell@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thockin@sun.com \
    /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

all inboxes | Powered by JetHome®