This commit is contained in:
Guillaume J. Charmes 2013-11-15 17:16:30 -08:00
parent cbd1281ec9
commit a518b84751
No known key found for this signature in database
GPG Key ID: B33E4642CB6E3FF3
3 changed files with 49 additions and 4 deletions

View File

@ -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 {

View File

@ -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
}

View File

@ -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
}