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