forsyth20100205-1101bb3d01d16 years agoHistory
116 lines · 2.3 KB · Text
RawDownload
.TH SYS-EXPORT 2.SH NAMEexport \- export a name space.SH SYNOPSIS.EXinclude "sys.m";sys := load Sys Sys->PATH; export:   fn(fd: ref FD, dir: string, flag: int):   int;.EE.SH DESCRIPTION.B Exportreceives and repliesto 9P requests from a client on a connection represented by.IR fd ,for file operations on the part of the current file name spacerooted at.IR dir ,which is thus exported.This is the server end of the client's.B mountcall.Names presented by the client are interpreted relative to directory.IR dir ,which can be adjusted using.IR sys-pctl (2)and.IR sys-bind (2)before export.The file descriptor.I fdmust be open for reading and writing, and neither mounted elsewhere nor already exported..PPCommonly,.BR export 'sfirst argument is a file descriptor open on the data file in the.B dirof a.B Connectionreturned by.B listen(see.IR dial (2)).Before calling.BR export ,the connection on.I fdcan optionally be authenticated and set for encryption or digesting using thefunctions in.IR security-auth (2)..PPThe.B exportfunction takes two mutually exclusive flags:.TP.B Sys->EXPWAIT.B Exportblocks until all client requests are complete..TP.B Sys->EXPASYNCClient requests are handled by a background (kernel) process..B Exportreturns immediately.The serving process terminates when the client hangs up..SH EXAMPLES.PPExport a given directory on.BR fd ,protecting it from subsequent changes:.IP.EXexportdir(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);}.EE.PPThe.B FORKNSgiven to.B pctlforks the name space, andprevents the.B sys->exportfrom seeing the effects of subsequent mounts by the processthat calls or spawns.BR exportdir .The.B exportdirfunction above might be called using:.IP.EXpid := chan of int;spawn exportdir(fd, "/", pid);expid := <-pid;.EE.PPService will stop automatically when the connection.B fdreturns end-of-file (eg, when it hangs up),but it can also be stopped locally by killing.BR expid ..EE.SH SOURCE.B /emu/port/inferno.c.br.B /emu/port/exportfs.c.br.B /os/port/inferno.c.br.B /os/port/exportfs.c.SH DIAGNOSTICS.B Exportreturns a non-negative value on success and -1 on error;the system error string is set.