From b48bc85967d473743192951d3e9ed2f85bf5c0a2 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Wed, 19 Feb 2014 16:50:10 -0800 Subject: [PATCH] OSX compilation Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes (github: creack) --- libcontainer/nsinit/exec.go | 2 ++ libcontainer/nsinit/init.go | 2 ++ libcontainer/nsinit/main.go | 13 +++++++++++++ libcontainer/nsinit/mount.go | 2 ++ 4 files changed, 19 insertions(+) diff --git a/libcontainer/nsinit/exec.go b/libcontainer/nsinit/exec.go index 4ac070d..5b53be2 100644 --- a/libcontainer/nsinit/exec.go +++ b/libcontainer/nsinit/exec.go @@ -1,3 +1,5 @@ +// +build linux + package main import ( diff --git a/libcontainer/nsinit/init.go b/libcontainer/nsinit/init.go index 16a3081..1c90ecc 100644 --- a/libcontainer/nsinit/init.go +++ b/libcontainer/nsinit/init.go @@ -1,3 +1,5 @@ +// +build linux + package main import ( diff --git a/libcontainer/nsinit/main.go b/libcontainer/nsinit/main.go index 47abcce..c9f9d7b 100644 --- a/libcontainer/nsinit/main.go +++ b/libcontainer/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/libcontainer/nsinit/mount.go b/libcontainer/nsinit/mount.go index 13ee13e..baa850f 100644 --- a/libcontainer/nsinit/mount.go +++ b/libcontainer/nsinit/mount.go @@ -1,3 +1,5 @@ +// +build linux + package main import (