9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Michael Teichgräber" <mt@wmipf.in-berlin.de>
To: 9fans@cse.psu.edu
Subject: [9fans] implementing 9p read
Date: Thu,  5 Jul 2007 20:51:05 +0200	[thread overview]
Message-ID: <468D3D99.8010802@wmipf.in-berlin.de> (raw)

Hi,

while thinking about whether it would make sense to use 9p for a rather
small embedded device, where Inferno or Plan 9 cannot be run (similar to
styx-on-a-brick), I came to the problem how to implement read access to
dynamic status files, like the `status' named text files on plan 9, or
files like acme's tag or ctl files. An important question seems to be:
When is the textual contents of such a file allowed to change?

For example, a text file like /mnt/acme/1/ctl: If I enter a character
into buffer 1, a certain number within the ctl file will be updated.
What if someone is reading `ctl' (using the same file descriptor)
just before and after the character is inserted - is its contents
allowed to change while the user does subsequent read() calls? This
could give him a corrupted snapshot of ctl, since parts of the text line
likely will be shifted or somehow overwritten; this can actually be
provoked, if one reads e.g. 10 bytes from ctl, enters a character, reads
some more bytes.

Under the condition that a ctl/status file is expected to be read by
`cat' or similar programs only, which read the whole file at once with
a large enough buffer, there will be no problem, as the text will be
consistent.

Is this the way to go? I.e. a 9p Read message arrives, the file server
just `sprint's status data into a buffer, and returns the requested
parts of it. If the user does seek operations, or reads only some bytes
at once, it is his problem if another sprint call results in a different
buffer content.

A different approach could be to allocate a new buffer for each user
opening the status file (i.e. for each fid), and `sprint' status data
only once into each buffer. This way each user always would see a
consistent text file, regardless of whether he performs seek operations
on it or reads only small chunks. Obviously this approach is also more
memory consuming.

Which approach would be preferred on Plan 9? Thanks for any advice,
Michael



             reply	other threads:[~2007-07-05 18:51 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-05 18:51 Michael Teichgräber [this message]
2007-07-05 18:59 ` Sape Mullender
2007-07-05 19:14   ` Steve Simon
2007-07-05 23:44     ` Michael Teichgräber
2007-07-06  0:01       ` erik quanstrom
2007-07-07 10:57         ` [9fans] kvm matt
2007-07-07 12:19           ` Paweł Lasek
2007-07-07 14:35             ` matt
2007-07-07 19:20               ` Paweł Lasek
2007-07-08 15:22                 ` Paweł Lasek
2007-07-06 14:43       ` [9fans] implementing 9p read Steve Simon
2007-07-06 14:54         ` ron minnich
2007-07-06 21:58           ` Steve Simon
2007-07-06 22:03             ` Charles Forsyth
2007-07-06 14:57         ` C H Forsyth
2007-07-05 19:58   ` ron minnich
2007-07-05 23:32   ` Michael Teichgräber

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=468D3D99.8010802@wmipf.in-berlin.de \
    --to=mt@wmipf.in-berlin.de \
    --cc=9fans@cse.psu.edu \
    /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;
as well as URLs for NNTP newsgroup(s).