9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Richard Miller <9fans@hamnavoe.com>
To: 9fans@9fans.net
Subject: Re: [9fans] Regarding 9p based "protocols" message framing
Date: Fri, 16 Mar 2012 17:04:00 +0000	[thread overview]
Message-ID: <9bd1c348b487ab7f85af250e76175753@hamnavoe.com> (raw)
In-Reply-To: <CA+Tk8fzHcHvd-yMfwVXSC7hpH-AsA1ocYhe0m+K7mPar=HF-sA@mail.gmail.com>

>     * the tools must be aware of this mapping between 1 request == 1
> write operation; thus if for example my request would be composed of
> multiple lines, and I use `cat >./some-file` as an "interface"; then
> `cat` would read one line and immediately send it as an individual
> write operation which of course is not respecting the "protocol" built
> ontop of 9p;

In general, control requests are not multiple lines (I presume by "line"
you mean a string of characters delimited by '\n').  As you say, each
request must be presented in a single 9p message, and this fits well
with the guarantee that 9p read/write messages are atomic [provided
tbe length is <= iounit].  The first example in 2.6 of /sys/doc/auth is
misleading -- if you try to do literally what it says:

	% cd /mnt/factotum
	% cat >ctl
	key dom=bell-labs.com proto=p9sk1 user=gre
		!password='don''t tell'
	key proto=apop server=x.y.com user=gre
		!password='bite me'
	^D

you'll find you get a write error after the first line; each 'key'
command actually has to be sent as a single write.  You can't even
get it to accept multiple lines in one write:

	term% echo 'key dom=bell-labs.com proto=p9sk1 user=gre
			!password=bite-me' >/mnt/factotum/ctl
	echo: write error: multiline write not allowed

In my experience, sending control requests as single atomic writes
is a natural way to work.  With failed requests communicated as
write errors, this makes it simple to match the error status with
the request.

Multiline responses are somewhat more common, and there is some
inconsistency in whether responses also need to be read as a single
atomic operation.  This can make it tricky, for example, to use the
read(1) command -- which reads one char at a time -- in a script
dealing with a device control interface.

For example, this loop works:
	</dev/irqalloc while (x=`{read}) echo $x
but this doesn't:
	</dev/ioalloc while (x=`{read}) echo $x




  reply	other threads:[~2012-03-16 17:04 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-16 11:40 Ciprian Dorin Craciun
2012-03-16 17:04 ` Richard Miller [this message]
2012-03-16 17:36 ` Russ Cox
2012-03-16 17:55   ` Ciprian Dorin Craciun
     [not found] ` <CADSkJJVcsffzZo6En5A8DTApZULxkqCuzXEgKbFvv8eRjm2DpQ@mail.gmail.c>
2012-03-16 17:49   ` erik quanstrom
2012-03-20 11:42     ` Yaroslav
2012-03-20 12:32       ` Dan Cross
2012-03-20 20:30         ` Ciprian Dorin Craciun
2012-03-21  1:22           ` Dan Cross
     [not found]           ` <CAEoi9W6t2WRPTYU6+JHfAZoRAe6aWxkuCDkXb1G+VAkZZ1kYug@mail.gmail.c>
2012-03-21  1:52             ` erik quanstrom
     [not found]       ` <CAEoi9W6z_48wm8Jx__Meodnr50g0Ba00wqyfVrv0SP=Xb5ZHcw@mail.gmail.c>
2012-03-20 15:57         ` erik quanstrom
2012-03-21 20:11           ` Yaroslav
2012-03-21 20:32             ` Anthony Sorace
2012-03-21 20:37               ` erik quanstrom
     [not found]           ` <CAG3N4d_Qd-dH4pZWXGdqoNTguSjGge1oLahTwJAk5nVLvzXvjQ@mail.gmail.c>
2012-03-21 20:27             ` erik quanstrom
2012-03-21 20:38               ` Anthony Sorace
2012-03-21 20:53                 ` erik quanstrom
2012-03-21 21:24                   ` cinap_lenrek
2012-03-21 21:27                     ` erik quanstrom
2012-03-21 21:35                       ` cinap_lenrek
2012-03-21 21:07                 ` cinap_lenrek
2012-03-21 21:22                   ` erik quanstrom
2012-03-21 21:16               ` David du Colombier

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=9bd1c348b487ab7f85af250e76175753@hamnavoe.com \
    --to=9fans@hamnavoe.com \
    --cc=9fans@9fans.net \
    /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).