9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] implementing 9p read
@ 2007-07-05 18:51 Michael Teichgräber
  2007-07-05 18:59 ` Sape Mullender
  0 siblings, 1 reply; 17+ messages in thread
From: Michael Teichgräber @ 2007-07-05 18:51 UTC (permalink / raw)
  To: 9fans

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



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

end of thread, other threads:[~2007-07-08 15:22 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-05 18:51 [9fans] implementing 9p read Michael Teichgräber
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

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).