linux: handle UNAME26 personality (#4109)
This commit is contained in:
parent
55376b044b
commit
30c3ef9f6f
@ -328,6 +328,31 @@ unsigned uv__kernel_version(void) {
|
||||
if (3 != sscanf(u.release, "%u.%u.%u", &major, &minor, &patch))
|
||||
return 0;
|
||||
|
||||
/* Handle it when the process runs under the UNAME26 personality:
|
||||
*
|
||||
* - kernels >= 3.x identify as 2.6.40+x
|
||||
* - kernels >= 4.x identify as 2.6.60+x
|
||||
*
|
||||
* UNAME26 is a poorly conceived hack that doesn't let us distinguish
|
||||
* between 4.x kernels and 5.x/6.x kernels so we conservatively assume
|
||||
* that 2.6.60+x means 4.x.
|
||||
*
|
||||
* Fun fact of the day: it's technically possible to observe the actual
|
||||
* kernel version for a brief moment because uname() first copies out the
|
||||
* real release string before overwriting it with the backcompat string.
|
||||
*/
|
||||
if (major == 2 && minor == 6) {
|
||||
if (patch >= 60) {
|
||||
major = 4;
|
||||
minor = patch - 60;
|
||||
patch = 0;
|
||||
} else if (patch >= 40) {
|
||||
major = 3;
|
||||
minor = patch - 40;
|
||||
patch = 0;
|
||||
}
|
||||
}
|
||||
|
||||
version = major * 65536 + minor * 256 + patch;
|
||||
atomic_store_explicit(&cached_version, version, memory_order_relaxed);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user