github.com/mvdan/u-root-coreutils@v0.0.0-20230122170626-c2eef2898555/cmds/core/mount/mount_plan9.go (about) 1 // Copyright 2012-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 // Mount mounts servename on old, with an optional keypattern spec 9 // 10 // Synopsis: 11 // 12 // mount [ option ... ] servename old [ spec ] 13 // 14 // Description: 15 // 16 // Mount modifies the name space of the current 17 // process and other processes in the same name space group 18 // (see https://9p.io/magic/man2html/1/bind). 19 // 20 // Options: 21 // 22 // –b: Both files must be directories. Add the new directory to the beginning of the union directory represented by the old file. 23 // –a: Both files must be directories. Add the new directory to the end of the union directory represented by the old file. 24 // –c: This can be used in addition to any of the above to permit creation in a union directory. 25 // When a new file is created in a union directory, it is placed in the first element of the union that has been bound or mounted with the –c flag. 26 // If that directory does not have write permission, the create fails. 27 // -C: By default, file contents are always retrieved from the server. 28 // With this option, the kernel may instead use a local cache to satisfy read(5) requests for files accessible through this mount point. 29 package main 30 31 import ( 32 "fmt" 33 "log" 34 "os" 35 36 "github.com/mvdan/u-root-coreutils/pkg/namespace" 37 ) 38 39 func main() { 40 if len(os.Args) == 1 { 41 n := fmt.Sprintf("/proc/%d/ns", os.Getpid()) 42 if b, err := os.ReadFile(n); err == nil { 43 fmt.Print(string(b)) 44 os.Exit(0) 45 } 46 log.Fatalf("Could not read %s to get namespace", n) 47 } 48 mod, err := namespace.ParseArgs(os.Args) 49 if err != nil { 50 log.Fatal(err) 51 } 52 if err := mod.Modify(namespace.DefaultNamespace, &namespace.Builder{}); err != nil { 53 log.Fatal(err) 54 } 55 }