Merge pull request #6109 from unclejack/block_aufs_on_top_of_btrfs
block aufs on incompatible file systems
This commit is contained in:
commit
107cd5dd5f
|
@ -23,20 +23,23 @@ package aufs
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dotcloud/docker/archive"
|
|
||||||
"github.com/dotcloud/docker/daemon/graphdriver"
|
|
||||||
"github.com/dotcloud/docker/pkg/label"
|
|
||||||
mountpk "github.com/dotcloud/docker/pkg/mount"
|
|
||||||
"github.com/dotcloud/docker/utils"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
|
"github.com/dotcloud/docker/archive"
|
||||||
|
"github.com/dotcloud/docker/daemon/graphdriver"
|
||||||
|
"github.com/dotcloud/docker/pkg/label"
|
||||||
|
mountpk "github.com/dotcloud/docker/pkg/mount"
|
||||||
|
"github.com/dotcloud/docker/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
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*/}
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -56,6 +59,20 @@ func Init(root string) (graphdriver.Driver, error) {
|
||||||
if err := supportsAufs(); err != nil {
|
if err := supportsAufs(); err != nil {
|
||||||
return nil, graphdriver.ErrNotSupported
|
return nil, graphdriver.ErrNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rootdir := path.Dir(root)
|
||||||
|
|
||||||
|
var buf syscall.Statfs_t
|
||||||
|
if err := syscall.Statfs(rootdir, &buf); err != nil {
|
||||||
|
return nil, fmt.Errorf("Couldn't stat the root directory: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, magic := range IncompatibleFSMagic {
|
||||||
|
if int64(buf.Type) == magic {
|
||||||
|
return nil, graphdriver.ErrIncompatibleFS
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
paths := []string{
|
paths := []string{
|
||||||
"mnt",
|
"mnt",
|
||||||
"diff",
|
"diff",
|
||||||
|
|
|
@ -45,7 +45,8 @@ var (
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrNotSupported = errors.New("driver not supported")
|
ErrNotSupported = errors.New("driver not supported")
|
||||||
ErrPrerequisites = errors.New("Prerequisites for driver not satisfied (wrong filesystem?)")
|
ErrPrerequisites = errors.New("prerequisites for driver not satisfied (wrong filesystem?)")
|
||||||
|
ErrIncompatibleFS = fmt.Errorf("backing file system is unsupported for this graph driver")
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -79,7 +80,7 @@ func New(root string) (driver Driver, err error) {
|
||||||
for _, name := range priority {
|
for _, name := range priority {
|
||||||
driver, err = GetDriver(name, root)
|
driver, err = GetDriver(name, root)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == ErrNotSupported || err == ErrPrerequisites {
|
if err == ErrNotSupported || err == ErrPrerequisites || err == ErrIncompatibleFS {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -90,7 +91,7 @@ func New(root string) (driver Driver, err error) {
|
||||||
// Check all registered drivers if no priority driver is found
|
// Check all registered drivers if no priority driver is found
|
||||||
for _, initFunc := range drivers {
|
for _, initFunc := range drivers {
|
||||||
if driver, err = initFunc(root); err != nil {
|
if driver, err = initFunc(root); err != nil {
|
||||||
if err == ErrNotSupported || err == ErrPrerequisites {
|
if err == ErrNotSupported || err == ErrPrerequisites || err == ErrIncompatibleFS {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in New Issue