code: 9ferno

ref: 44ce0097b612a1fefd754065bdf8d9d2e5ef60c8
dir: /man/2/styxconv/

View raw version
.TH STYXCONV 2
.SH NAME
styxconv \- convert between old 1995 Styx and current Styx (9P)
.SH SYNOPSIS
.EX
include "styxconv.m";
styxconv := load Styxconv Styxconv->PATHNEW2OLD;
styxconv := load Styxconv Styxconv->PATHOLD2NEW;

init:     fn();
styxconv: fn(client: ref Sys->FD, server: ref Sys->FD);
.EE
.SH DESCRIPTION
.B Styxconv
converts between the obsolete 1995 version of the Styx protocol,
as used for instance in Inferno's Third Edition and earlier,
and the current file service protocol,
previously also called `Styx' but
based on 9P2000 and defined by
.IR intro (5).
.PP
.B Init
must be called before any other function in the module.
.PP
The function
.B styxconv
takes two file descriptors:
.I client
should be a connection to a client requiring
one version of the protocol;
.I server
should be a connection to a server serving
the other version of the protocol.
There are two conversion modules:
.B PATHNEW2OLD
converts from a new client to an old server;
.B PATHOLD2NEW
converts from an old client to a new server.
.PP
.B Styxconv
should be spawned by the caller, and copies messages between
.I client
and
.IR server ,
converting as required.
See the example below.
.SH EXAMPLE
Apply
.B styxconv
to file descriptor
.IR fd ,
connected to an old Styx server, and return
a file descriptor suitable for mounting with
.IR mount (2).
.IP
.EX
cvstyx(fd: ref Sys->FD): ref Sys->FD
{
	styxconv := load Styxconv Styxconv->NEW2OLDPATH;
	if(styxconv == nil)
		return nil;
	p := array[2] of ref Sys->FD;
	if(sys->pipe(p) < 0)
		return nil;
	styxconv->init();
	spawn styxconv->styxconv(p[1], fd);
	return p[0];
}
.EE
.SH SOURCE
.B /appl/lib/styxconv
.SH SEE ALSO
.IR bind (1),
.IR sys-bind (2),
.IR sys-pipe (2),
.IR intro (5)
.SH BUGS
There is no provision for 9P2000 authentication.