Browse code

Windows: Allow VFS

Signed-off-by: John Howard <jhoward@microsoft.com>

John Howard authored on 2015/05/27 04:45:08
Showing 3 changed files
... ...
@@ -4,6 +4,7 @@ import (
4 4
 	"fmt"
5 5
 	"os"
6 6
 	"path"
7
+	"runtime"
7 8
 
8 9
 	"github.com/Sirupsen/logrus"
9 10
 )
... ...
@@ -112,9 +113,12 @@ func (daemon *Daemon) rm(container *Container, forceRemove bool) (err error) {
112 112
 		return fmt.Errorf("Driver %s failed to remove root filesystem %s: %s", daemon.driver, container.ID, err)
113 113
 	}
114 114
 
115
-	initID := fmt.Sprintf("%s-init", container.ID)
116
-	if err := daemon.driver.Remove(initID); err != nil {
117
-		return fmt.Errorf("Driver %s failed to remove init filesystem %s: %s", daemon.driver, initID, err)
115
+	// There will not be an -init on Windows, so don't fail by not attempting to delete it
116
+	if runtime.GOOS != "windows" {
117
+		initID := fmt.Sprintf("%s-init", container.ID)
118
+		if err := daemon.driver.Remove(initID); err != nil {
119
+			return fmt.Errorf("Driver %s failed to remove init filesystem %s: %s", daemon.driver, initID, err)
120
+		}
118 121
 	}
119 122
 
120 123
 	if err = os.RemoveAll(container.root); err != nil {
... ...
@@ -1,26 +1,25 @@
1 1
 package graphdriver
2 2
 
3
+import (
4
+	_ "github.com/docker/docker/daemon/graphdriver/vfs"
5
+
6
+	// TODO Windows - Add references to real graph driver when PR'd
7
+)
8
+
3 9
 type DiffDiskDriver interface {
4 10
 	Driver
5 11
 	CopyDiff(id, sourceId string) error
6 12
 }
7 13
 
8
-const (
9
-	FsMagicWindows = FsMagic(0xa1b1830f)
10
-)
11
-
12 14
 var (
13
-	// Slice of drivers that should be used in an order
15
+	// Slice of drivers that should be used in order
14 16
 	priority = []string{
15 17
 		"windows",
16
-	}
17
-
18
-	FsNames = map[FsMagic]string{
19
-		FsMagicWindows:     "windows",
20
-		FsMagicUnsupported: "unsupported",
18
+		"vfs",
21 19
 	}
22 20
 )
23 21
 
24 22
 func GetFSMagic(rootpath string) (FsMagic, error) {
25
-	return FsMagicWindows, nil
23
+	// Note it is OK to return FsMagicUnsupported on Windows.
24
+	return FsMagicUnsupported, nil
26 25
 }
... ...
@@ -5,7 +5,7 @@ package vfs
5 5
 import (
6 6
 	"fmt"
7 7
 	"os"
8
-	"path"
8
+	"path/filepath"
9 9
 
10 10
 	"github.com/docker/docker/daemon/graphdriver"
11 11
 	"github.com/docker/docker/pkg/chrootarchive"
... ...
@@ -42,7 +42,7 @@ func (d *Driver) Cleanup() error {
42 42
 
43 43
 func (d *Driver) Create(id, parent string) error {
44 44
 	dir := d.dir(id)
45
-	if err := system.MkdirAll(path.Dir(dir), 0700); err != nil {
45
+	if err := system.MkdirAll(filepath.Dir(dir), 0700); err != nil {
46 46
 		return err
47 47
 	}
48 48
 	if err := os.Mkdir(dir, 0755); err != nil {
... ...
@@ -66,7 +66,7 @@ func (d *Driver) Create(id, parent string) error {
66 66
 }
67 67
 
68 68
 func (d *Driver) dir(id string) string {
69
-	return path.Join(d.home, "dir", path.Base(id))
69
+	return filepath.Join(d.home, "dir", filepath.Base(id))
70 70
 }
71 71
 
72 72
 func (d *Driver) Remove(id string) error {