Use fewer modprobes

Signed-off-by: Danny Milosavljevic <dannym@scratchpost.org>
(cherry picked from commit 074eca1d79)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
Danny Milosavljevic 2019-07-31 13:04:03 +02:00 committed by Akihiro Suda
parent d3dab1f618
commit 5e4574526d
3 changed files with 26 additions and 10 deletions

View File

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

View File

@ -8,7 +8,6 @@ import (
"io"
"io/ioutil"
"os"
"os/exec"
"path"
"path/filepath"
"strconv"
@ -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 {

View File

@ -10,7 +10,6 @@ import (
"io"
"io/ioutil"
"os"
"os/exec"
"path"
"path/filepath"
"strconv"
@ -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 {