diff -ruN linux-2.2.3-reference/Documentation/proc.txt linux/Documentation/proc.txt --- linux-2.2.3-reference/Documentation/proc.txt Sat Mar 13 15:05:52 1999 +++ linux/Documentation/proc.txt Sat Mar 13 18:25:20 1999 @@ -102,6 +102,7 @@ cwd Link to the current working directory exe Link to the executable of this process maps Memory maps + rlimit Current process rlimits root Link to the root directory of this process statm Process memory status information _________________________________________________ @@ -149,6 +150,22 @@ dt number of dirty pages The ratio text/data/library is approximate only by heuristics. + +The rlimit file contains process-specific rlimit information. The +values in the rlimit file have the following meanings. The text +"unlimited" in any field means that no limit is set. + +CPU time: Cpu time limit, in milliseconds +File size: File size limit, in bytes +Data seg: Data segment size limit, in bytes +Res set: Resident set size limit, in pages +Locked mem: Locked memory limit, in pages +Addr space: Address space size limit, in pages +Stack size: Stack size limit, in bytes +Core size: Core file size limit, in 1K blocks +Proc count: Maximum processes allowed for this UID +Open files: Maximum open files for this process +Pipe size: Maximum number of bytes pending in a pipe 2.2 Kernel data diff -ruN linux-2.2.3-reference/fs/proc/array.c linux/fs/proc/array.c --- linux-2.2.3-reference/fs/proc/array.c Sat Mar 13 15:05:46 1999 +++ linux/fs/proc/array.c Sat Mar 13 19:11:43 1999 @@ -42,6 +42,9 @@ * Alan Cox : security fixes. * * + * Chuck Lever : /proc//rlimit + * + * */ #include @@ -1225,6 +1228,75 @@ } #endif +/* can get a process's rlimit info -- someday, should be able to set it, too */ +static int get_rlimit(int pid, char * buffer) +{ + int len = 0; + struct task_struct *tsk; + struct rlimit * rlim; + + read_lock(&tasklist_lock); + + if ((tsk = find_task_by_pid(pid)) && (rlim = tsk->rlim)) { + len = sprintf(buffer, "CPU time:\t"); + if (rlim[RLIMIT_CPU].rlim_cur == LONG_MAX) + len += sprintf(buffer + len, "unlimited\n"); + else + len += sprintf(buffer + len, "%ld\n", + rlim[RLIMIT_CPU].rlim_cur); + + len += sprintf(buffer + len, "File size:\t"); + if (rlim[RLIMIT_FSIZE].rlim_cur == LONG_MAX) + len += sprintf(buffer + len, "unlimited\n"); + else + len += sprintf(buffer + len, "%ld\n", + rlim[RLIMIT_FSIZE].rlim_cur); + + len += sprintf(buffer + len, "Data seg:\t"); + if (rlim[RLIMIT_DATA].rlim_cur == LONG_MAX) + len += sprintf(buffer + len, "unlimited\n"); + else + len += sprintf(buffer + len, "%ld\n", + rlim[RLIMIT_DATA].rlim_cur); + + len += sprintf(buffer + len, "Res set:\t"); + if (rlim[RLIMIT_RSS].rlim_cur == LONG_MAX) + len += sprintf(buffer + len, "unlimited\n"); + else + len += sprintf(buffer + len, "%ld\n", + rlim[RLIMIT_RSS].rlim_cur); + + len += sprintf(buffer + len, "Locked mem:\t"); + if (rlim[RLIMIT_MEMLOCK].rlim_cur == LONG_MAX) + len += sprintf(buffer + len, "unlimited\n"); + else + len += sprintf(buffer + len, "%ld\n", + rlim[RLIMIT_MEMLOCK].rlim_cur >> PAGE_SHIFT); + + len += sprintf(buffer + len, "Addr space:\t"); + if (rlim[RLIMIT_AS].rlim_cur == LONG_MAX) + len += sprintf(buffer + len, "unlimited\n"); + else + len += sprintf(buffer + len, "%ld\n", + rlim[RLIMIT_AS].rlim_cur >> PAGE_SHIFT); + + len += sprintf(buffer + len, + "Stack size:\t%ld\n" + "Core size:\t%ld\n" + "Proc count:\t%ld\n" + "Open files:\t%ld\n" + "Pipe size:\t%d\n", /* just cuz bash does it */ + rlim[RLIMIT_STACK].rlim_cur, + rlim[RLIMIT_CORE].rlim_cur >> 10, + rlim[RLIMIT_NPROC].rlim_cur, + rlim[RLIMIT_NOFILE].rlim_cur, + PIPE_BUF); + } + + read_unlock(&tasklist_lock); + return len; +} + #ifdef CONFIG_MODULES extern int get_module_list(char *); extern int get_ksyms_list(char *, char **, off_t, int); @@ -1375,6 +1447,7 @@ case PROC_PID_MAPS: case PROC_PID_CMDLINE: case PROC_PID_CPU: + case PROC_PID_RLIMIT: return 0; } if(capable(CAP_DAC_OVERRIDE) || (current->fsuid == euid && ok)) @@ -1400,6 +1473,8 @@ case PROC_PID_CPU: return get_pidcpu(pid, page); #endif + case PROC_PID_RLIMIT: + return get_rlimit(pid, page); } return -EBADF; } diff -ruN linux-2.2.3-reference/fs/proc/base.c linux/fs/proc/base.c --- linux-2.2.3-reference/fs/proc/base.c Mon Aug 24 16:02:43 1998 +++ linux/fs/proc/base.c Sat Mar 13 14:21:26 1999 @@ -175,6 +175,13 @@ }; #endif +static struct proc_dir_entry proc_pid_rlimit = { + PROC_PID_RLIMIT, 6, "rlimit", + S_IFREG | S_IRUGO, 1, 0, 0, + 0, &proc_array_inode_operations, + NULL, proc_pid_fill_inode, +}; + __initfunc(void proc_base_init(void)) { #if CONFIG_AP1000 @@ -194,14 +201,5 @@ #ifdef __SMP__ proc_register(&proc_pid, &proc_pid_cpu); #endif + proc_register(&proc_pid, &proc_pid_rlimit); }; - - - - - - - - - - diff -ruN linux-2.2.3-reference/include/linux/proc_fs.h linux/include/linux/proc_fs.h --- linux-2.2.3-reference/include/linux/proc_fs.h Sat Mar 13 15:05:47 1999 +++ linux/include/linux/proc_fs.h Sat Mar 13 19:05:05 1999 @@ -72,6 +72,7 @@ PROC_PID_RINGBUF, #endif PROC_PID_CPU, + PROC_PID_RLIMIT, }; enum pid_subdirectory_inos {