浏览代码

Merge pull request #6205 from crosbymichael/rename-namespaces

Rename nsinit package to namespaces in libcontainer
Michael Crosby 11 年之前
父节点
当前提交
a8ef66d84a

+ 8 - 8
daemon/execdriver/native/driver.go

@@ -16,7 +16,7 @@ import (
 	"github.com/dotcloud/docker/pkg/libcontainer"
 	"github.com/dotcloud/docker/pkg/libcontainer/cgroups/fs"
 	"github.com/dotcloud/docker/pkg/libcontainer/cgroups/systemd"
-	"github.com/dotcloud/docker/pkg/libcontainer/nsinit"
+	"github.com/dotcloud/docker/pkg/libcontainer/namespaces"
 	"github.com/dotcloud/docker/pkg/system"
 )
 
@@ -42,11 +42,11 @@ func init() {
 		if err != nil {
 			return err
 		}
-		syncPipe, err := nsinit.NewSyncPipeFromFd(0, uintptr(args.Pipe))
+		syncPipe, err := namespaces.NewSyncPipeFromFd(0, uintptr(args.Pipe))
 		if err != nil {
 			return err
 		}
-		if err := nsinit.Init(container, rootfs, args.Console, syncPipe, args.Args); err != nil {
+		if err := namespaces.Init(container, rootfs, args.Console, syncPipe, args.Args); err != nil {
 			return err
 		}
 		return nil
@@ -110,8 +110,8 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
 
 	term := getTerminal(c, pipes)
 
-	return nsinit.Exec(container, term, c.Rootfs, dataPath, args, func(container *libcontainer.Container, console, rootfs, dataPath, init string, child *os.File, args []string) *exec.Cmd {
-		// we need to join the rootfs because nsinit will setup the rootfs and chroot
+	return namespaces.Exec(container, term, c.Rootfs, dataPath, args, func(container *libcontainer.Container, console, rootfs, dataPath, init string, child *os.File, args []string) *exec.Cmd {
+		// we need to join the rootfs because namespaces will setup the rootfs and chroot
 		initPath := filepath.Join(c.Rootfs, c.InitPath)
 
 		c.Path = d.initPath
@@ -126,7 +126,7 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
 
 		// set this to nil so that when we set the clone flags anything else is reset
 		c.SysProcAttr = nil
-		system.SetCloneFlags(&c.Cmd, uintptr(nsinit.GetNamespaceFlags(container.Namespaces)))
+		system.SetCloneFlags(&c.Cmd, uintptr(namespaces.GetNamespaceFlags(container.Namespaces)))
 		c.ExtraFiles = []*os.File{child}
 
 		c.Env = container.Env
@@ -258,8 +258,8 @@ func getEnv(key string, env []string) string {
 	return ""
 }
 
-func getTerminal(c *execdriver.Command, pipes *execdriver.Pipes) nsinit.Terminal {
-	var term nsinit.Terminal
+func getTerminal(c *execdriver.Command, pipes *execdriver.Pipes) namespaces.Terminal {
+	var term namespaces.Terminal
 	if c.Tty {
 		term = &dockerTtyTerm{
 			pipes: pipes,

+ 1 - 1
pkg/libcontainer/nsinit/create.go → pkg/libcontainer/namespaces/create.go

@@ -1,4 +1,4 @@
-package nsinit
+package namespaces
 
 import (
 	"os"

+ 1 - 1
pkg/libcontainer/nsinit/exec.go → pkg/libcontainer/namespaces/exec.go

@@ -1,6 +1,6 @@
 // +build linux
 
-package nsinit
+package namespaces
 
 import (
 	"os"

+ 1 - 1
pkg/libcontainer/nsinit/execin.go → pkg/libcontainer/namespaces/execin.go

@@ -1,6 +1,6 @@
 // +build linux
 
-package nsinit
+package namespaces
 
 import (
 	"fmt"

+ 1 - 1
pkg/libcontainer/nsinit/init.go → pkg/libcontainer/namespaces/init.go

@@ -1,6 +1,6 @@
 // +build linux
 
-package nsinit
+package namespaces
 
 import (
 	"fmt"

+ 1 - 1
pkg/libcontainer/nsinit/pid.go → pkg/libcontainer/namespaces/pid.go

@@ -1,4 +1,4 @@
-package nsinit
+package namespaces
 
 import (
 	"fmt"

+ 1 - 1
pkg/libcontainer/nsinit/std_term.go → pkg/libcontainer/namespaces/std_term.go

@@ -1,4 +1,4 @@
-package nsinit
+package namespaces
 
 import (
 	"io"

+ 1 - 1
pkg/libcontainer/nsinit/sync_pipe.go → pkg/libcontainer/namespaces/sync_pipe.go

@@ -1,4 +1,4 @@
-package nsinit
+package namespaces
 
 import (
 	"encoding/json"

+ 1 - 1
pkg/libcontainer/nsinit/term.go → pkg/libcontainer/namespaces/term.go

@@ -1,4 +1,4 @@
-package nsinit
+package namespaces
 
 import (
 	"io"

+ 1 - 1
pkg/libcontainer/nsinit/tty_term.go → pkg/libcontainer/namespaces/tty_term.go

@@ -1,4 +1,4 @@
-package nsinit
+package namespaces
 
 import (
 	"io"

+ 1 - 1
pkg/libcontainer/nsinit/unsupported.go → pkg/libcontainer/namespaces/unsupported.go

@@ -1,6 +1,6 @@
 // +build !linux
 
-package nsinit
+package namespaces
 
 import (
 	"github.com/dotcloud/docker/pkg/libcontainer"

+ 8 - 8
pkg/libcontainer/nsinit/nsinit/main.go → pkg/libcontainer/nsinit/main.go

@@ -13,7 +13,7 @@ import (
 
 	"github.com/dotcloud/docker/pkg/libcontainer"
 	"github.com/dotcloud/docker/pkg/libcontainer/cgroups/fs"
-	"github.com/dotcloud/docker/pkg/libcontainer/nsinit"
+	"github.com/dotcloud/docker/pkg/libcontainer/namespaces"
 )
 
 var (
@@ -40,9 +40,9 @@ func main() {
 		}
 
 		if nspid > 0 {
-			exitCode, err = nsinit.ExecIn(container, nspid, os.Args[2:])
+			exitCode, err = namespaces.ExecIn(container, nspid, os.Args[2:])
 		} else {
-			term := nsinit.NewTerminal(os.Stdin, os.Stdout, os.Stderr, container.Tty)
+			term := namespaces.NewTerminal(os.Stdin, os.Stdout, os.Stderr, container.Tty)
 			exitCode, err = startContainer(container, term, dataPath, os.Args[2:])
 		}
 
@@ -61,12 +61,12 @@ func main() {
 		if err != nil {
 			log.Fatal(err)
 		}
-		syncPipe, err := nsinit.NewSyncPipeFromFd(0, uintptr(pipeFd))
+		syncPipe, err := namespaces.NewSyncPipeFromFd(0, uintptr(pipeFd))
 		if err != nil {
 			log.Fatalf("unable to create sync pipe: %s", err)
 		}
 
-		if err := nsinit.Init(container, rootfs, console, syncPipe, os.Args[2:]); err != nil {
+		if err := namespaces.Init(container, rootfs, console, syncPipe, os.Args[2:]); err != nil {
 			log.Fatalf("unable to initialize for container: %s", err)
 		}
 	case "stats":
@@ -124,7 +124,7 @@ func readPid() (int, error) {
 // error.
 //
 // Signals sent to the current process will be forwarded to container.
-func startContainer(container *libcontainer.Container, term nsinit.Terminal, dataPath string, args []string) (int, error) {
+func startContainer(container *libcontainer.Container, term namespaces.Terminal, dataPath string, args []string) (int, error) {
 	var (
 		cmd  *exec.Cmd
 		sigc = make(chan os.Signal, 10)
@@ -133,7 +133,7 @@ func startContainer(container *libcontainer.Container, term nsinit.Terminal, dat
 	signal.Notify(sigc)
 
 	createCommand := func(container *libcontainer.Container, console, rootfs, dataPath, init string, pipe *os.File, args []string) *exec.Cmd {
-		cmd = nsinit.DefaultCreateCommand(container, console, rootfs, dataPath, init, pipe, args)
+		cmd = namespaces.DefaultCreateCommand(container, console, rootfs, dataPath, init, pipe, args)
 		return cmd
 	}
 
@@ -145,7 +145,7 @@ func startContainer(container *libcontainer.Container, term nsinit.Terminal, dat
 		}()
 	}
 
-	return nsinit.Exec(container, term, "", dataPath, args, createCommand, startCallback)
+	return namespaces.Exec(container, term, "", dataPath, args, createCommand, startCallback)
 }
 
 // returns the container stats in json format.