Serenity Operating System
1/*
2 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#include <Kernel/FileSystem/VirtualFileSystem.h>
8#include <Kernel/Memory/MemoryManager.h>
9#include <Kernel/Process.h>
10#include <Kernel/Time/TimeManagement.h>
11
12namespace Kernel {
13
14ErrorOr<FlatPtr> Process::sys$sysconf(int name)
15{
16 VERIFY_NO_PROCESS_BIG_LOCK(this);
17 switch (name) {
18 case _SC_MONOTONIC_CLOCK:
19 return 1;
20 case _SC_NPROCESSORS_CONF:
21 case _SC_NPROCESSORS_ONLN:
22 return Processor::count();
23 case _SC_OPEN_MAX:
24 return OpenFileDescriptions::max_open();
25 case _SC_PAGESIZE:
26 return PAGE_SIZE;
27 case _SC_HOST_NAME_MAX:
28 return HOST_NAME_MAX;
29 case _SC_TTY_NAME_MAX:
30 return TTY_NAME_MAX;
31 case _SC_GETPW_R_SIZE_MAX:
32 return 4096; // idk
33 case _SC_CLK_TCK:
34 return TimeManagement::the().ticks_per_second();
35 case _SC_SYMLOOP_MAX:
36 return Kernel::VirtualFileSystem::symlink_recursion_limit;
37 case _SC_ARG_MAX:
38 return Process::max_arguments_size;
39 case _SC_IOV_MAX:
40 return IOV_MAX;
41 case _SC_PHYS_PAGES:
42 return MM.get_system_memory_info().physical_pages;
43 default:
44 return EINVAL;
45 }
46}
47
48}