Implemented get/setrlimit(RLIMIT_NOVMON). Note the kernel calls don't set errno... but they're called by user versions. Might want to split them if needed.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20165 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -3263,7 +3263,7 @@ vfs_new_io_context(void *_parentContext)
|
|||||||
context->table_size = tableSize;
|
context->table_size = tableSize;
|
||||||
|
|
||||||
list_init(&context->node_monitors);
|
list_init(&context->node_monitors);
|
||||||
context->max_monitors = MAX_NODE_MONITORS;
|
context->max_monitors = DEFAULT_NODE_MONITORS;
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
@@ -3352,6 +3352,29 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static status_t
|
||||||
|
vfs_resize_monitor_table(struct io_context *context, const int newSize)
|
||||||
|
{
|
||||||
|
void *fds;
|
||||||
|
int status = B_OK;
|
||||||
|
|
||||||
|
if (newSize <= 0 || newSize > MAX_NODE_MONITORS)
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
|
mutex_lock(&context->io_mutex);
|
||||||
|
|
||||||
|
if ((size_t)newSize < context->num_monitors) {
|
||||||
|
status = EBUSY;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
context->max_monitors = newSize;
|
||||||
|
|
||||||
|
out:
|
||||||
|
mutex_unlock(&context->io_mutex);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
vfs_getrlimit(int resource, struct rlimit * rlp)
|
vfs_getrlimit(int resource, struct rlimit * rlp)
|
||||||
{
|
{
|
||||||
@@ -3373,6 +3396,20 @@ vfs_getrlimit(int resource, struct rlimit * rlp)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case RLIMIT_NOVMON:
|
||||||
|
{
|
||||||
|
struct io_context *ioctx = get_current_io_context(false);
|
||||||
|
|
||||||
|
mutex_lock(&ioctx->io_mutex);
|
||||||
|
|
||||||
|
rlp->rlim_cur = ioctx->max_monitors;
|
||||||
|
rlp->rlim_max = MAX_NODE_MONITORS;
|
||||||
|
|
||||||
|
mutex_unlock(&ioctx->io_mutex);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -3387,8 +3424,17 @@ vfs_setrlimit(int resource, const struct rlimit * rlp)
|
|||||||
|
|
||||||
switch (resource) {
|
switch (resource) {
|
||||||
case RLIMIT_NOFILE:
|
case RLIMIT_NOFILE:
|
||||||
|
if (rlp->rlim_max != RLIM_SAVED_MAX &&
|
||||||
|
rlp->rlim_max != MAX_FD_TABLE_SIZE)
|
||||||
|
return EINVAL;
|
||||||
return vfs_resize_fd_table(get_current_io_context(false), rlp->rlim_cur);
|
return vfs_resize_fd_table(get_current_io_context(false), rlp->rlim_cur);
|
||||||
|
|
||||||
|
case RLIMIT_NOVMON:
|
||||||
|
if (rlp->rlim_max != RLIM_SAVED_MAX &&
|
||||||
|
rlp->rlim_max != MAX_NODE_MONITORS)
|
||||||
|
return EINVAL;
|
||||||
|
return vfs_resize_monitor_table(get_current_io_context(false), rlp->rlim_cur);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2016,6 +2016,7 @@ getrlimit(int resource, struct rlimit * rlp)
|
|||||||
|
|
||||||
switch (resource) {
|
switch (resource) {
|
||||||
case RLIMIT_NOFILE:
|
case RLIMIT_NOFILE:
|
||||||
|
case RLIMIT_NOVMON:
|
||||||
return vfs_getrlimit(resource, rlp);
|
return vfs_getrlimit(resource, rlp);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -2034,6 +2035,7 @@ setrlimit(int resource, const struct rlimit * rlp)
|
|||||||
|
|
||||||
switch (resource) {
|
switch (resource) {
|
||||||
case RLIMIT_NOFILE:
|
case RLIMIT_NOFILE:
|
||||||
|
case RLIMIT_NOVMON:
|
||||||
return vfs_setrlimit(resource, rlp);
|
return vfs_setrlimit(resource, rlp);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ _kset_mon_limit_(int num)
|
|||||||
if (num < 1)
|
if (num < 1)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
rl.rlim_cur = num;
|
rl.rlim_cur = num;
|
||||||
|
rl.rlim_max = RLIM_SAVED_MAX;
|
||||||
if (setrlimit(RLIMIT_NOVMON, &rl) < 0)
|
if (setrlimit(RLIMIT_NOVMON, &rl) < 0)
|
||||||
return errno;
|
return errno;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -49,6 +50,7 @@ _kset_fd_limit_(int num)
|
|||||||
if (num < 1)
|
if (num < 1)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
rl.rlim_cur = num;
|
rl.rlim_cur = num;
|
||||||
|
rl.rlim_max = RLIM_SAVED_MAX;
|
||||||
if (setrlimit(RLIMIT_NOFILE, &rl) < 0)
|
if (setrlimit(RLIMIT_NOFILE, &rl) < 0)
|
||||||
return errno;
|
return errno;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user