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