mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #6172 from tianon/remove-duplicated-magic-values
Move duplicated FS "magic" values to the graphdriver package so they can be shared
This commit is contained in:
commit
dccf336204
3 changed files with 14 additions and 8 deletions
|
@ -39,7 +39,10 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrAufsNotSupported = fmt.Errorf("AUFS was not found in /proc/filesystems")
|
ErrAufsNotSupported = fmt.Errorf("AUFS was not found in /proc/filesystems")
|
||||||
IncompatibleFSMagic = []int64{0x9123683E /*btrfs*/, 0x61756673 /*AUFS*/}
|
incompatibleFsMagic = []graphdriver.FsMagic{
|
||||||
|
graphdriver.FsMagicBtrfs,
|
||||||
|
graphdriver.FsMagicAufs,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -67,8 +70,8 @@ func Init(root string) (graphdriver.Driver, error) {
|
||||||
return nil, fmt.Errorf("Couldn't stat the root directory: %s", err)
|
return nil, fmt.Errorf("Couldn't stat the root directory: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, magic := range IncompatibleFSMagic {
|
for _, magic := range incompatibleFsMagic {
|
||||||
if int64(buf.Type) == magic {
|
if graphdriver.FsMagic(buf.Type) == magic {
|
||||||
return nil, graphdriver.ErrIncompatibleFS
|
return nil, graphdriver.ErrIncompatibleFS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,6 @@ import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
btrfsSuperMagic = 0x9123683E
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
graphdriver.Register("btrfs", Init)
|
graphdriver.Register("btrfs", Init)
|
||||||
}
|
}
|
||||||
|
@ -34,7 +30,7 @@ func Init(home string) (graphdriver.Driver, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if buf.Type != btrfsSuperMagic {
|
if graphdriver.FsMagic(buf.Type) != graphdriver.FsMagicBtrfs {
|
||||||
return nil, graphdriver.ErrPrerequisites
|
return nil, graphdriver.ErrPrerequisites
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,13 @@ import (
|
||||||
"path"
|
"path"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type FsMagic uint64
|
||||||
|
|
||||||
|
const (
|
||||||
|
FsMagicBtrfs = FsMagic(0x9123683E)
|
||||||
|
FsMagicAufs = FsMagic(0x61756673)
|
||||||
|
)
|
||||||
|
|
||||||
type InitFunc func(root string) (Driver, error)
|
type InitFunc func(root string) (Driver, error)
|
||||||
|
|
||||||
type Driver interface {
|
type Driver interface {
|
||||||
|
|
Loading…
Add table
Reference in a new issue