diff --git a/nsinit/exec.go b/nsinit/exec.go index 4ac070db..5b53be25 100644 --- a/nsinit/exec.go +++ b/nsinit/exec.go @@ -1,3 +1,5 @@ +// +build linux + package main import ( diff --git a/nsinit/init.go b/nsinit/init.go index 16a30812..1c90ecca 100644 --- a/nsinit/init.go +++ b/nsinit/init.go @@ -1,3 +1,5 @@ +// +build linux + package main import ( diff --git a/nsinit/main.go b/nsinit/main.go index 47abcce0..c9f9d7bc 100644 --- a/nsinit/main.go +++ b/nsinit/main.go @@ -2,17 +2,27 @@ package main import ( "encoding/json" + "errors" "github.com/dotcloud/docker/pkg/libcontainer" "log" "os" ) +var ( + ErrUnsupported = errors.New("Unsupported method") + ErrWrongArguments = errors.New("Wrong argument count") +) + func main() { container, err := loadContainer() if err != nil { log.Fatal(err) } + argc := len(os.Args) + if argc < 2 { + log.Fatal(ErrWrongArguments) + } switch os.Args[1] { case "exec": exitCode, err := execCommand(container) @@ -21,6 +31,9 @@ func main() { } os.Exit(exitCode) case "init": + if argc != 3 { + log.Fatal(ErrWrongArguments) + } if err := initCommand(container, os.Args[2]); err != nil { log.Fatal(err) } diff --git a/nsinit/mount.go b/nsinit/mount.go index 13ee13e0..baa850f0 100644 --- a/nsinit/mount.go +++ b/nsinit/mount.go @@ -1,3 +1,5 @@ +// +build linux + package main import (