Documentation ¶
Overview ¶
Package namespace parses name space description files https://plan9.io/magic/man2html/6/namespace
Index ¶
Constants ¶
const ( // REPL 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). REPL mountflag = 0x0000 // BEFORE 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 an BEFORE bind or mount, the new directory will be // searched first when evaluating file names in the union directory. BEFORE mountflag = 0x0001 // AFTER Like MBEFORE but the new directory goes at the end of the union. AFTER mountflag = 0x0002 // CREATE flag that can be OR'd with any of the above. // When a create system call (see 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 found with CREATE set. The file is created in that directory; // if that attempt fails, the create fails. CREATE mountflag = 0x0004 // CACHE flag, valid for mount only, 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 read(5) requests for files accessible through this mount point. CACHE mountflag = 0x0010 )
const ( // BIND is the plan9 bind syscall. https://9p.io/magic/man2html/2/bind BIND syzcall = 2 // CHDIR is the plan9 bind syscall. https://9p.io/magic/man2html/2/chdir CHDIR syzcall = 3 // UNMOUNT is the plan9 unmount syscall. https://9p.io/magic/man2html/2/bind UNMOUNT syzcall = 35 // MOUNT is the plan9 MOUNT syscall. https://9p.io/magic/man2html/2/bind MOUNT syzcall = 46 // RFORK is the plan9 rfork() syscall. https://9p.io/magic/man2html/2/fork // used to perform clear RFORK syzcall = 19 // IMPORT is not a syscall. https://9p.io/magic/man2html/4/import IMPORT syzcall = 7 // INCLUDE is not a syscall INCLUDE syzcall = 14 )
Variables ¶
var DefaultNamespace = &unixnamespace{}
DefaultNamespace is the default namespace
Functions ¶
func AddNS ¶
AddNS also interprets and executes the commands in nsfile. Unlike newns it applies the command to the current name space rather than starting from scratch.
func NewNS ¶
NewNS builds a name space for user. It opens the file nsfile (/lib/namespace is used if nsfile is ""), copies the old environment, erases the current name space, sets the environment variables user and home, and interprets the commands in nsfile. The format of nsfile is described in namespace(6).
func ParseFlags ¶
ParseFlags parses flags as mount, bind would. Not using the os.Flag package here as that would break the name space description files. https://9p.io/magic/man2html/6/namespace
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder helps building plan9 name spaces. Builder keeps track of directory changes when another name space file is included, another builder will be created for it's modifications, and it's final working directory will be set to be the parents working directroy after it's modifications are complete.
type Modifier ¶
type Modifier interface { // Modify modifies the namespace Modify(ns Namespace, b *Builder) error String() string }
Modifier repesents an individual command that can be applied to a plan9 name space which will modify the name space of the process or process group.
type Namespace ¶
type Namespace interface { // Bind binds new on old. Bind(new, old string, flag mountflag) error // Mount mounts servename on old. Mount(servername, old, spec string, flag mountflag) error // Unmount unmounts new from old, or everything mounted on old if new is missing. Unmount(new, old string) error // Clear clears the name space with rfork(RFCNAMEG). Clear() error // Chdir changes the working directory to dir. Chdir(dir string) error // Import imports a name space from a remote system Import(host, remotepath, mountpoint string, flag mountflag) error }
Namespace is a plan9 namespace. It implmenets the http://man.cat-v.org/plan_9/2/bind calls.
Bind and mount modify the file name space of the current process and other processes in its name space group (see http://man.cat-v.org/plan_9/2/fork). For both calls, old is the name of an existing file or directory in the current name space where the modification is to be made. The name old is evaluated as described in http://man.cat-v.org/plan_9/2/intro, except that no translation of the final path element is done.
type OpenFunc ¶
OpenFunc opens files for the include or . commands in name space files. while the default open function is just os.Open for the file:// one could extend this to other protocols. Potentially we could even import files from the web.eg
. https://harvey-os.org/lib/namespace@sha256:deadbeef
could be interesting.