93 lines · 3.9 KB · Text
RawDownload
= bind, mount, unmount: change file name space     include "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; Bind  and  mount  modify  the  file name space of the currentprocess and its name space group.  For both calls, old is thename  of  an  existing  file or directory in the current namespace where the modification is to be made.  The name old  isevaluated  as described in sys-intro(2) except that no trans‐lation of the final path element is done. For bind, name is the name of another (or possibly the  same)existing  file or directory in the current name space.  Aftera successful bind call, the file name old is an alias for theobject originally named by name; if the modification does nothide the original, name will also still refer to its originalfile.   The  evaluation  of  name  happens at the time of thebind, not when the binding is later used. The fd argument to mount is a file descriptor of an open pipeor  network  connection  to a file server ready to receive 9Pmessages.  The old file must be a directory.   After  a  suc‐cessful mount, the file tree served (see below) by fd will bevisible with its root directory  having  name  old.   If  therequested  service requires authentication, the file descrip‐tor afd must be  open  on  an  authentication  file  for  therequested service; otherwise it should be nil. The  flag  controls  details  of the modification made to thename space.  In the following, new  refers  to  the  file  asdefined  by  name or the root directory served by fd.  Eitherboth old and new files must be directories, or both must  notbe directories.  Flag can be one of: Sys->MREPL       Replace  the  old file by the new one.  Henceforth, an       evaluation of old will be translated to the new  file.       If  they are directories (for mount, this condition is       true by definition), old  becomes  a  union  directory       consisting of one directory (the new file). Sys->MBEFORE       Both  the  old and new files must be directories.  Add       the constituent files of  the  new  directory  to  the       union directory at old so its contents appear first in       the union.  After a Sys->MBEFORE bind  or  mount,  the       new  directory  will be searched first when evaluating       file names in the union directory. Sys->MAFTER       Like Sys->MBEFORE but the new directory  goes  at  the       end of the union. In  addition,  there  is a Sys->MCREATE flag that can be OR'dwith any of the above.  When a create call (see  sys-open(2))attempts  to  create  in a union directory, and the file doesnot exist, the elements of the union are  searched  in  orderuntil  one  is found with Sys->MCREATE set.  The file is cre‐ated in that directory; if that  attempt  fails,  the  createfails. With  mount,  the file descriptor fd must be open for readingand writing and connected to a file server.  After the mount,the  file  tree  starting at old is served by a kernel mnt(3)device.  That device will turn operations in  the  tree  intomessages  to the server on fd.  Aname selects among differentfile trees on the server; the empty (or nil)  string  choosesthe default tree. The  effects  of bind and mount can be undone by unmount.  Ifname is nil, everything bound  to  or  mounted  upon  old  isunbound or unmounted.  If name is not nil, it is evaluated asdescribed above for bind, and the effect of binding or mount‐ing that particular result on old is undone. == see ALSOsys-intro(2) == diagnosticsThe  return  value  is  a positive integer (a unique sequencenumber) for success, -1 for failure. == bugsMount will not return until it has successfully  attached  tothe  file  server,  so the thread doing a mount cannot be theone serving.