From cfd188e9251f5047e4fd677fe8f2921ae28b8bcc Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Mon, 24 Feb 2014 14:11:09 -0800 Subject: [PATCH] Add info for driver Docker-DCO-1.1-Signed-off-by: Michael Crosby (github: crosbymichael) --- execdriver/namespaces/driver.go | 25 ++++++++++++++++++++++--- integration/container_test.go | 2 +- runtime.go | 2 +- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/execdriver/namespaces/driver.go b/execdriver/namespaces/driver.go index 9f153bd3eb..7dbea4c5c8 100644 --- a/execdriver/namespaces/driver.go +++ b/execdriver/namespaces/driver.go @@ -55,10 +55,26 @@ func init() { } type driver struct { + root string } -func NewDriver() (*driver, error) { - return &driver{}, nil +type info struct { + ID string + driver *driver +} + +func (i *info) IsRunning() bool { + p := filepath.Join(i.driver.root, "containers", i.ID, "rootfs", ".nspid") + if _, err := os.Stat(p); err == nil { + return true + } + return false +} + +func NewDriver(root string) (*driver, error) { + return &driver{ + root: root, + }, nil } func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallback execdriver.StartCallback) (int, error) { @@ -98,7 +114,10 @@ func (d *driver) Restore(c *execdriver.Command) error { } func (d *driver) Info(id string) execdriver.Info { - return nil + return &info{ + ID: id, + driver: d, + } } func (d *driver) Name() string { diff --git a/integration/container_test.go b/integration/container_test.go index b961e1d147..ea0283260a 100644 --- a/integration/container_test.go +++ b/integration/container_test.go @@ -1044,7 +1044,7 @@ func TestEnv(t *testing.T) { goodEnv := []string{ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "HOME=/", - "container=lxc", + "container=docker", "HOSTNAME=" + utils.TruncateID(container.ID), "FALSE=true", "TRUE=false", diff --git a/runtime.go b/runtime.go index 9f16d6213b..739cc7ee56 100644 --- a/runtime.go +++ b/runtime.go @@ -704,7 +704,7 @@ func NewRuntimeFromDirectory(config *DaemonConfig, eng *engine.Engine) (*Runtime sysInfo := sysinfo.New(false) - ed, err := namespaces.NewDriver() + ed, err := namespaces.NewDriver(config.Root) if err != nil { return nil, err }