github.com/mvdan/u-root-coreutils@v0.0.0-20230122170626-c2eef2898555/pkg/namespace/namespace_unix.go (about) 1 // Copyright 2020 the u-root Authors. All rights reserved 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build !plan9 6 // +build !plan9 7 8 // This file is inserted here so the lack of these variables/implmenetations doesn't break 9 // IDEs and tooling on other platforms. 10 11 package namespace 12 13 // DefaultNamespace is the default namespace 14 var DefaultNamespace = &unixnamespace{} 15 16 const ( 17 // REPL Replace the old file by the new one. 18 // Henceforth, an evaluation of old will be translated to the new file. 19 // If they are directories (for mount, this condition is true by definition), 20 // old becomes a union directory consisting of one directory (the new file). 21 REPL mountflag = 0x0000 22 // BEFORE Both the old and new files must be directories. 23 // Add the constituent files of the new directory to the 24 // union directory at old so its contents appear first in the union. 25 // After an BEFORE bind or mount, the new directory will be 26 // searched first when evaluating file names in the union directory. 27 BEFORE mountflag = 0x0001 28 // AFTER Like MBEFORE but the new directory goes at the end of the union. 29 AFTER mountflag = 0x0002 30 // CREATE flag that can be OR'd with any of the above. 31 // When a create system call (see open(2)) attempts to create in a union directory, 32 // and the file does not exist, the elements of the union are searched in order until 33 // one is found with CREATE set. The file is created in that directory; 34 // if that attempt fails, the create fails. 35 CREATE mountflag = 0x0004 36 // CACHE flag, valid for mount only, turns on caching for files made available by the mount. 37 // By default, file contents are always retrieved from the server. 38 // With caching enabled, the kernel may instead use a local cache 39 // to satisfy read(5) requests for files accessible through this mount point. 40 CACHE mountflag = 0x0010 41 ) 42 43 const ( 44 // These are copied over from the syscall pkg for plan9 https://golang.org/pkg/syscall/?GOOS=plan9 45 46 // BIND is the plan9 bind syscall. https://9p.io/magic/man2html/2/bind 47 BIND syzcall = 2 48 // CHDIR is the plan9 bind syscall. https://9p.io/magic/man2html/2/chdir 49 CHDIR syzcall = 3 50 // UNMOUNT is the plan9 unmount syscall. https://9p.io/magic/man2html/2/bind 51 UNMOUNT syzcall = 35 52 // MOUNT is the plan9 MOUNT syscall. https://9p.io/magic/man2html/2/bind 53 MOUNT syzcall = 46 54 // RFORK is the plan9 rfork() syscall. https://9p.io/magic/man2html/2/fork 55 // used to perform clear 56 RFORK syzcall = 19 57 // IMPORT is not a syscall. https://9p.io/magic/man2html/4/import 58 IMPORT syzcall = 7 59 // INCLUDE is not a syscall 60 INCLUDE syzcall = 14 61 ) 62 63 type unixnamespace struct{} 64 65 // Bind binds new on old. 66 func (ns *unixnamespace) Bind(new string, old string, flag mountflag) error { 67 panic("not implemented") // TODO: Implement 68 } 69 70 // Mount mounts servename on old. 71 func (ns *unixnamespace) Mount(servername string, old string, spec string, flag mountflag) error { 72 panic("not implemented") // TODO: Implement 73 } 74 75 // Unmount unmounts new from old, or everything mounted on old if new is missing. 76 func (ns *unixnamespace) Unmount(new string, old string) error { 77 panic("not implemented") // TODO: Implement 78 } 79 80 // Clear clears the name space with rfork(RFCNAMEG). 81 func (ns *unixnamespace) Clear() error { 82 panic("not implemented") // TODO: Implement 83 } 84 85 // Chdir changes the working directory to dir. 86 func (ns *unixnamespace) Chdir(dir string) error { 87 panic("not implemented") // TODO: Implement 88 } 89 90 // Import imports a name space from a remote system 91 func (ns *unixnamespace) Import(host string, remotepath string, mountpoint string, flag mountflag) error { 92 panic("not implemented") // TODO: Implement 93 }