Exit gracefully from mount when linux host does not support file system 9p.
parent
8b33d22c5a
commit
2faab769ec
|
@ -186,6 +186,11 @@ var mountCmd = &cobra.Command{
|
|||
cfg.Options[parts[0]] = parts[1]
|
||||
}
|
||||
|
||||
if runtime.GOOS == "linux" && !detect.IsNinePSupported() {
|
||||
exit.Message(reason.HostUnsupported, "The host does not support filesystem 9p.")
|
||||
|
||||
}
|
||||
|
||||
// An escape valve to allow future hackers to try NFS, VirtFS, or other FS types.
|
||||
if !supportedFilesystems[cfg.Type] {
|
||||
out.WarningT("{{.type}} is not yet a supported filesystem. We will try anyways!", out.V{"type": cfg.Type})
|
||||
|
|
|
@ -19,6 +19,8 @@ limitations under the License.
|
|||
package detect
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
|
@ -54,3 +56,30 @@ func cgroupVersion() string {
|
|||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func IsNinePSupported() bool {
|
||||
// assume true from non-linux
|
||||
if runtime.GOOS != "linux" {
|
||||
return true
|
||||
}
|
||||
_, err := os.Stat(getModuleRoot() + "/kernel/fs/9p")
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func getModuleRoot() string {
|
||||
// assume true from non-linux
|
||||
if runtime.GOOS != "linux" {
|
||||
return ""
|
||||
}
|
||||
uname := unix.Utsname{}
|
||||
if err := unix.Uname(&uname); err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
i := 0
|
||||
for ; uname.Release[i] != 0; i++ {
|
||||
continue
|
||||
}
|
||||
return filepath.Join("/lib/modules", string(uname.Release[:i]))
|
||||
|
||||
}
|
||||
|
|
|
@ -22,3 +22,8 @@ package detect
|
|||
func cgroupVersion() string {
|
||||
return "v1"
|
||||
}
|
||||
|
||||
// Assume 9p is supported by non linux apps
|
||||
func IsNinePSupported() bool {
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -288,6 +288,8 @@ var (
|
|||
HostPurge = Kind{ID: "HOST_PURGE", ExitCode: ExHostError}
|
||||
// minikube failed to persist profile config
|
||||
HostSaveProfile = Kind{ID: "HOST_SAVE_PROFILE", ExitCode: ExHostConfig}
|
||||
// Host doesn't support 9p
|
||||
HostUnsupported = Kind{ID: "HOST_UNSUPPORTED", ExitCode: ExHostUnsupported}
|
||||
|
||||
// minikube could not find a provider for the selected driver
|
||||
ProviderNotFound = Kind{ID: "PROVIDER_NOT_FOUND", ExitCode: ExProviderNotFound}
|
||||
|
|
Loading…
Reference in New Issue