include "sys.m"; sys := load Sys Sys->PATH; export: fn(fd: ref FD, dir: string, flag: int): int;
Commonly, export's first argument is a file descriptor open on the data file in the dir of a Connection returned by listen (see dial(2)). Before calling export, the connection on fd can optionally be authenticated and set for encryption or digesting using the functions in security-auth(2).
The export function takes two mutually exclusive flags:
exportdir(fd: ref Sys->FD, dir: string, pid: chan of int) { pid <-= sys->pctl(Sys->FORKNS|Sys->FORKENV|Sys->NEWFD, fd.fd :: nil); sys->export(fd, dir, Sys->EXPWAIT); }
The FORKNS given to pctl forks the name space, and prevents the sys->export from seeing the effects of subsequent mounts by the process that calls or spawns exportdir. The exportdir function above might be called using:
pid := chan of int; spawn exportdir(fd, "/", pid); expid := <-pid;
Service will stop automatically when the connection fd returns end-of-file (eg, when it hangs up), but it can also be stopped locally by killing expid.
SYS-EXPORT(2 ) | Rev: Tue Mar 31 02:42:39 GMT 2015 |