2020-07-30 18:38:15 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-07-30 18:38:15 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <Kernel/Process.h>
|
|
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
2021-06-28 15:59:35 -03:00
|
|
|
KResultOr<FlatPtr> Process::sys$uname(Userspace<utsname*> user_buf)
|
2020-07-30 18:38:15 -03:00
|
|
|
{
|
2021-07-18 15:27:41 -03:00
|
|
|
VERIFY_NO_PROCESS_BIG_LOCK(this)
|
2020-07-30 18:38:15 -03:00
|
|
|
REQUIRE_PROMISE(stdio);
|
2020-08-09 17:02:27 -03:00
|
|
|
|
2021-02-24 10:33:50 -03:00
|
|
|
utsname buf {};
|
|
|
|
|
memcpy(buf.sysname, "SerenityOS", 11);
|
|
|
|
|
memcpy(buf.release, "1.0-dev", 8);
|
|
|
|
|
memcpy(buf.version, "FIXME", 6);
|
2021-06-29 14:19:35 -03:00
|
|
|
#if ARCH(I386)
|
2021-02-24 10:33:50 -03:00
|
|
|
memcpy(buf.machine, "i686", 5);
|
2021-06-29 14:19:35 -03:00
|
|
|
#else
|
|
|
|
|
memcpy(buf.machine, "x86_64", 7);
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-07-18 10:00:48 -03:00
|
|
|
hostname().with_shared([&](const auto& name) {
|
|
|
|
|
memcpy(buf.nodename, name.characters(), name.length() + 1);
|
|
|
|
|
});
|
2021-02-24 10:33:50 -03:00
|
|
|
|
2021-09-05 12:38:37 -03:00
|
|
|
return copy_to_user(user_buf, &buf);
|
2020-07-30 18:38:15 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|