mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-25 22:14:37 +00:00
Implement process resource limits
This commit is contained in:
parent
e09d93e2bb
commit
daccdaeeae
@ -247,13 +247,6 @@ struct rusage
|
||||
long ru_nivcsw;
|
||||
};
|
||||
|
||||
typedef unsigned long rlim_t;
|
||||
struct rlimit
|
||||
{
|
||||
rlim_t rlim_cur; /* Soft limit */
|
||||
rlim_t rlim_max; /* Hard limit (ceiling for rlim_cur) */
|
||||
};
|
||||
|
||||
struct linux_dirent
|
||||
{
|
||||
unsigned long d_ino; /* Inode number */
|
||||
|
@ -33,6 +33,15 @@
|
||||
#include <abi.h>
|
||||
#include <list>
|
||||
|
||||
#define RLIM_INFINITY (~0ULL)
|
||||
|
||||
typedef unsigned long long rlim_t;
|
||||
struct rlimit
|
||||
{
|
||||
rlim_t rlim_cur;
|
||||
rlim_t rlim_max;
|
||||
};
|
||||
|
||||
namespace Tasking
|
||||
{
|
||||
using vfs::FileDescriptorTable;
|
||||
@ -445,6 +454,12 @@ namespace Tasking
|
||||
pid_t ProcessGroupID = 0;
|
||||
pid_t SessionID = 0;
|
||||
} Security{};
|
||||
struct
|
||||
{
|
||||
rlim_t OpenFiles = 4096;
|
||||
rlim_t Threads = 1024;
|
||||
rlim_t Memory = 8589934592; /* 8 GiB */
|
||||
} Limits{};
|
||||
TaskInfo Info{};
|
||||
ThreadLocalStorage TLS{};
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <rand.hpp>
|
||||
#include <limits.h>
|
||||
#include <exec.hpp>
|
||||
#include <task.hpp>
|
||||
#include <debug.h>
|
||||
#include <cpu.hpp>
|
||||
#include <time.h>
|
||||
@ -2702,12 +2703,14 @@ static int linux_prlimit64(SysFrm *, pid_t pid, int resource,
|
||||
|
||||
if (new_limit)
|
||||
{
|
||||
debug("new limit: rlim_cur:%#lx rlim_max:%#lx", pNewLimit->rlim_cur, pNewLimit->rlim_max);
|
||||
debug("new limit: rlim_cur:%lld rlim_max:%lld",
|
||||
pNewLimit->rlim_cur, pNewLimit->rlim_max);
|
||||
}
|
||||
|
||||
if (old_limit)
|
||||
{
|
||||
debug("old limit: rlim_cur:%#lx rlim_max:%#lx", pOldLimit->rlim_cur, pOldLimit->rlim_max);
|
||||
debug("old limit: rlim_cur:%lld rlim_max:%lld",
|
||||
pOldLimit->rlim_cur, pOldLimit->rlim_max);
|
||||
}
|
||||
|
||||
switch (resource)
|
||||
@ -2718,10 +2721,27 @@ static int linux_prlimit64(SysFrm *, pid_t pid, int resource,
|
||||
case RLIMIT_STACK:
|
||||
case RLIMIT_CORE:
|
||||
case RLIMIT_RSS:
|
||||
goto __stub;
|
||||
case RLIMIT_NPROC:
|
||||
{
|
||||
if (new_limit)
|
||||
pcb->Limits.Threads = pNewLimit->rlim_max;
|
||||
return 0;
|
||||
}
|
||||
case RLIMIT_NOFILE:
|
||||
{
|
||||
if (new_limit)
|
||||
pcb->Limits.OpenFiles = pNewLimit->rlim_max;
|
||||
return 0;
|
||||
}
|
||||
case RLIMIT_MEMLOCK:
|
||||
goto __stub;
|
||||
case RLIMIT_AS:
|
||||
{
|
||||
if (new_limit)
|
||||
pcb->Limits.Memory = pNewLimit->rlim_max;
|
||||
return 0;
|
||||
}
|
||||
case RLIMIT_LOCKS:
|
||||
case RLIMIT_SIGPENDING:
|
||||
case RLIMIT_MSGQUEUE:
|
||||
@ -2729,6 +2749,7 @@ static int linux_prlimit64(SysFrm *, pid_t pid, int resource,
|
||||
case RLIMIT_RTPRIO:
|
||||
case RLIMIT_RTTIME:
|
||||
case RLIMIT_NLIMITS:
|
||||
__stub:
|
||||
{
|
||||
fixme("resource %s(%d) is stub", rlimitStr[resource], resource);
|
||||
return 0; /* just return 0 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user