blob: dc8e002ca09d97578a2ea5cd985b93c1a693c2c4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/Process.h>
namespace Kernel {
KResultOr<FlatPtr> Process::sys$uname(Userspace<utsname*> user_buf)
{
extern String* g_hostname;
extern Lock* g_hostname_lock;
REQUIRE_PROMISE(stdio);
Locker locker(*g_hostname_lock, Lock::Mode::Shared);
if (g_hostname->length() + 1 > sizeof(utsname::nodename))
return ENAMETOOLONG;
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))
return EFAULT;
return 0;
}
}
|