Browse code

Move duplicated FS "magic" values to the graphdriver package so they can be shared instead of duplicated

Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)

Tianon Gravi authored on 2014/06/03 10:26:41
Showing 3 changed files
... ...
@@ -39,7 +39,10 @@ import (
39 39
 
40 40
 var (
41 41
 	ErrAufsNotSupported = fmt.Errorf("AUFS was not found in /proc/filesystems")
42
-	IncompatibleFSMagic = []int64{0x9123683E /*btrfs*/, 0x61756673 /*AUFS*/}
42
+	incompatibleFsMagic = []graphdriver.FsMagic{
43
+		graphdriver.FsMagicBtrfs,
44
+		graphdriver.FsMagicAufs,
45
+	}
43 46
 )
44 47
 
45 48
 func init() {
... ...
@@ -67,8 +70,8 @@ func Init(root string) (graphdriver.Driver, error) {
67 67
 		return nil, fmt.Errorf("Couldn't stat the root directory: %s", err)
68 68
 	}
69 69
 
70
-	for _, magic := range IncompatibleFSMagic {
71
-		if int64(buf.Type) == magic {
70
+	for _, magic := range incompatibleFsMagic {
71
+		if graphdriver.FsMagic(buf.Type) == magic {
72 72
 			return nil, graphdriver.ErrIncompatibleFS
73 73
 		}
74 74
 	}
... ...
@@ -18,10 +18,6 @@ import (
18 18
 	"unsafe"
19 19
 )
20 20
 
21
-const (
22
-	btrfsSuperMagic = 0x9123683E
23
-)
24
-
25 21
 func init() {
26 22
 	graphdriver.Register("btrfs", Init)
27 23
 }
... ...
@@ -34,7 +30,7 @@ func Init(home string) (graphdriver.Driver, error) {
34 34
 		return nil, err
35 35
 	}
36 36
 
37
-	if buf.Type != btrfsSuperMagic {
37
+	if graphdriver.FsMagic(buf.Type) != graphdriver.FsMagicBtrfs {
38 38
 		return nil, graphdriver.ErrPrerequisites
39 39
 	}
40 40
 
... ...
@@ -8,6 +8,13 @@ import (
8 8
 	"path"
9 9
 )
10 10
 
11
+type FsMagic uint64
12
+
13
+const (
14
+	FsMagicBtrfs = FsMagic(0x9123683E)
15
+	FsMagicAufs  = FsMagic(0x61756673)
16
+)
17
+
11 18
 type InitFunc func(root string) (Driver, error)
12 19
 
13 20
 type Driver interface {