summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_resource.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/kern_resource.c')
-rw-r--r--sys/kern/kern_resource.c183
1 files changed, 98 insertions, 85 deletions
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c
index 68e9dfb..569b9d9 100644
--- a/sys/kern/kern_resource.c
+++ b/sys/kern/kern_resource.c
@@ -35,41 +35,48 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)kern_resource.c 8.5 (Berkeley) 1/21/94
+ * @(#)kern_resource.c 8.8 (Berkeley) 2/14/95
*/
#include <sys/param.h>
+#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/file.h>
#include <sys/resourcevar.h>
#include <sys/malloc.h>
#include <sys/proc.h>
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+
#include <vm/vm.h>
+int donice __P((struct proc *curp, struct proc *chgp, int n));
+int dosetrlimit __P((struct proc *p, u_int which, struct rlimit *limp));
+
/*
* Resource controls and accounting.
*/
-struct getpriority_args {
- int which;
- int who;
-};
+int
getpriority(curp, uap, retval)
struct proc *curp;
- register struct getpriority_args *uap;
- int *retval;
+ register struct getpriority_args /* {
+ syscallarg(int) which;
+ syscallarg(int) who;
+ } */ *uap;
+ register_t *retval;
{
register struct proc *p;
register int low = PRIO_MAX + 1;
- switch (uap->which) {
+ switch (SCARG(uap, which)) {
case PRIO_PROCESS:
- if (uap->who == 0)
+ if (SCARG(uap, who) == 0)
p = curp;
else
- p = pfind(uap->who);
+ p = pfind(SCARG(uap, who));
if (p == 0)
break;
low = p->p_nice;
@@ -78,11 +85,12 @@ getpriority(curp, uap, retval)
case PRIO_PGRP: {
register struct pgrp *pg;
- if (uap->who == 0)
+ if (SCARG(uap, who) == 0)
pg = curp->p_pgrp;
- else if ((pg = pgfind(uap->who)) == NULL)
+ else if ((pg = pgfind(SCARG(uap, who))) == NULL)
break;
- for (p = pg->pg_mem; p != NULL; p = p->p_pgrpnxt) {
+ for (p = pg->pg_members.lh_first; p != 0;
+ p = p->p_pglist.le_next) {
if (p->p_nice < low)
low = p->p_nice;
}
@@ -90,13 +98,12 @@ getpriority(curp, uap, retval)
}
case PRIO_USER:
- if (uap->who == 0)
- uap->who = curp->p_ucred->cr_uid;
- for (p = (struct proc *)allproc; p != NULL; p = p->p_next) {
- if (p->p_ucred->cr_uid == uap->who &&
+ if (SCARG(uap, who) == 0)
+ SCARG(uap, who) = curp->p_ucred->cr_uid;
+ for (p = allproc.lh_first; p != 0; p = p->p_list.le_next)
+ if (p->p_ucred->cr_uid == SCARG(uap, who) &&
p->p_nice < low)
low = p->p_nice;
- }
break;
default:
@@ -108,53 +115,54 @@ getpriority(curp, uap, retval)
return (0);
}
-struct setpriority_args {
- int which;
- int who;
- int prio;
-};
/* ARGSUSED */
+int
setpriority(curp, uap, retval)
struct proc *curp;
- register struct setpriority_args *uap;
- int *retval;
+ register struct setpriority_args /* {
+ syscallarg(int) which;
+ syscallarg(int) who;
+ syscallarg(int) prio;
+ } */ *uap;
+ register_t *retval;
{
register struct proc *p;
int found = 0, error = 0;
- switch (uap->which) {
+ switch (SCARG(uap, which)) {
case PRIO_PROCESS:
- if (uap->who == 0)
+ if (SCARG(uap, who) == 0)
p = curp;
else
- p = pfind(uap->who);
+ p = pfind(SCARG(uap, who));
if (p == 0)
break;
- error = donice(curp, p, uap->prio);
+ error = donice(curp, p, SCARG(uap, prio));
found++;
break;
case PRIO_PGRP: {
register struct pgrp *pg;
- if (uap->who == 0)
+ if (SCARG(uap, who) == 0)
pg = curp->p_pgrp;
- else if ((pg = pgfind(uap->who)) == NULL)
+ else if ((pg = pgfind(SCARG(uap, who))) == NULL)
break;
- for (p = pg->pg_mem; p != NULL; p = p->p_pgrpnxt) {
- error = donice(curp, p, uap->prio);
+ for (p = pg->pg_members.lh_first; p != 0;
+ p = p->p_pglist.le_next) {
+ error = donice(curp, p, SCARG(uap, prio));
found++;
}
break;
}
case PRIO_USER:
- if (uap->who == 0)
- uap->who = curp->p_ucred->cr_uid;
- for (p = (struct proc *)allproc; p != NULL; p = p->p_next)
- if (p->p_ucred->cr_uid == uap->who) {
- error = donice(curp, p, uap->prio);
+ if (SCARG(uap, who) == 0)
+ SCARG(uap, who) = curp->p_ucred->cr_uid;
+ for (p = allproc.lh_first; p != 0; p = p->p_list.le_next)
+ if (p->p_ucred->cr_uid == SCARG(uap, who)) {
+ error = donice(curp, p, SCARG(uap, prio));
found++;
}
break;
@@ -167,6 +175,7 @@ setpriority(curp, uap, retval)
return (error);
}
+int
donice(curp, chgp, n)
register struct proc *curp, *chgp;
register int n;
@@ -189,71 +198,73 @@ donice(curp, chgp, n)
}
#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
-struct setrlimit_args {
- u_int which;
- struct orlimit *lim;
-};
/* ARGSUSED */
-osetrlimit(p, uap, retval)
+int
+compat_43_setrlimit(p, uap, retval)
struct proc *p;
- register struct setrlimit_args *uap;
- int *retval;
+ struct compat_43_setrlimit_args /* {
+ syscallarg(u_int) which;
+ syscallarg(struct ogetrlimit *) rlp;
+ } */ *uap;
+ register_t *retval;
{
struct orlimit olim;
struct rlimit lim;
int error;
- if (error =
- copyin((caddr_t)uap->lim, (caddr_t)&olim, sizeof (struct orlimit)))
+ if (error = copyin((caddr_t)SCARG(uap, rlp), (caddr_t)&olim,
+ sizeof (struct orlimit)))
return (error);
lim.rlim_cur = olim.rlim_cur;
lim.rlim_max = olim.rlim_max;
- return (dosetrlimit(p, uap->which, &lim));
+ return (dosetrlimit(p, SCARG(uap, which), &lim));
}
-struct getrlimit_args {
- u_int which;
- struct orlimit *rlp;
-};
/* ARGSUSED */
-ogetrlimit(p, uap, retval)
+int
+compat_43_getrlimit(p, uap, retval)
struct proc *p;
- register struct getrlimit_args *uap;
- int *retval;
+ register struct compat_43_getrlimit_args /* {
+ syscallarg(u_int) which;
+ syscallarg(struct ogetrlimit *) rlp;
+ } */ *uap;
+ register_t *retval;
{
struct orlimit olim;
- if (uap->which >= RLIM_NLIMITS)
+ if (SCARG(uap, which) >= RLIM_NLIMITS)
return (EINVAL);
- olim.rlim_cur = p->p_rlimit[uap->which].rlim_cur;
+ olim.rlim_cur = p->p_rlimit[SCARG(uap, which)].rlim_cur;
if (olim.rlim_cur == -1)
olim.rlim_cur = 0x7fffffff;
- olim.rlim_max = p->p_rlimit[uap->which].rlim_max;
+ olim.rlim_max = p->p_rlimit[SCARG(uap, which)].rlim_max;
if (olim.rlim_max == -1)
olim.rlim_max = 0x7fffffff;
- return (copyout((caddr_t)&olim, (caddr_t)uap->rlp, sizeof(olim)));
+ return (copyout((caddr_t)&olim, (caddr_t)SCARG(uap, rlp),
+ sizeof(olim)));
}
#endif /* COMPAT_43 || COMPAT_SUNOS */
-struct __setrlimit_args {
- u_int which;
- struct rlimit *lim;
-};
/* ARGSUSED */
+int
setrlimit(p, uap, retval)
struct proc *p;
- register struct __setrlimit_args *uap;
- int *retval;
+ register struct setrlimit_args /* {
+ syscallarg(u_int) which;
+ syscallarg(struct rlimit *) rlp;
+ } */ *uap;
+ register_t *retval;
{
struct rlimit alim;
int error;
- if (error =
- copyin((caddr_t)uap->lim, (caddr_t)&alim, sizeof (struct rlimit)))
+ if (error = copyin((caddr_t)SCARG(uap, rlp), (caddr_t)&alim,
+ sizeof (struct rlimit)))
return (error);
- return (dosetrlimit(p, uap->which, &alim));
+ return (dosetrlimit(p, SCARG(uap, which), &alim));
}
+int
dosetrlimit(p, which, limp)
struct proc *p;
u_int which;
@@ -337,27 +348,28 @@ dosetrlimit(p, which, limp)
return (0);
}
-struct __getrlimit_args {
- u_int which;
- struct rlimit *rlp;
-};
/* ARGSUSED */
+int
getrlimit(p, uap, retval)
struct proc *p;
- register struct __getrlimit_args *uap;
- int *retval;
+ register struct getrlimit_args /* {
+ syscallarg(u_int) which;
+ syscallarg(struct rlimit *) rlp;
+ } */ *uap;
+ register_t *retval;
{
- if (uap->which >= RLIM_NLIMITS)
+ if (SCARG(uap, which) >= RLIM_NLIMITS)
return (EINVAL);
- return (copyout((caddr_t)&p->p_rlimit[uap->which], (caddr_t)uap->rlp,
- sizeof (struct rlimit)));
+ return (copyout((caddr_t)&p->p_rlimit[SCARG(uap, which)],
+ (caddr_t)SCARG(uap, rlp), sizeof (struct rlimit)));
}
/*
* Transform the running time and tick information in proc p into user,
* system, and interrupt time usage.
*/
+void
calcru(p, up, sp, ip)
register struct proc *p;
register struct timeval *up;
@@ -410,19 +422,19 @@ calcru(p, up, sp, ip)
}
}
-struct getrusage_args {
- int who;
- struct rusage *rusage;
-};
/* ARGSUSED */
+int
getrusage(p, uap, retval)
register struct proc *p;
- register struct getrusage_args *uap;
- int *retval;
+ register struct getrusage_args /* {
+ syscallarg(int) who;
+ syscallarg(struct rusage *) rusage;
+ } */ *uap;
+ register_t *retval;
{
register struct rusage *rup;
- switch (uap->who) {
+ switch (SCARG(uap, who)) {
case RUSAGE_SELF:
rup = &p->p_stats->p_ru;
@@ -436,10 +448,11 @@ getrusage(p, uap, retval)
default:
return (EINVAL);
}
- return (copyout((caddr_t)rup, (caddr_t)uap->rusage,
+ return (copyout((caddr_t)rup, (caddr_t)SCARG(uap, rusage),
sizeof (struct rusage)));
}
+void
ruadd(ru, ru2)
register struct rusage *ru, *ru2;
{
OpenPOWER on IntegriCloud