[manual index][section index]

NAME

styxconv - convert between old and new Styx

SYNOPSIS

include "styxconv.m";
styxconv := load Styxconv Styxconv->PATH;

init:     fn();
styxconv: fn(to: ref Sys->FD, from: ref Sys->FD, pid: chan of int);

DESCRIPTION

Styxconv converts between the previous version of the Styx protocol, as used for instance in Inferno's Third Edition and earlier, and the current version of the protocol, based on 9P2000 and defined by intro(5).

Init must be called before any other function in the module.

The function styxconv takes two file descriptors. From must be a connection to a file server that serves the original, older version of Styx. To is a connection, perhaps a pipe, to something that requires the current protocol; Sys->mount for instance (see sys-bind(2)). Styxconv is spawned by the caller, to create a process that copies messages between from and to, converting as required as it goes. Its process ID is the only message sent on channel pidc; it must be received by styxconv's caller. See the example below.

EXAMPLE

Apply styxconv to file descriptor fd connected to an old Styx server:

cvstyx(fd: ref Sys->FD): ref Sys->FD
{
	styxconv := load Styxconv Styxconv->PATH;
	if(styxconv == nil)
		return nil;
	p := array[2] of ref Sys->FD;
	if(sys->pipe(p) < 0)
		return nil;
	styxconv->init();
	pidc := chan of int;
	spawn styxconv->styxconv(p[1], fd, pidc);
	<-pidc;
	return p[0];
}

SOURCE

/appl/lib/styxconv

SEE ALSO

bind(1), sys-bind(2), sys-pipe(2), intro(5)

STYXCONV(2 ) Rev:  Sun Feb 22 17:41:21 GMT 2009