mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Improve aufs detection by looking at proc fs
This commit is contained in:
parent
81674fbbdf
commit
043a576171
1 changed files with 22 additions and 1 deletions
23
aufs/aufs.go
23
aufs/aufs.go
|
@ -21,6 +21,7 @@ aufs driver directory structure
|
||||||
package aufs
|
package aufs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dotcloud/docker/archive"
|
"github.com/dotcloud/docker/archive"
|
||||||
"github.com/dotcloud/docker/graphdriver"
|
"github.com/dotcloud/docker/graphdriver"
|
||||||
|
@ -29,6 +30,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -43,7 +45,7 @@ type AufsDriver struct {
|
||||||
// An error is returned if AUFS is not supported.
|
// An error is returned if AUFS is not supported.
|
||||||
func Init(root string) (graphdriver.Driver, error) {
|
func Init(root string) (graphdriver.Driver, error) {
|
||||||
// Try to load the aufs kernel module
|
// Try to load the aufs kernel module
|
||||||
if err := exec.Command("modprobe", "aufs").Run(); err != nil {
|
if err := supportsAufs(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
paths := []string{
|
paths := []string{
|
||||||
|
@ -71,6 +73,25 @@ func Init(root string) (graphdriver.Driver, error) {
|
||||||
return &AufsDriver{root}, nil
|
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 {
|
func (a *AufsDriver) rootPath() string {
|
||||||
return path.Join(a.root, "aufs")
|
return path.Join(a.root, "aufs")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue