2024-08-22 14:28:39 +03:00
|
|
|
#include <BAN/Assert.h>
|
2024-12-02 03:54:11 +02:00
|
|
|
#include <BAN/Limits.h>
|
|
|
|
|
|
|
|
#include <kernel/Thread.h>
|
|
|
|
|
2024-09-17 15:59:22 +03:00
|
|
|
#include <errno.h>
|
2024-12-02 03:54:11 +02:00
|
|
|
#include <limits.h>
|
2024-08-22 14:28:39 +03:00
|
|
|
#include <sys/resource.h>
|
|
|
|
|
2024-12-02 03:54:11 +02:00
|
|
|
int getrlimit(int resource, struct rlimit* rlp)
|
|
|
|
{
|
|
|
|
switch (resource)
|
|
|
|
{
|
|
|
|
case RLIMIT_CORE:
|
|
|
|
rlp->rlim_cur = 0;
|
|
|
|
rlp->rlim_max = 0;
|
|
|
|
return 0;
|
|
|
|
case RLIMIT_CPU:
|
|
|
|
rlp->rlim_cur = BAN::numeric_limits<rlim_t>::max();
|
|
|
|
rlp->rlim_max = BAN::numeric_limits<rlim_t>::max();
|
|
|
|
return 0;
|
|
|
|
case RLIMIT_DATA:
|
|
|
|
rlp->rlim_cur = BAN::numeric_limits<rlim_t>::max();
|
|
|
|
rlp->rlim_max = BAN::numeric_limits<rlim_t>::max();
|
|
|
|
return 0;
|
|
|
|
case RLIMIT_FSIZE:
|
|
|
|
rlp->rlim_cur = BAN::numeric_limits<rlim_t>::max();
|
|
|
|
rlp->rlim_max = BAN::numeric_limits<rlim_t>::max();
|
|
|
|
return 0;
|
|
|
|
case RLIMIT_NOFILE:
|
|
|
|
rlp->rlim_cur = OPEN_MAX;
|
|
|
|
rlp->rlim_max = OPEN_MAX;
|
|
|
|
return 0;
|
|
|
|
case RLIMIT_STACK:
|
|
|
|
rlp->rlim_cur = Kernel::Thread::userspace_stack_size;
|
|
|
|
rlp->rlim_max = Kernel::Thread::userspace_stack_size;
|
|
|
|
return 0;
|
|
|
|
case RLIMIT_AS:
|
|
|
|
rlp->rlim_cur = BAN::numeric_limits<rlim_t>::max();
|
|
|
|
rlp->rlim_max = BAN::numeric_limits<rlim_t>::max();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
errno = EINVAL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2024-09-17 15:59:22 +03:00
|
|
|
int getrusage(int who, struct rusage* r_usage)
|
2024-08-22 14:28:39 +03:00
|
|
|
{
|
2024-09-17 15:59:22 +03:00
|
|
|
if (who != RUSAGE_CHILDREN && who != RUSAGE_SELF)
|
|
|
|
{
|
|
|
|
errno = EINVAL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
r_usage->ru_stime.tv_sec = 0;
|
|
|
|
r_usage->ru_stime.tv_usec = 0;
|
|
|
|
|
|
|
|
r_usage->ru_utime.tv_sec = 0;
|
|
|
|
r_usage->ru_utime.tv_usec = 0;
|
|
|
|
|
|
|
|
return 0;
|
2024-08-22 14:28:39 +03:00
|
|
|
}
|