From f869860377d2d752460aef2ac13ee6b1bfbbee05 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Tue, 6 Jan 2026 19:30:03 -0500 Subject: [PATCH] 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. --- src/system/kernel/system_info.cpp | 2 +- src/system/libroot/posix/sys/uname.c | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/system/kernel/system_info.cpp b/src/system/kernel/system_info.cpp index 9139a1d642..5dd5b7ac5d 100644 --- a/src/system/kernel/system_info.cpp +++ b/src/system/kernel/system_info.cpp @@ -42,7 +42,7 @@ #include -const static int64 kKernelVersion = 0x1; +const static int64 kKernelVersion = B_HAIKU_VERSION; const static char *kKernelName = "kernel_" HAIKU_ARCH; diff --git a/src/system/libroot/posix/sys/uname.c b/src/system/libroot/posix/sys/uname.c index 4d81d4ad63..abe1915450 100644 --- a/src/system/libroot/posix/sys/uname.c +++ b/src/system/libroot/posix/sys/uname.c @@ -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)