9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Steve Simon" <steve@quintile.net>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] implementing 9p read
Date: Thu,  5 Jul 2007 20:14:09 +0100	[thread overview]
Message-ID: <8d88287934ff066cf767d5d1e024cf94@quintile.net> (raw)
In-Reply-To: <84c03de05d2626f54ae08464b2933408@plan9.bell-labs.com>

> I don't see how this can be helped other than keeping buffers allocated
> on a per open-file basis — and that would be overkill.

We run an embdeed os at work for which we stole many ideas from plan9.

It has a lib9pfile like library to make writing servers easier.
Generally it uses an array of initialised C structures to define the
hierarchy you want to serve, which contains functions to generate the
contents of these files; Each file also has an associated read and write
flag word. Files can be read:

	line at a time - the library assembles the lines into the
		requested buffer's worth

	file at a time - contents generated in malloced memory on open
		and freed on close

	raw access - requests passed direct to underlying function

writing files can be flagged smilarly:

	line at a time - newlines and leading and trailing whitespace stripped

	file at a time - application specific function called only on close

	raw - as above.

This has been useful and I have thought about writing a similar library for
plan9 but have not done so yet, its difficult to decide what is useful often
enough to libraryise and what is just "nice to have".

-Steve


  reply	other threads:[~2007-07-05 19:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-05 18:51 Michael Teichgräber
2007-07-05 18:59 ` Sape Mullender
2007-07-05 19:14   ` Steve Simon [this message]
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=8d88287934ff066cf767d5d1e024cf94@quintile.net \
    --to=steve@quintile.net \
    --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).