Skip to content

Commit

Permalink
Merge pull request #4108 from BOINC/dpa_linux_version
Browse files Browse the repository at this point in the history
Scheduler, XML plan class spec: parse Linux version correctly
  • Loading branch information
AenBleidd authored Jan 11, 2021
2 parents 9caf3df + da680f6 commit 62662a0
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions sched/plan_class_spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,35 @@ static double os_version_num(HOST h) {
if (p && (sscanf(p, "(%u.%u.%u.%u)", &a, &b, &c, &d) == 4)) {
return 100000000.0*a + 1000000.0*b + 100.0*c +d;
}
} else if (strstr(h.os_name, "Android") || strstr(h.os_name, "Linux")) {
// example: 3.0.31-g6fb96c9
} else if (strstr(h.os_name, "Android")) {
// examples:
// 3.0.31-g6fb96c9
// 2.6.36.3
// 3.4.0
//
if (sscanf(h.os_version, "%u.%u.%u", &a, &b, &c) == 3) {
return 10000.*a + 100.*b + c;
}
} else if (strstr(h.os_name, "Linux")) {
// os_name seems to always contain "Linux".
// os_version is pretty diverse:
//
// Linux Mint 19 Tara [4.18.12-041812-generic|libc 2.27 (Ubuntu GLIBC 2.27-3ubuntu1)]
// CentOS Linux 7 (Core) [3.10.0-862.14.4.el7.x86_64|libc 2.17 (GNU libc)]
// Ubuntu 18.04.1 LTS [4.15.0-36-generic|libc 2.27 (Ubuntu GLIBC 2.27-3ubuntu1)]
// 3.13.0-103-generic
// 4.9.0-8-amd64
// Manjaro Linux [4.19.42-1-MANJARO|libc 2.29 (GNU libc)]

char* p = strchr(h.os_version, '[');
if (p) {
p++;
} else {
p = h.os_version;
}
if (sscanf(p, "%u.%u.%u", &a, &b, &c) == 3) {
return 10000.*a + 100.*b + c;
}
}
// could not determine numerical OS version
//
Expand Down

0 comments on commit 62662a0

Please sign in to comment.