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
|
|
|
*/
|
|
|
|
|
2021-12-21 18:15:24 +03:00
|
|
|
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
2020-07-31 00:38:15 +03:00
|
|
|
#include <Kernel/Process.h>
|
2021-03-16 23:22:56 +03:00
|
|
|
#include <Kernel/Time/TimeManagement.h>
|
2020-07-31 00:38:15 +03:00
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
2021-11-08 02:51:39 +03:00
|
|
|
ErrorOr<FlatPtr> Process::sys$sysconf(int name)
|
2020-07-31 00:38:15 +03:00
|
|
|
{
|
2021-08-06 15:27:03 +03:00
|
|
|
VERIFY_NO_PROCESS_BIG_LOCK(this)
|
2020-07-31 00:38:15 +03:00
|
|
|
switch (name) {
|
2021-06-04 02:45:04 +03:00
|
|
|
case _SC_MONOTONIC_CLOCK:
|
|
|
|
return 1;
|
2020-07-31 00:38:15 +03:00
|
|
|
case _SC_NPROCESSORS_CONF:
|
|
|
|
case _SC_NPROCESSORS_ONLN:
|
2021-12-16 20:11:25 +03:00
|
|
|
return Processor::count();
|
2020-09-09 10:35:02 +03:00
|
|
|
case _SC_OPEN_MAX:
|
2021-12-18 20:39:18 +03:00
|
|
|
return OpenFileDescriptions::max_open();
|
2021-01-18 11:51:21 +03:00
|
|
|
case _SC_PAGESIZE:
|
|
|
|
return PAGE_SIZE;
|
2021-09-10 21:34:04 +03:00
|
|
|
case _SC_HOST_NAME_MAX:
|
|
|
|
return HOST_NAME_MAX;
|
2021-01-18 11:51:21 +03:00
|
|
|
case _SC_TTY_NAME_MAX:
|
|
|
|
return TTY_NAME_MAX;
|
2021-02-12 05:11:50 +03:00
|
|
|
case _SC_GETPW_R_SIZE_MAX:
|
|
|
|
return 4096; // idk
|
2021-03-16 21:05:23 +03:00
|
|
|
case _SC_CLK_TCK:
|
2021-03-16 23:22:56 +03:00
|
|
|
return TimeManagement::the().ticks_per_second();
|
2021-12-21 18:15:24 +03:00
|
|
|
case _SC_SYMLOOP_MAX:
|
|
|
|
return Kernel::VirtualFileSystem::symlink_recursion_limit;
|
2020-07-31 00:38:15 +03:00
|
|
|
default:
|
2021-03-01 15:49:16 +03:00
|
|
|
return EINVAL;
|
2020-07-31 00:38:15 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|