forsyth20121205-174063a80cc13 years agoHistory
201 lines · 4.0 KB · Text
RawDownload
.TH SYS-BIND 2.SH NAMEbind, mount, unmount \- change file name space.SH SYNOPSIS.EXinclude "sys.m";sys := load Sys Sys->PATH; bind:     fn(name, old: string, flag: int): int;mount:    fn(fd: ref FD; afd: ref FD, old: string, flag: int, aname: string):             int;unmount:  fn(name, old: string): int;.EE.SH DESCRIPTION.B Bindand.B mountmodify the file name space of the current process and its name space group.For both calls,.I oldis the name of an existing file or directory in thecurrent name space where the modification is to be made.The name.I oldisevaluatedas described in.IR sys-intro (2)except that no translation of the final path element is done..PPFor.BR bind ,.I nameis the name of another (or possibly the same)existing file or directory inthe current name space.After a successful.B bindcall, the file name.I oldis an alias for the object originally named by.IR name ;if the modification does not hide the original,.I namewill also still refer to its original file.The evaluation of.I namehappens at the time of the.BR bind ,not when the binding is later used..PPThe.I fdargument to.B mountis a file descriptor of an open pipe or network connectionto a file server ready to receive 9P messages.The.I oldfile must be a directory.After a successful.BR mount ,the file tree.I served(see below) by.I fdwill be visible with its root directory having name.IR old .If the requested service requires authentication, the file descriptor.I afdmust be open on an authentication file for therequested service;otherwise it should be.BR nil ..PPThe.I flagcontrols details of the modification made to the name space.In the following,.I newrefers to the fileas defined by.I nameor the root directory served by.IR fd .Either both.I oldand new files must be directories,or both must not be directories..I Flagcan be one of:.TF Sys->MBEFORE.TP .B Sys->MREPLReplace the.I oldfile by the new one.Henceforth, an evaluation of.I oldwill be translated to the new file.If they are directories (for.BR mount ,this condition is true by definition),.I oldbecomes a.I "union directory"consisting of one directory (the new file)..TP.B Sys->MBEFOREBoth the.I oldand new files must be directories.Add the constituent files of the new directoryto the union directory at.I oldso its contents appear first in the union.After a.B Sys->MBEFORE.B bindor.BR mount ,the new directory will be searched first when evaluating file namesin the union directory..TP.B Sys->MAFTERLike.B Sys->MBEFOREbut the new directory goes at the end of the union..PD.PPIn addition, there is a.B Sys->MCREATEflag that can be OR'd with any of the above.When a.B createcall (see.IR sys-open (2))attempts to create in a union directory, and the file does not exist,the elements of the union are searched in order until one is foundwith.B Sys->MCREATEset.The file is created in that directory; if that attempt fails,the.B createfails..PPWith.BR mount ,the file descriptor.I fdmust be open for reading and writingand connected to a file server.After the.BR mount ,the file tree starting at.I oldis served by a kernel.IR mnt (3)device.That device will turn operations in the tree into messages to the server on.IR fd ..I Anameselects among differentfile trees on the server; theempty (or nil)string chooses the default tree..PPThe effects of.B bindand.B mountcan be undone by.BR unmount .If.I nameis.BR nil ,everything bound to or mounted upon.I oldis unbound or unmounted.If.I nameis not.BR nil ,it is evaluated as described above for.BR bind ,and the effect of binding or mounting that particular result on.I oldis undone..SH SEE ALSO.IR sys-intro (2).SH DIAGNOSTICSThe return value is a positive integer (a unique sequence number) forsuccess, \-1 for failure..SH BUGS.B Mountwill not return until it has successfully attachedto the file server, so the thread doing a.B mountcannot be the one serving.