5
Server
mount and export
The kernel maps system calls like open()
, read()
, write() etc. into function calls on devices.
One of the devices is #M. It can only be accessed by the kernel. #M translates function calls into remote function calls, i.e., Styx transactions, to processes for which #M has file connections (ref FD).
#M gets these file connections through the system call mount()
:
include "sys.m";
sys := load Sys Sys->PATH;
if (sys->mount(fd, "/n/client", sys->MAFTER|sys->MCREATE, "") < 0)
sys->print("mount failed: %r\n");
The command mount
gets the ref FD as a network connection to the port styx (usually 6666) for some host:
perky$ mount -ac net!$FILESERVER /n/client
$FILESERVER can be replaced by a DNS name or IP address. mount does not permit an explicit port, however.
mount uses the same flags as bind. Additionally, a security algorithm can be specified with -C for the Secure Socket Layer
: md5 or sha for digesting, rc4 for encryption, and in the US two versions of DES.
mount() links up with the system call export()
at the other end of a connection:
if (sys->export(fd, sys->EXPWAIT) < 0)
sys->print("export failed: %r\n");
export() delivers it's entire namespace to #M and from there to the directory specified for mount(). It is advisable to use newns()
to create a reduced namespace first.
clone
is a Limbo program which uses the module styx
to copy and display Styx messages:
perky$ clone
Usage: clone [-Av] net!machine[!port] port
clone -f [-abv] net!machine[!port] path/file
-A suppresses authentication. -f requests that clone use #s
to park a network connection as a file. A new directory is mounted in path using the flags -a or -bwhich contains just file.
mnt
extends mount to match clone:
perky$ mnt
Usage: mnt [-abcr] [-Ap | -C alg] net!machine[!port] dir
mnt -f [-abcpr] path/file dir
-A suppresses authentication. -p will request a password. -p mounts a file:
$ emu
perky$ lib/srv
perky$ clone -v net!perky 1234
perky$ clone -fb net!perky!1234 /tmp/srv
perky$ mnt -f /tmp/srv /n/client
lib/srv starts file service, the first clone produces a trace, the second one connects to the file mount with mnt. Altogether this permits watching Styx.
odin
odin
evolved from u9fs, a UNIX program that makes a UNIX tree accessible for Plan 9. odin serves a UNIX tree for Styx; however, it usually requires a UNIX password as aname in Tattach
and does not support the Secure Socket Layer.
$ odin -p 1234 -v
$ emu
perky$ lib/srv
perky$ mnt -Ap net!perky!1234 /n/client
odin illustrates the internal workings of a server using ANSI-C. With the option -v odin displays the transactions as diagnostic output.
odin should be run by root. In this case, an argument can be specified for chroot(). If another user runs odin, it serves / and cannot act on all aspects of protection.