1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Rename nsinit package to namespaces in libcontainer

Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
Michael Crosby 2014-06-04 15:47:57 -07:00
parent 048833c246
commit 8aff01c0b4
12 changed files with 26 additions and 26 deletions

View file

@ -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,

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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