Skip to content

Commit

Permalink
Added additonal checks for 9p support
Browse files Browse the repository at this point in the history
  • Loading branch information
xcarolan committed Jan 18, 2025
1 parent d3804e6 commit ced131f
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions pkg/minikube/detect/detect_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ package detect

import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"

"golang.org/x/sys/unix"
)
Expand Down Expand Up @@ -62,8 +64,29 @@ func IsNinePSupported() bool {
if runtime.GOOS != "linux" {
return true
}
_, err := os.Stat(getModuleRoot() + "/kernel/fs/9p")
return err == nil

if _, err := os.Stat(getModuleRoot() + "/kernel/fs/9p"); err == nil {
return true
}
// Try modprobe check (silent)
cmd := exec.Command("modprobe", "-q", "9p")
if err := cmd.Run(); err == nil {
return true
}
// Check if module is already loaded
loaded, err := is9PModuleLoaded()
if err == nil && loaded {
return true
}
return false
}
func is9PModuleLoaded() (bool, error) {
cmd := exec.Command("lsmod")
out, err := cmd.Output()
if err != nil {
return false, err
}
return strings.Contains(string(out), "9p"), nil
}

func getModuleRoot() string {
Expand Down

0 comments on commit ced131f

Please sign in to comment.