Merge pull request #6109 from unclejack/block_aufs_on_top_of_btrfs

block aufs on incompatible file systems
This commit is contained in:
Michael Crosby 2014-05-29 16:58:30 -07:00
commit 107cd5dd5f
2 changed files with 27 additions and 9 deletions

View File

@ -23,20 +23,23 @@ package aufs
import (
"bufio"
"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/exec"
"path"
"strings"
"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 (
ErrAufsNotSupported = fmt.Errorf("AUFS was not found in /proc/filesystems")
IncompatibleFSMagic = []int64{0x9123683E /*btrfs*/, 0x61756673 /*AUFS*/}
)
func init() {
@ -56,6 +59,20 @@ func Init(root string) (graphdriver.Driver, error) {
if err := supportsAufs(); err != nil {
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{
"mnt",
"diff",

View File

@ -44,8 +44,9 @@ var (
"vfs",
}
ErrNotSupported = errors.New("driver not supported")
ErrPrerequisites = errors.New("Prerequisites for driver not satisfied (wrong filesystem?)")
ErrNotSupported = errors.New("driver not supported")
ErrPrerequisites = errors.New("prerequisites for driver not satisfied (wrong filesystem?)")
ErrIncompatibleFS = fmt.Errorf("backing file system is unsupported for this graph driver")
)
func init() {
@ -79,7 +80,7 @@ func New(root string) (driver Driver, err error) {
for _, name := range priority {
driver, err = GetDriver(name, root)
if err != nil {
if err == ErrNotSupported || err == ErrPrerequisites {
if err == ErrNotSupported || err == ErrPrerequisites || err == ErrIncompatibleFS {
continue
}
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
for _, initFunc := range drivers {
if driver, err = initFunc(root); err != nil {
if err == ErrNotSupported || err == ErrPrerequisites {
if err == ErrNotSupported || err == ErrPrerequisites || err == ErrIncompatibleFS {
continue
}
return nil, err