static void restore_rlims(struct task_restore_args *ta) { int r; for (r = 0; r < ta->nr_rlim; r++) { struct krlimit krlim; krlim.rlim_cur = ta->rlims[r].rlim_cur; krlim.rlim_max = ta->rlims[r].rlim_max; sys_setrlimit(r, &krlim); } }
int osf1_sys_setrlimit(struct lwp *l, const struct osf1_sys_setrlimit_args *uap, register_t *retval) { struct sys_setrlimit_args a; switch (SCARG(uap, which)) { case OSF1_RLIMIT_CPU: SCARG(&a, which) = RLIMIT_CPU; break; case OSF1_RLIMIT_FSIZE: SCARG(&a, which) = RLIMIT_FSIZE; break; case OSF1_RLIMIT_DATA: SCARG(&a, which) = RLIMIT_DATA; break; case OSF1_RLIMIT_STACK: SCARG(&a, which) = RLIMIT_STACK; break; case OSF1_RLIMIT_CORE: SCARG(&a, which) = RLIMIT_CORE; break; case OSF1_RLIMIT_RSS: SCARG(&a, which) = RLIMIT_RSS; break; case OSF1_RLIMIT_NOFILE: SCARG(&a, which) = RLIMIT_NOFILE; break; case OSF1_RLIMIT_AS: SCARG(&a, which) = RLIMIT_AS; break; default: return (EINVAL); } /* XXX should translate */ SCARG(&a, rlp) = SCARG(uap, rlp); return sys_setrlimit(l, &a, retval); }
asmlinkage long compat_sys_setrlimit(unsigned int resource, struct compat_rlimit __user *rlim) { struct rlimit r; int ret; mm_segment_t old_fs = get_fs (); if (resource >= RLIM_NLIMITS) return -EINVAL; if (!access_ok(VERIFY_READ, rlim, sizeof(*rlim)) || __get_user(r.rlim_cur, &rlim->rlim_cur) || __get_user(r.rlim_max, &rlim->rlim_max)) return -EFAULT; if (r.rlim_cur == COMPAT_RLIM_INFINITY) r.rlim_cur = RLIM_INFINITY; if (r.rlim_max == COMPAT_RLIM_INFINITY) r.rlim_max = RLIM_INFINITY; set_fs(KERNEL_DS); ret = sys_setrlimit(resource, (struct rlimit __user *) &r); set_fs(old_fs); return ret; }