RLIM_INFINITY support for RLIMIT_NOFILE (patch)

Andrew Wansink (andy@sharinga.com)
Fri, 13 Jul 2001 02:33:30 +0000


Good day all, I recently found that the linux kernel does not support setting
a process' RLIMIT_NOFILE limits to the #define RLIM_INFINITY. My patch will
add such support by setting the limit to the maximum supported by the kernel
when a call to set a limit to RLIM_INFINITY is made.

I understand that the semantics do not match exactly but all kernels are limited
by real hard limits and/or available memory, I think that it is therefore
acceptable to have a call to set a limit to RLIM_INFINITY actually set the
limit to the maximum extent supported by the kernel.

Patch by: Andrew Wansink & Chris Leishman
Against: Linux 2.4.6
Date: (Friday the 13th) 13th July 2001
File: kernel/sys.c

--- sys.c.orig Fri Jul 13 02:03:19 2001
+++ sys.c Fri Jul 13 01:41:57 2001
@@ -1119,6 +1119,10 @@
return -EINVAL;
if(copy_from_user(&new_rlim, rlim, sizeof(*rlim)))
return -EFAULT;
+ if (new_rlim.rlim_cur == RLIM_INFINITY)
+ new_rlim.rlim_cur = NR_OPEN;
+ if (new_rlim.rlim_max == RLIM_INFINITY)
+ new_rlim.rlim_max = NR_OPEN;
if (new_rlim.rlim_cur < 0 || new_rlim.rlim_max < 0)
return -EINVAL;
old_rlim = current->rlim + resource;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/