Bläddra i källkod

Add info for driver
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)

Michael Crosby 11 år sedan
förälder
incheckning
cfd188e925
3 ändrade filer med 24 tillägg och 5 borttagningar
  1. 22 3
      execdriver/namespaces/driver.go
  2. 1 1
      integration/container_test.go
  3. 1 1
      runtime.go

+ 22 - 3
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 {

+ 1 - 1
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",

+ 1 - 1
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
 	}