Browse Source

Windows: Allow VFS

Signed-off-by: John Howard <jhoward@microsoft.com>
John Howard 10 years ago
parent
commit
e89f837bc6
3 changed files with 20 additions and 17 deletions
  1. 7 3
      daemon/delete.go
  2. 10 11
      daemon/graphdriver/driver_windows.go
  3. 3 3
      daemon/graphdriver/vfs/driver.go

+ 7 - 3
daemon/delete.go

@@ -4,6 +4,7 @@ import (
 	"fmt"
 	"fmt"
 	"os"
 	"os"
 	"path"
 	"path"
+	"runtime"
 
 
 	"github.com/Sirupsen/logrus"
 	"github.com/Sirupsen/logrus"
 )
 )
@@ -112,9 +113,12 @@ func (daemon *Daemon) rm(container *Container, forceRemove bool) (err error) {
 		return fmt.Errorf("Driver %s failed to remove root filesystem %s: %s", daemon.driver, container.ID, err)
 		return fmt.Errorf("Driver %s failed to remove root filesystem %s: %s", daemon.driver, container.ID, err)
 	}
 	}
 
 
-	initID := fmt.Sprintf("%s-init", container.ID)
-	if err := daemon.driver.Remove(initID); err != nil {
-		return fmt.Errorf("Driver %s failed to remove init filesystem %s: %s", daemon.driver, initID, err)
+	// There will not be an -init on Windows, so don't fail by not attempting to delete it
+	if runtime.GOOS != "windows" {
+		initID := fmt.Sprintf("%s-init", container.ID)
+		if err := daemon.driver.Remove(initID); err != nil {
+			return fmt.Errorf("Driver %s failed to remove init filesystem %s: %s", daemon.driver, initID, err)
+		}
 	}
 	}
 
 
 	if err = os.RemoveAll(container.root); err != nil {
 	if err = os.RemoveAll(container.root); err != nil {

+ 10 - 11
daemon/graphdriver/driver_windows.go

@@ -1,26 +1,25 @@
 package graphdriver
 package graphdriver
 
 
+import (
+	_ "github.com/docker/docker/daemon/graphdriver/vfs"
+
+	// TODO Windows - Add references to real graph driver when PR'd
+)
+
 type DiffDiskDriver interface {
 type DiffDiskDriver interface {
 	Driver
 	Driver
 	CopyDiff(id, sourceId string) error
 	CopyDiff(id, sourceId string) error
 }
 }
 
 
-const (
-	FsMagicWindows = FsMagic(0xa1b1830f)
-)
-
 var (
 var (
-	// Slice of drivers that should be used in an order
+	// Slice of drivers that should be used in order
 	priority = []string{
 	priority = []string{
 		"windows",
 		"windows",
-	}
-
-	FsNames = map[FsMagic]string{
-		FsMagicWindows:     "windows",
-		FsMagicUnsupported: "unsupported",
+		"vfs",
 	}
 	}
 )
 )
 
 
 func GetFSMagic(rootpath string) (FsMagic, error) {
 func GetFSMagic(rootpath string) (FsMagic, error) {
-	return FsMagicWindows, nil
+	// Note it is OK to return FsMagicUnsupported on Windows.
+	return FsMagicUnsupported, nil
 }
 }

+ 3 - 3
daemon/graphdriver/vfs/driver.go

@@ -5,7 +5,7 @@ package vfs
 import (
 import (
 	"fmt"
 	"fmt"
 	"os"
 	"os"
-	"path"
+	"path/filepath"
 
 
 	"github.com/docker/docker/daemon/graphdriver"
 	"github.com/docker/docker/daemon/graphdriver"
 	"github.com/docker/docker/pkg/chrootarchive"
 	"github.com/docker/docker/pkg/chrootarchive"
@@ -42,7 +42,7 @@ func (d *Driver) Cleanup() error {
 
 
 func (d *Driver) Create(id, parent string) error {
 func (d *Driver) Create(id, parent string) error {
 	dir := d.dir(id)
 	dir := d.dir(id)
-	if err := system.MkdirAll(path.Dir(dir), 0700); err != nil {
+	if err := system.MkdirAll(filepath.Dir(dir), 0700); err != nil {
 		return err
 		return err
 	}
 	}
 	if err := os.Mkdir(dir, 0755); err != nil {
 	if err := os.Mkdir(dir, 0755); err != nil {
@@ -66,7 +66,7 @@ func (d *Driver) Create(id, parent string) error {
 }
 }
 
 
 func (d *Driver) dir(id string) string {
 func (d *Driver) dir(id string) string {
-	return path.Join(d.home, "dir", path.Base(id))
+	return filepath.Join(d.home, "dir", filepath.Base(id))
 }
 }
 
 
 func (d *Driver) Remove(id string) error {
 func (d *Driver) Remove(id string) error {