Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit 806947e

Browse files
Danny MilosavljevicAkihiroSuda
authored andcommitted
Use fewer modprobes
Signed-off-by: Danny Milosavljevic <dannym@scratchpost.org> (cherry picked from commit 074eca1d796d0863a8c71d4707f6d8767fd19fa9) Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp> Upstream-commit: 5e4574526d4a38d897e76407dc291d366ed15b33 Component: engine
1 parent 6e493ff commit 806947e

3 files changed

Lines changed: 26 additions & 10 deletions

File tree

components/engine/daemon/graphdriver/devmapper/deviceset.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,14 @@ func xfsSupported() error {
540540
return err // error text is descriptive enough
541541
}
542542

543-
// Check if kernel supports xfs filesystem or not.
544-
exec.Command("modprobe", "xfs").Run()
543+
mountTarget, err := ioutil.TempDir("", "supportsXFS")
544+
if err != nil {
545+
return errors.Wrapf(err, "error checking for xfs support")
546+
}
547+
548+
/* The mounting will fail--after the module has been loaded.*/
549+
defer os.RemoveAll(mountTarget)
550+
unix.Mount("none", mountTarget, "xfs", 0, "")
545551

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

components/engine/daemon/graphdriver/overlay/overlay.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"io"
99
"io/ioutil"
1010
"os"
11-
"os/exec"
1211
"path"
1312
"path/filepath"
1413
"strconv"
@@ -201,9 +200,15 @@ func parseOptions(options []string) (*overlayOptions, error) {
201200
}
202201

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

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

components/engine/daemon/graphdriver/overlay2/overlay.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"io"
1111
"io/ioutil"
1212
"os"
13-
"os/exec"
1413
"path"
1514
"path/filepath"
1615
"strconv"
@@ -276,9 +275,15 @@ func parseOptions(options []string) (*overlayOptions, error) {
276275
}
277276

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

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

0 commit comments

Comments
 (0)