1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Name sure drivers are confined into their own dir

This commit is contained in:
Michael Crosby 2013-11-08 11:36:58 -08:00
parent ed18844613
commit 08a276986c
3 changed files with 11 additions and 11 deletions

View file

@ -57,8 +57,7 @@ func Init(root string) (graphdriver.Driver, error) {
// Create the root aufs driver dir and return
// if it already exists
// If not populate the dir structure
aufsPath := path.Join(root, "aufs")
if err := os.MkdirAll(aufsPath, 0755); err != nil {
if err := os.MkdirAll(root, 0755); err != nil {
if os.IsExist(err) {
return &AufsDriver{root}, nil
}
@ -66,7 +65,7 @@ func Init(root string) (graphdriver.Driver, error) {
}
for _, p := range paths {
if err := os.MkdirAll(path.Join(aufsPath, p), 0755); err != nil {
if err := os.MkdirAll(path.Join(root, p), 0755); err != nil {
return nil, err
}
}
@ -93,7 +92,7 @@ func supportsAufs() error {
}
func (a *AufsDriver) rootPath() string {
return path.Join(a.root, "aufs")
return a.root
}
func (a *AufsDriver) String() string {

View file

@ -8,7 +8,7 @@ import (
)
var (
tmp = path.Join(os.TempDir(), "aufs-tests")
tmp = path.Join(os.TempDir(), "aufs-tests", "aufs")
)
func newDriver(t *testing.T) *AufsDriver {
@ -58,7 +58,7 @@ func TestCreateDirStructure(t *testing.T) {
}
for _, p := range paths {
if _, err := os.Stat(path.Join(tmp, "aufs", p)); err != nil {
if _, err := os.Stat(path.Join(tmp, p)); err != nil {
t.Fatal(err)
}
}
@ -103,7 +103,7 @@ func TestCreateNewDirStructure(t *testing.T) {
}
for _, p := range paths {
if _, err := os.Stat(path.Join(tmp, "aufs", p, "1")); err != nil {
if _, err := os.Stat(path.Join(tmp, p, "1")); err != nil {
t.Fatal(err)
}
}
@ -128,7 +128,7 @@ func TestRemoveImage(t *testing.T) {
}
for _, p := range paths {
if _, err := os.Stat(path.Join(tmp, "aufs", p, "1")); err == nil {
if _, err := os.Stat(path.Join(tmp, p, "1")); err == nil {
t.Fatalf("Error should not be nil because dirs with id 1 should be delted: %s", p)
}
}
@ -146,7 +146,7 @@ func TestGetWithoutParent(t *testing.T) {
if err != nil {
t.Fatal(err)
}
expected := path.Join(tmp, "aufs", "diff", "1")
expected := path.Join(tmp, "diff", "1")
if diffPath != expected {
t.Fatalf("Expected path %s got %s", expected, diffPath)
}
@ -244,7 +244,7 @@ func TestMountWithParent(t *testing.T) {
t.Fatal("mntPath should not be empty string")
}
expected := path.Join(tmp, "aufs", "mnt", "2")
expected := path.Join(tmp, "mnt", "2")
if mntPath != expected {
t.Fatalf("Expected %s got %s", expected, mntPath)
}

View file

@ -5,6 +5,7 @@ import (
"github.com/dotcloud/docker/archive"
"github.com/dotcloud/docker/utils"
"os"
"path"
)
type InitFunc func(root string) (Driver, error)
@ -48,7 +49,7 @@ func Register(name string, initFunc InitFunc) error {
func getDriver(name, home string) (Driver, error) {
if initFunc, exists := drivers[name]; exists {
return initFunc(home)
return initFunc(path.Join(home, name))
}
return nil, fmt.Errorf("No such driver: %s", name)
}