236 lines · 4.6 KB · Text
RawDownload
.TH BIND 2.SH NAMEbind, mount, unmount \- change name space.SH SYNOPSIS.B #include <u.h>.br.B #include <libc.h>.PP.Bint bind(char *name, char *old, int flag).PP.Bint mount(int fd, int afd, char *old, int flag, char *aname).PP.Bint unmount(char *name, char *old).SH DESCRIPTION.I Bindand.I mountmodify the file name space of the current process and otherprocesses in its name space group(see.IR fork (2)).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 oldis.I evaluatedas described in.IR intro (2),except that no translation of the final path element is done..PPFor.IR bind ,.I nameis the name of another (or possibly the same)existing file or directory inthe current name space.After a successful.I bindcall, the file name.I oldis an alias for the object originally named by.IR name ;if the modification doesn't hide it,.I namewill also still refer to its original file.The evaluation of.I newhappens at the time of the.IR bind ,not when the binding is later used..PPThe.I fdargument to.I mountis a file descriptor of an open network connectionor pipe to a file server, while.I afdis a authentication file descriptor as created by.IR fauth (2)and subsequently authenticated.If authentication is not required,.I afdshould be -1.The.I oldfile must be a directory.After a successful.I mountthe file tree.I served(see below) by.I fdwill be visible with its root directory having name.IR old ..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 MBEFORE.TP .B 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.IR mount ,this condition is true by definition),.I oldbecomes a.I "union directory"consisting of one directory (the new file)..TP.B 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 an.B MBEFORE.I bindor.IR mount ,the new directory will be searched first when evaluating file namesin the union directory..TP.B MAFTERLike.B MBEFOREbut the new directory goes at the end of the union..PD.PPThe flags are defined in.BR <libc.h> .In addition, there is an.B MCREATEflag that can be OR'd with any of the above.When a.I createsystem call (see.IR 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 MCREATEset.The file is created in that directory; if that attempt fails,the.I createfails..PPFinally, the.B MCACHEflag, valid for.I mountonly, turns on caching for files made available by the mount.By default, file contents are always retrieved from the server.With caching enabled, the kernel may instead use a local cache to satisfy.IR read (5)requests for files accessible through this mount point.The currency of cached data for a file is verified at each.IR open (5)of the file from this client machine..PPWith.IR mount ,the file descriptor.I fdmust be open for reading and writingand prepared to respond to 9P messages(see Section 5).After the.IR 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 on.IR fd ..I Anameselects among differentfile trees on the server; the null string chooses the default tree..PPThe file descriptor.I fdis automatically closed by a successful.I mountcall..PPThe effects of.I bindand.I mountcan be undone by.IR unmount .If.I nameis zero, everything bound to or mounted upon.I oldis unbound or unmounted.If.I nameis not zero, it is evaluated as described above for.IR bind ,and the effect of binding or mounting that particular result on.I oldis undone..SH SOURCE.B /sys/src/libc/9syscall.SH SEE ALSO.IR bind (1),.IR intro (2),.IR fcall (2),.IR auth (2)(particularly.BR amount ),.IR intro (5),.IR mnt (3),.IR srv (3).SH DIAGNOSTICSThe return value is a positive integer (a unique sequence number) forsuccess, -1 for failure.These routines set.IR errstr ..SH BUGS.I Mountwill not return until it has successfully attachedto the file server, so the process doing a.I mountcannot be the one serving.