namespace

package module
v1.0.4-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2025 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package namespace parses name space description files https://plan9.io/magic/man2html/6/namespace

Index

Constants

View Source
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
)
View Source
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

View Source
var DefaultNamespace = &unixnamespace{}

Functions

func AddNS

func AddNS(nsfile string) error

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

func NewNS(nsfile string) error

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).

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder helps building plan9 namespaces

func NewBuilder

func NewBuilder() (*Builder, error)

NewBuilder returns the default runner

func (*Builder) Parse

func (b *Builder) Parse(file string) error

Parse takes a path and parses the namespace file

type File

type File []cmd

File are a collection of calls that a namespace has to do as defined by the namespace files

func Parse

func Parse(r io.Reader) (File, error)

Parse takes a namespace file and returns a collection of operations.

type Namespace

type Namespace interface {
	// Bind binds new on old.
	Bind(new, old string, flag int) error
	// Mount mounts servename on old.
	Mount(servername, old, spec string, flag int) 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 int) error
}

Namespace is a plan9 namespace. It implmenets the bind(1) calls. Bind and mount modify the file name space of the current process and other processes in its name space group (see fork(2)). 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 intro(2), except that no translation of the final path element is done.

type OpenFunc

type OpenFunc func(path string) (io.Reader, error)

OpenFunc opens files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL