>     * 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 via email to