Skip to content

Commit

Permalink
Merge pull request #353 from shirou/fix_352
Browse files Browse the repository at this point in the history
[linux]host: change to use filepath.Join
  • Loading branch information
shirou authored Apr 30, 2017
2 parents 70693b6 + cdcb9bb commit 1f6e626
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions host/host_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,8 @@ func Virtualization() (string, string, error) {
system = "xen"
role = "guest" // assume guest

if common.PathExists(filename + "/capabilities") {
contents, err := common.ReadLines(filename + "/capabilities")
if common.PathExists(filepath.Join(filename, "capabilities")) {
contents, err := common.ReadLines(filepath.Join(filename, "capabilities"))
if err == nil {
if common.StringsContains(contents, "control_d") {
role = "host"
Expand Down Expand Up @@ -476,17 +476,17 @@ func Virtualization() (string, string, error) {
}

filename = common.HostProc()
if common.PathExists(filename + "/bc/0") {
if common.PathExists(filepath.Join(filename, "bc", "0")) {
system = "openvz"
role = "host"
} else if common.PathExists(filename + "/vz") {
} else if common.PathExists(filepath.Join(filename, "vz")) {
system = "openvz"
role = "guest"
}

// not use dmidecode because it requires root
if common.PathExists(filename + "/self/status") {
contents, err := common.ReadLines(filename + "/self/status")
if common.PathExists(filepath.Join(filename, "self", "status")) {
contents, err := common.ReadLines(filepath.Join(filename, "self", "status"))
if err == nil {

if common.StringsContains(contents, "s_context:") ||
Expand All @@ -497,8 +497,8 @@ func Virtualization() (string, string, error) {
}
}

if common.PathExists(filename + "/self/cgroup") {
contents, err := common.ReadLines(filename + "/self/cgroup")
if common.PathExists(filepath.Join(filename, "self", "cgroup")) {
contents, err := common.ReadLines(filepath.Join(filename, "self", "cgroup"))
if err == nil {
if common.StringsContains(contents, "lxc") {
system = "lxc"
Expand Down Expand Up @@ -543,7 +543,7 @@ func SensorsTemperatures() ([]TemperatureStat, error) {

for _, match := range files {
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 {
return temperatures, err
}
Expand All @@ -552,7 +552,7 @@ func SensorsTemperatures() ([]TemperatureStat, error) {
return temperatures, err
}
temperature, err := strconv.ParseFloat(string(current), 64)
if err != nil{
if err != nil {
continue
}
temperatures = append(temperatures, TemperatureStat{
Expand Down

0 comments on commit 1f6e626

Please sign in to comment.