groff 1.23.0 added .MR to its -man macro package. The NEWS file states
that the inclusion of the macro "was prompted by its introduction to
Plan 9 from User Space's troff in August 2020." From d32deab it seems
that the name for Plan 9 from User Space's implementation was suggested
by groff maintainer G. Brandon Robinson.
Not sure if the intention was to make these definitions compatible, but
it would be nice if they were.
Currently, Plan 9 from User Space's .MR expects its second argument to
be parenthesized. groff's .MR does not. This results in extra
parentheses appearing in manual references when viewing Plan 9 from User
Space's manual pages on a system using groff.
123 lines
2.1 KiB
Groff
123 lines
2.1 KiB
Groff
.TH VENTI-SERVER 3
|
|
.SH NAME
|
|
vtsrvhello, vtlisten, vtgetreq, vtrespond \- Venti server
|
|
.SH SYNOPSIS
|
|
.PP
|
|
.ft L
|
|
#include <u.h>
|
|
.br
|
|
#include <libc.h>
|
|
.br
|
|
#include <venti.h>
|
|
.ta +\w'\fLVtReq* 'u
|
|
.PP
|
|
.ft L
|
|
.nf
|
|
typedef struct VtReq
|
|
{
|
|
VtFcall tx;
|
|
VtFcall rx;
|
|
...
|
|
} VtReq;
|
|
.PP
|
|
.B
|
|
int vtsrvhello(VtConn *z)
|
|
.PP
|
|
.B
|
|
VtSrv* vtlisten(char *addr)
|
|
.PP
|
|
.B
|
|
VtReq* vtgetreq(VtSrv *srv)
|
|
.PP
|
|
.B
|
|
void vtrespond(VtReq *req)
|
|
.SH DESCRIPTION
|
|
These routines execute the server side of the
|
|
.MR venti 7
|
|
protocol.
|
|
.PP
|
|
.I Vtsrvhello
|
|
executes the server side of the initial
|
|
.B hello
|
|
transaction.
|
|
It sets
|
|
.IB z -> uid
|
|
with the user name claimed by the other side.
|
|
Each new connection must be initialized by running
|
|
.I vtversion
|
|
and then
|
|
.IR vtsrvhello .
|
|
The framework below takes care of this detail automatically;
|
|
.I vtsrvhello
|
|
is provided for programs that do not use the functions below.
|
|
.PP
|
|
.IR Vtlisten ,
|
|
.IR vtgetreq ,
|
|
and
|
|
.I vtrespond
|
|
provide a simple framework for writing Venti servers.
|
|
.PP
|
|
.I Vtlisten
|
|
announces at the network address
|
|
.IR addr ,
|
|
returning a fresh
|
|
.B VtSrv
|
|
structure representing the service.
|
|
.PP
|
|
.I Vtgetreq
|
|
waits for and returns
|
|
the next
|
|
.BR read ,
|
|
.BR write ,
|
|
.BR sync ,
|
|
or
|
|
.B ping
|
|
request from any client connected to
|
|
the service
|
|
.IR srv .
|
|
.B Hello
|
|
and
|
|
.B goodbye
|
|
messages are handled internally and not returned to the client.
|
|
The interface does not distinguish between the
|
|
different clients that may be connected at any given time.
|
|
The request can be found in the
|
|
.I tx
|
|
field of the returned
|
|
.BR VtReq .
|
|
.PP
|
|
Once a request has been served and a response stored in
|
|
.IB r ->rx \fR,
|
|
the server should call
|
|
.IR vtrespond
|
|
to send the response to the client.
|
|
.I Vtrespond
|
|
frees the structure
|
|
.I r
|
|
as well as the packets
|
|
.IB r ->tx.data
|
|
and
|
|
.IB r ->rx.data \fR.
|
|
.SH EXAMPLE
|
|
.B \*9/src/venti/cmd
|
|
contains two simple Venti servers
|
|
.B ro.c
|
|
and
|
|
.B devnull.c
|
|
written using these routines.
|
|
.I Ro
|
|
is a read-only Venti proxy (it rejects
|
|
.B write
|
|
requests).
|
|
.I Devnull
|
|
is a dangerous write-only Venti server: it discards all
|
|
blocks written to it and returns error on all reads.
|
|
.SH SOURCE
|
|
.B \*9/src/libventi
|
|
.SH SEE ALSO
|
|
.MR venti 3 ,
|
|
.MR venti-conn 3 ,
|
|
.MR venti-packet 3 ,
|
|
.MR venti 7 ,
|
|
.MR venti 8
|