mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:47:44 +00:00
Kernel: Read version and git commit hash from baked-in version info
... instead of hard-coding it in the uname syscall.
This commit is contained in:
parent
7e11b9a276
commit
4c7eef874d
1 changed files with 18 additions and 7 deletions
|
@ -1,10 +1,13 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||||
|
* Copyright (c) 2022, kleines Filmröllchen <filmroellchen@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <AK/TypedTransfer.h>
|
||||||
#include <Kernel/Process.h>
|
#include <Kernel/Process.h>
|
||||||
|
#include <Kernel/Version.h>
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
|
@ -13,19 +16,27 @@ ErrorOr<FlatPtr> Process::sys$uname(Userspace<utsname*> user_buf)
|
||||||
VERIFY_NO_PROCESS_BIG_LOCK(this);
|
VERIFY_NO_PROCESS_BIG_LOCK(this);
|
||||||
TRY(require_promise(Pledge::stdio));
|
TRY(require_promise(Pledge::stdio));
|
||||||
|
|
||||||
utsname buf {};
|
utsname buf
|
||||||
memcpy(buf.sysname, "SerenityOS", 11);
|
{
|
||||||
memcpy(buf.release, "1.0-dev", 8);
|
"SerenityOS",
|
||||||
memcpy(buf.version, "FIXME", 6);
|
{}, // Hostname, filled in below.
|
||||||
|
{}, // "Release" (1.0-dev), filled in below.
|
||||||
|
{}, // "Revision" (git commit hash), filled in below.
|
||||||
#if ARCH(I386)
|
#if ARCH(I386)
|
||||||
memcpy(buf.machine, "i686", 5);
|
"i686",
|
||||||
#elif ARCH(X86_64)
|
#elif ARCH(X86_64)
|
||||||
memcpy(buf.machine, "x86_64", 7);
|
"x86_64",
|
||||||
#elif ARCH(AARCH64)
|
#elif ARCH(AARCH64)
|
||||||
memcpy(buf.machine, "AArch64", 7);
|
"AArch64",
|
||||||
#else
|
#else
|
||||||
# error Unknown architecture
|
# error Unknown architecture
|
||||||
#endif
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
auto version_string = TRY(KString::formatted("{}.{}-dev", SERENITY_MAJOR_REVISION, SERENITY_MINOR_REVISION));
|
||||||
|
AK::TypedTransfer<u8>::copy(reinterpret_cast<u8*>(buf.release), version_string->bytes().data(), min(version_string->length(), UTSNAME_ENTRY_LEN - 1));
|
||||||
|
|
||||||
|
AK::TypedTransfer<u8>::copy(reinterpret_cast<u8*>(buf.version), SERENITY_VERSION.bytes().data(), min(SERENITY_VERSION.length(), UTSNAME_ENTRY_LEN - 1));
|
||||||
|
|
||||||
hostname().with_shared([&](auto const& name) {
|
hostname().with_shared([&](auto const& name) {
|
||||||
auto length = min(name->length(), UTSNAME_ENTRY_LEN - 1);
|
auto length = min(name->length(), UTSNAME_ENTRY_LEN - 1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue