mirror of
https://github.com/rancher/os.git
synced 2025-08-31 22:32:14 +00:00
isolate and mark platform dependent code
now unit tests compile on OS X and (some of them) work
This commit is contained in:
32
util/util.go
32
util/util.go
@@ -12,7 +12,6 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
@@ -44,37 +43,6 @@ func GetOSType() string {
|
||||
|
||||
}
|
||||
|
||||
func mountProc() error {
|
||||
if _, err := os.Stat("/proc/self/mountinfo"); os.IsNotExist(err) {
|
||||
if _, err := os.Stat("/proc"); os.IsNotExist(err) {
|
||||
if err = os.Mkdir("/proc", 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if err := syscall.Mount("none", "/proc", "proc", 0, ""); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Mount(device, directory, fsType, options string) error {
|
||||
if err := mountProc(); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if _, err := os.Stat(directory); os.IsNotExist(err) {
|
||||
err = os.MkdirAll(directory, 0755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return mount.Mount(device, directory, fsType, options)
|
||||
}
|
||||
|
||||
func Remount(directory, options string) error {
|
||||
return mount.Mount("", directory, "", fmt.Sprintf("remount,%s", options))
|
||||
}
|
||||
|
Reference in New Issue
Block a user