public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Val Henson <val@nmt.edu>
To: "Randy.Dunlap" <rddunlap@osdl.org>
Cc: Laurent <laurent@augias.org>, linux-kernel@vger.kernel.org
Subject: Re: read_proc issue
Date: Wed, 27 Feb 2002 14:04:32 -0700	[thread overview]
Message-ID: <20020227140432.L20918@boardwalk> (raw)
In-Reply-To: <E16fmE1-0000Mu-00@lsinitam> <Pine.LNX.4.33L2.0202271122040.1463-100000@dragon.pdx.osdl.net>
In-Reply-To: <Pine.LNX.4.33L2.0202271122040.1463-100000@dragon.pdx.osdl.net>; from rddunlap@osdl.org on Wed, Feb 27, 2002 at 11:33:18AM -0800

On Wed, Feb 27, 2002 at 11:33:18AM -0800, Randy.Dunlap wrote:
> On Tue, 26 Feb 2002, Laurent wrote:
<snippety snippety>
> | Problem is:
> | when I 'cat /proc/number' multiple times, instead of getting
> | 0
> | 1
> | 2
> | 3
> | ...
> |
> | I get
> | 0
> | 2
> | 4
> | 6
> | ...
<more snippage>
> app. calls read() [Key data: with offset=0], which calls sys_read(),
> which calls proc_file_read(), which returns N bytes, and then
> proc_file_read() and sys_read() and read() return to the app.
> 
> When the app. gets N bytes of actual data on its read(), it
> doesn't know whether it was at EOF or not, so it tries another
> read() [with offset=N], and sys_read() calls proc_file_read()
> again, both of which return 0, so the app. knows that there
> is no more data.

I've encountered this problem before, too.  What is the "One True Way"
to do this cleanly?  In other words, if you want to do a calculation
once every time someone runs "cat /proc/foo", what is the cleanest way
to do that?  The solution we came up with was to check the file offset
and only do the calculation if offset == 0, which seems pretty
hackish.

-VAL

  reply	other threads:[~2002-02-27 21:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-26 18:21 read_proc issue Laurent
2002-02-27 19:33 ` Randy.Dunlap
2002-02-27 21:04   ` Val Henson [this message]
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

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=20020227140432.L20918@boardwalk \
    --to=val@nmt.edu \
    --cc=laurent@augias.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rddunlap@osdl.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