kernel: Return B_HAIKU_VERSION for kernel_version & handle it in uname().

We have returned "1" here since this code was originally written
in 2004 (hrev7290). BeOS R5 apparently returns "1000009" for this
value, while the Be Book gives no details about what this value means.

So, return an actually useful value of the Haiku version, and then
in uname() process this to return a string indicating the Haiku
version. This makes "uname" print the actual system version,
not just the hrev.

It appears Linux and other systems give non-integer values in
info->release, so this should be fine.

Fixes #17030.
This commit is contained in:
Augustin Cavalier
2026-01-06 19:30:44 -05:00
parent 6a1ad86129
commit f869860377
2 changed files with 15 additions and 3 deletions
+1 -1
View File
@@ -42,7 +42,7 @@
#include <vm/vm_page.h>
const static int64 kKernelVersion = 0x1;
const static int64 kKernelVersion = B_HAIKU_VERSION;
const static char *kKernelName = "kernel_" HAIKU_ARCH;
+14 -2
View File
@@ -45,8 +45,20 @@ uname(struct utsname *info)
strlcat(info->version, systemInfo.kernel_build_date, sizeof(info->version));
strlcat(info->version, " ", sizeof(info->version));
strlcat(info->version, systemInfo.kernel_build_time, sizeof(info->version));
snprintf(info->release, sizeof(info->release), "%" B_PRId64,
systemInfo.kernel_version);
const char* release = NULL;
switch (systemInfo.kernel_version) {
case B_HAIKU_VERSION_1_PRE_BETA_5: release = "R1~beta4+development"; break;
case B_HAIKU_VERSION_1_BETA_5: release = "R1~beta5"; break;
case B_HAIKU_VERSION_1_PRE_BETA_6: release = "R1~beta5+development"; break;
case B_HAIKU_VERSION_1: release = "R1"; break;
default:
snprintf(info->release, sizeof(info->release), "%" B_PRId64,
systemInfo.kernel_version);
break;
}
if (release != NULL)
strlcpy(info->release, release, sizeof(info->release));
error = get_cpu_topology_info(&root, &count);
if (error != B_OK || count < 1)