[linux]host: change to use filepath.Join

pull/353/head
WAKAYAMA Shirou 8 years ago
parent 70693b6a3d
commit 25d50d5bc3

@ -432,8 +432,8 @@ func Virtualization() (string, string, error) {
system = "xen" system = "xen"
role = "guest" // assume guest role = "guest" // assume guest
if common.PathExists(filename + "/capabilities") { if common.PathExists(filepath.Join(filename, "capabilities")) {
contents, err := common.ReadLines(filename + "/capabilities") contents, err := common.ReadLines(filepath.Join(filename, "capabilities"))
if err == nil { if err == nil {
if common.StringsContains(contents, "control_d") { if common.StringsContains(contents, "control_d") {
role = "host" role = "host"
@ -476,17 +476,17 @@ func Virtualization() (string, string, error) {
} }
filename = common.HostProc() filename = common.HostProc()
if common.PathExists(filename + "/bc/0") { if common.PathExists(filepath.Join(filename, "bc", "0")) {
system = "openvz" system = "openvz"
role = "host" role = "host"
} else if common.PathExists(filename + "/vz") { } else if common.PathExists(filepath.Join(filename, "vz")) {
system = "openvz" system = "openvz"
role = "guest" role = "guest"
} }
// not use dmidecode because it requires root // not use dmidecode because it requires root
if common.PathExists(filename + "/self/status") { if common.PathExists(filpath.Join(filename, "self", "status")) {
contents, err := common.ReadLines(filename + "/self/status") contents, err := common.ReadLines(filepath.Join(filename, "self", "status"))
if err == nil { if err == nil {
if common.StringsContains(contents, "s_context:") || if common.StringsContains(contents, "s_context:") ||
@ -497,8 +497,8 @@ func Virtualization() (string, string, error) {
} }
} }
if common.PathExists(filename + "/self/cgroup") { if common.PathExists(filepath.Join(filename, "self", "cgroup")) {
contents, err := common.ReadLines(filename + "/self/cgroup") contents, err := common.ReadLines(filepath.Join(filename, "self", "cgroup"))
if err == nil { if err == nil {
if common.StringsContains(contents, "lxc") { if common.StringsContains(contents, "lxc") {
system = "lxc" system = "lxc"
@ -543,7 +543,7 @@ func SensorsTemperatures() ([]TemperatureStat, error) {
for _, match := range files { for _, match := range files {
match = strings.Split(match, "_")[0] match = strings.Split(match, "_")[0]
name, err := ioutil.ReadFile(filepath.Dir(match) + "name") name, err := ioutil.ReadFile(filepath.Join(filepath.Dir(match), "name"))
if err != nil { if err != nil {
return temperatures, err return temperatures, err
} }
@ -552,7 +552,7 @@ func SensorsTemperatures() ([]TemperatureStat, error) {
return temperatures, err return temperatures, err
} }
temperature, err := strconv.ParseFloat(string(current), 64) temperature, err := strconv.ParseFloat(string(current), 64)
if err != nil{ if err != nil {
continue continue
} }
temperatures = append(temperatures, TemperatureStat{ temperatures = append(temperatures, TemperatureStat{

Loading…
Cancel
Save