diff --git a/graphdriver/aufs/aufs.go b/graphdriver/aufs/aufs.go index c0bc069ce8..9cfaf90996 100644 --- a/graphdriver/aufs/aufs.go +++ b/graphdriver/aufs/aufs.go @@ -95,18 +95,25 @@ func supportsAufs() error { return fmt.Errorf("AUFS was not found in /proc/filesystems") } -func (a *AufsDriver) rootPath() string { +func (a AufsDriver) rootPath() string { return a.root } -func (a *AufsDriver) String() string { +func (AufsDriver) String() string { return "aufs" } -func (d *AufsDriver) Status() [][2]string { +func (AufsDriver) Status() [][2]string { return nil } +func (a AufsDriver) Exists(id string) bool { + if _, err := os.Lstat(path.Join(a.rootPath(), "diff", id)); err != nil { + return false + } + return true +} + // Three folders are created for each id // mnt, layers, and diff func (a *AufsDriver) Create(id, parent string) error { diff --git a/graphdriver/aufs/migrate.go b/graphdriver/aufs/migrate.go new file mode 100644 index 0000000000..58145aa989 --- /dev/null +++ b/graphdriver/aufs/migrate.go @@ -0,0 +1,32 @@ +package aufs + +import ( + "io/ioutil" + "os" + "path" +) + +func exists(pth string) bool { + if _, err := os.Stat(pth); err != nil { + return false + } + return true +} + +func (a *AufsDriver) Migrate(pth string) error { + fis, err := ioutil.ReadDir(pth) + if err != nil { + return err + } + for _, fi := range fis { + if fi.IsDir() && exists(path.Join(pth, fi.Name(), "layer")) && !a.Exists(fi.Name()) { + if err := os.Symlink(path.Join(pth, fi.Name(), "layer"), path.Join(a.rootPath(), "diff", fi.Name())); err != nil { + return err + } + if err := a.Create(fi.Name(), ""); err != nil { + return err + } + } + } + return nil +} diff --git a/runtime.go b/runtime.go index 8ae9b97d2e..6eef38c842 100644 --- a/runtime.go +++ b/runtime.go @@ -8,7 +8,7 @@ import ( "github.com/dotcloud/docker/archive" "github.com/dotcloud/docker/graphdb" "github.com/dotcloud/docker/graphdriver" - _ "github.com/dotcloud/docker/graphdriver/aufs" + "github.com/dotcloud/docker/graphdriver/aufs" _ "github.com/dotcloud/docker/graphdriver/devmapper" _ "github.com/dotcloud/docker/graphdriver/dummy" "github.com/dotcloud/docker/utils" @@ -629,6 +629,12 @@ func NewRuntimeFromDirectory(config *DaemonConfig) (*Runtime, error) { return nil, err } + if ad, ok := driver.(*aufs.AufsDriver); ok { + if err := ad.Migrate(path.Join(config.Root, "graph")); err != nil { + return nil, err + } + } + if err := linkLxcStart(config.Root); err != nil { return nil, err }