Skip to content

Commit

Permalink
Merge pull request #8 from crosbymichael/improve-aufs-detection
Browse files Browse the repository at this point in the history
aufs: Improve aufs detection by looking at proc fs
  • Loading branch information
Solomon Hykes committed Nov 8, 2013
2 parents 81674fb + 043a576 commit 9afe475
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion aufs/aufs.go
Expand Up @@ -21,6 +21,7 @@ aufs driver directory structure
package aufs

import (
"bufio"
"fmt"
"github.com/dotcloud/docker/archive"
"github.com/dotcloud/docker/graphdriver"
Expand All @@ -29,6 +30,7 @@ import (
"os"
"os/exec"
"path"
"strings"
)

func init() {
Expand All @@ -43,7 +45,7 @@ type AufsDriver struct {
// An error is returned if AUFS is not supported.
func Init(root string) (graphdriver.Driver, error) {
// Try to load the aufs kernel module
if err := exec.Command("modprobe", "aufs").Run(); err != nil {
if err := supportsAufs(); err != nil {
return nil, err
}
paths := []string{
Expand Down Expand Up @@ -71,6 +73,25 @@ func Init(root string) (graphdriver.Driver, error) {
return &AufsDriver{root}, nil
}

// Return a nil error if the kernel supports aufs
// We cannot modprobe because inside dind modprobe fails
// to run
func supportsAufs() error {
f, err := os.Open("/proc/filesystems")
if err != nil {
return err
}
defer f.Close()

s := bufio.NewScanner(f)
for s.Scan() {
if strings.Contains(s.Text(), "aufs") {
return nil
}
}
return fmt.Errorf("AUFS was not found in /proc/filesystems")
}

func (a *AufsDriver) rootPath() string {
return path.Join(a.root, "aufs")
}
Expand Down

0 comments on commit 9afe475

Please sign in to comment.