v_count => v_usecount; v_lastr is being used; v_mounton is gone;
[unix-history] / usr / src / sys / kern / kern_resource.c
index 1f71393..212ee85 100644 (file)
@@ -1,22 +1,14 @@
 /*
 /*
- * Copyright (c) 1982 Regents of the University of California.
+ * Copyright (c) 1982, 1986 Regents of the University of California.
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)kern_resource.c     6.9 (Berkeley) %G%
+ *     @(#)kern_resource.c     7.5 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
-#include "systm.h"
-#include "dir.h"
 #include "user.h"
 #include "user.h"
-#include "inode.h"
 #include "proc.h"
 #include "proc.h"
-#include "seg.h"
-#include "fs.h"
-#include "uio.h"
-#include "vm.h"
-#include "kernel.h"
 
 /*
  * Resource controls and accounting.
 
 /*
  * Resource controls and accounting.
@@ -29,7 +21,7 @@ getpriority()
                int     who;
        } *uap = (struct a *)u.u_ap;
        register struct proc *p;
                int     who;
        } *uap = (struct a *)u.u_ap;
        register struct proc *p;
-       int low = PRIO_MAX + 1;
+       register int low = PRIO_MAX + 1;
 
        switch (uap->which) {
 
 
        switch (uap->which) {
 
@@ -43,15 +35,19 @@ getpriority()
                low = p->p_nice;
                break;
 
                low = p->p_nice;
                break;
 
-       case PRIO_PGRP:
+       case PRIO_PGRP: {
+               register struct pgrp *pg;
+
                if (uap->who == 0)
                if (uap->who == 0)
-                       uap->who = u.u_procp->p_pgrp;
-               for (p = allproc; p != NULL; p = p->p_nxt) {
-                       if (p->p_pgrp == uap->who &&
-                           p->p_nice < low)
+                       pg = u.u_procp->p_pgrp;
+               else if ((pg = pgfind(uap->who)) == NULL)
+                       break;
+               for (p = pg->pg_mem; p != NULL; p = p->p_pgrpnxt) {
+                       if (p->p_nice < low)
                                low = p->p_nice;
                }
                break;
                                low = p->p_nice;
                }
                break;
+       }
 
        case PRIO_USER:
                if (uap->who == 0)
 
        case PRIO_USER:
                if (uap->who == 0)
@@ -97,15 +93,19 @@ setpriority()
                found++;
                break;
 
                found++;
                break;
 
-       case PRIO_PGRP:
+       case PRIO_PGRP: {
+               register struct pgrp *pg;
+                
                if (uap->who == 0)
                if (uap->who == 0)
-                       uap->who = u.u_procp->p_pgrp;
-               for (p = allproc; p != NULL; p = p->p_nxt)
-                       if (p->p_pgrp == uap->who) {
-                               donice(p, uap->prio);
-                               found++;
-                       }
+                       pg = u.u_procp->p_pgrp;
+               else if ((pg = pgfind(uap->who)) == NULL)
+                       break;
+               for (p = pg->pg_mem; p != NULL; p = p->p_pgrpnxt) {
+                       donice(p, uap->prio);
+                       found++;
+               }
                break;
                break;
+       }
 
        case PRIO_USER:
                if (uap->who == 0)
 
        case PRIO_USER:
                if (uap->who == 0)
@@ -139,7 +139,7 @@ donice(p, n)
                n = PRIO_MAX;
        if (n < PRIO_MIN)
                n = PRIO_MIN;
                n = PRIO_MAX;
        if (n < PRIO_MIN)
                n = PRIO_MIN;
-       if (n < p->p_nice && !suser()) {
+       if (n < p->p_nice && suser(u.u_cred, &u.u_acflag)) {
                u.u_error = EACCES;
                return;
        }
                u.u_error = EACCES;
                return;
        }
@@ -167,7 +167,7 @@ setrlimit()
        if (u.u_error)
                return;
        if (alim.rlim_cur > alimp->rlim_max || alim.rlim_max > alimp->rlim_max)
        if (u.u_error)
                return;
        if (alim.rlim_cur > alimp->rlim_max || alim.rlim_max > alimp->rlim_max)
-               if (!suser())
+               if (u.u_error = suser(u.u_cred, &u.u_acflag))
                        return;
        switch (uap->which) {
 
                        return;
        switch (uap->which) {