2020-07-31 00:38:15 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-07-31 00:38:15 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <Kernel/Process.h>
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
2021-03-01 15:49:16 +03:00
|
|
|
KResultOr<int> Process::sys$uname(Userspace<utsname*> user_buf)
|
2020-07-31 00:38:15 +03:00
|
|
|
{
|
|
|
|
extern String* g_hostname;
|
|
|
|
extern Lock* g_hostname_lock;
|
|
|
|
|
|
|
|
REQUIRE_PROMISE(stdio);
|
2020-08-09 23:02:27 +03:00
|
|
|
|
2021-04-25 01:27:32 +03:00
|
|
|
Locker locker(*g_hostname_lock, Lock::Mode::Shared);
|
2020-07-31 00:38:15 +03:00
|
|
|
if (g_hostname->length() + 1 > sizeof(utsname::nodename))
|
2021-03-01 15:49:16 +03:00
|
|
|
return ENAMETOOLONG;
|
2020-08-09 23:02:27 +03:00
|
|
|
|
2021-02-24 16:33:50 +03:00
|
|
|
utsname buf {};
|
|
|
|
memcpy(buf.sysname, "SerenityOS", 11);
|
|
|
|
memcpy(buf.release, "1.0-dev", 8);
|
|
|
|
memcpy(buf.version, "FIXME", 6);
|
|
|
|
memcpy(buf.machine, "i686", 5);
|
|
|
|
memcpy(buf.nodename, g_hostname->characters(), g_hostname->length() + 1);
|
|
|
|
|
|
|
|
if (!copy_to_user(user_buf, &buf))
|
2021-03-01 15:49:16 +03:00
|
|
|
return EFAULT;
|
2020-07-31 00:38:15 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|