mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Unexport reexec symbols
Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
This commit is contained in:
parent
8ebeb1da5c
commit
7d4450e647
2 changed files with 14 additions and 14 deletions
|
@ -7,14 +7,14 @@ type networkNamespace struct {
|
||||||
|
|
||||||
// Create a new network namespace mounted on the provided path.
|
// Create a new network namespace mounted on the provided path.
|
||||||
func NewNamespace(path string) (Namespace, error) {
|
func NewNamespace(path string) (Namespace, error) {
|
||||||
if err := Reexec(ReexecCreateNamespace, path); err != nil {
|
if err := reexec(reexecCreateNamespace, path); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &networkNamespace{path: path}, nil
|
return &networkNamespace{path: path}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *networkNamespace) AddInterface(i *Interface) error {
|
func (n *networkNamespace) AddInterface(i *Interface) error {
|
||||||
if err := Reexec(ReexecMoveInterface, i.SrcName, i.DstName); err != nil {
|
if err := reexec(reexecMoveInterface, i.SrcName, i.DstName); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
n.interfaces = append(n.interfaces, i)
|
n.interfaces = append(n.interfaces, i)
|
||||||
|
|
|
@ -5,38 +5,38 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/reexec"
|
dre "github.com/docker/docker/pkg/reexec"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ReexecCommand int
|
type reexecCommand int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ReexecCreateNamespace ReexecCommand = iota
|
reexecCreateNamespace reexecCommand = iota
|
||||||
ReexecMoveInterface
|
reexecMoveInterface
|
||||||
)
|
)
|
||||||
|
|
||||||
var ReexecCommands = map[ReexecCommand]struct {
|
var reexecCommands = map[reexecCommand]struct {
|
||||||
Key string
|
Key string
|
||||||
Entrypoint func()
|
Entrypoint func()
|
||||||
}{
|
}{
|
||||||
ReexecCreateNamespace: {"netns-create", createNetworkNamespace},
|
reexecCreateNamespace: {"netns-create", createNetworkNamespace},
|
||||||
ReexecMoveInterface: {"netns-moveif", namespaceMoveInterface},
|
reexecMoveInterface: {"netns-moveif", namespaceMoveInterface},
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
for _, reexecCmd := range ReexecCommands {
|
for _, reexecCmd := range reexecCommands {
|
||||||
reexec.Register(reexecCmd.Key, reexecCmd.Entrypoint)
|
dre.Register(reexecCmd.Key, reexecCmd.Entrypoint)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Reexec(command ReexecCommand, params ...string) error {
|
func reexec(command reexecCommand, params ...string) error {
|
||||||
reexecCommand, ok := ReexecCommands[command]
|
reexecCommand, ok := reexecCommands[command]
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("unknown reexec command %q", command)
|
return fmt.Errorf("unknown reexec command %q", command)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := &exec.Cmd{
|
cmd := &exec.Cmd{
|
||||||
Path: reexec.Self(),
|
Path: dre.Self(),
|
||||||
Args: append([]string{reexecCommand.Key}, params...),
|
Args: append([]string{reexecCommand.Key}, params...),
|
||||||
Stdout: os.Stdout,
|
Stdout: os.Stdout,
|
||||||
Stderr: os.Stderr,
|
Stderr: os.Stderr,
|
||||||
|
|
Loading…
Add table
Reference in a new issue