Skip to content

Commit

Permalink
Merge pull request moby#38930 from daym/fewer-modprobes
Browse files Browse the repository at this point in the history
Use fewer modprobes
  • Loading branch information
AkihiroSuda authored Sep 23, 2019
2 parents 1dd9260 + 074eca1 commit 610551e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
10 changes: 8 additions & 2 deletions daemon/graphdriver/devmapper/deviceset.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,14 @@ func xfsSupported() error {
return err // error text is descriptive enough
}

// Check if kernel supports xfs filesystem or not.
exec.Command("modprobe", "xfs").Run()
mountTarget, err := ioutil.TempDir("", "supportsXFS")
if err != nil {
return errors.Wrapf(err, "error checking for xfs support")
}

/* The mounting will fail--after the module has been loaded.*/
defer os.RemoveAll(mountTarget)
unix.Mount("none", mountTarget, "xfs", 0, "")

f, err := os.Open("/proc/filesystems")
if err != nil {
Expand Down
13 changes: 9 additions & 4 deletions daemon/graphdriver/overlay/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"io"
"io/ioutil"
"os"
"os/exec"
"path"
"path/filepath"
"strconv"
Expand Down Expand Up @@ -201,9 +200,15 @@ func parseOptions(options []string) (*overlayOptions, error) {
}

func supportsOverlay() error {
// We can try to modprobe overlay first before looking at
// proc/filesystems for when overlay is supported
exec.Command("modprobe", "overlay").Run()
// Access overlay filesystem so that Linux loads it (if possible).
mountTarget, err := ioutil.TempDir("", "supportsOverlay")
if err != nil {
logrus.WithError(err).WithField("storage-driver", "overlay2").Error("could not create temporary directory, so assuming that 'overlay' is not supported")
return graphdriver.ErrNotSupported
}
/* The mounting will fail--after the module has been loaded.*/
defer os.RemoveAll(mountTarget)
unix.Mount("overlay", mountTarget, "overlay", 0, "")

f, err := os.Open("/proc/filesystems")
if err != nil {
Expand Down
13 changes: 9 additions & 4 deletions daemon/graphdriver/overlay2/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"io"
"io/ioutil"
"os"
"os/exec"
"path"
"path/filepath"
"strconv"
Expand Down Expand Up @@ -276,9 +275,15 @@ func parseOptions(options []string) (*overlayOptions, error) {
}

func supportsOverlay() error {
// We can try to modprobe overlay first before looking at
// proc/filesystems for when overlay is supported
exec.Command("modprobe", "overlay").Run()
// Access overlay filesystem so that Linux loads it (if possible).
mountTarget, err := ioutil.TempDir("", "supportsOverlay2")
if err != nil {
logrus.WithError(err).WithField("storage-driver", "overlay2").Error("could not create temporary directory, so assuming that 'overlay' is not supported")
return graphdriver.ErrNotSupported
}
/* The mounting will fail--after the module has been loaded.*/
defer os.RemoveAll(mountTarget)
unix.Mount("overlay", mountTarget, "overlay", 0, "")

f, err := os.Open("/proc/filesystems")
if err != nil {
Expand Down

0 comments on commit 610551e

Please sign in to comment.