|
|
1.1 ! root 1: #include "sys/param.h" ! 2: #include "sys/user.h" ! 3: #include "sys/proc.h" ! 4: #include "sys/vm.h" ! 5: #include "sys/pte.h" ! 6: #include "sys/cmap.h" ! 7: #include "sys/mtpr.h" ! 8: #include "sys/vlimit.h" ! 9: #include "sys/vadvise.h" ! 10: ! 11: int both; ! 12: ! 13: vadvise() ! 14: { ! 15: register struct a { ! 16: int anom; ! 17: } *uap; ! 18: register struct proc *rp = u.u_procp; ! 19: int oanom = rp->p_flag & SUANOM; ! 20: register struct pte *pte; ! 21: register struct cmap *c; ! 22: register int i; ! 23: ! 24: uap = (struct a *)u.u_ap; ! 25: rp->p_flag &= ~(SSEQL|SUANOM); ! 26: switch (uap->anom) { ! 27: ! 28: case VA_ANOM: ! 29: rp->p_flag |= SUANOM; ! 30: break; ! 31: ! 32: case VA_SEQL: ! 33: rp->p_flag |= SSEQL; ! 34: break; ! 35: } ! 36: if (both || (oanom && (rp->p_flag & SUANOM) == 0)) { ! 37: for (i = 0; i < rp->p_dsize; i += CLSIZE) { ! 38: pte = dptopte(rp, i); ! 39: if (pte->pg_v) { ! 40: c = &cmap[pgtocm(pte->pg_pfnum)]; ! 41: if (c->c_lock) ! 42: continue; ! 43: pte->pg_v = 0; ! 44: if (anycl(pte, pg_m)) ! 45: pte->pg_m = 1; ! 46: distcl(pte); ! 47: } ! 48: } ! 49: mtpr(TBIA, 0); ! 50: } ! 51: } ! 52: ! 53: vtimes() ! 54: { ! 55: register struct a { ! 56: struct vtimes *par_vm; ! 57: struct vtimes *ch_vm; ! 58: } *uap = (struct a *)u.u_ap; ! 59: if (uap->par_vm) { ! 60: if (copyout((caddr_t)&u.u_vm, (caddr_t)uap->par_vm, ! 61: sizeof(struct vtimes)) < 0) ! 62: u.u_error = EFAULT; ! 63: } ! 64: if (uap->ch_vm == 0) ! 65: return; ! 66: if (copyout((caddr_t)&u.u_cvm, (caddr_t)uap->ch_vm, ! 67: sizeof(struct vtimes)) < 0) ! 68: u.u_error = EFAULT; ! 69: } ! 70: ! 71: vmsadd(vp, wp) ! 72: register struct vtimes *vp, *wp; ! 73: { ! 74: ! 75: vp->vm_utime += wp->vm_utime; ! 76: vp->vm_stime += wp->vm_stime; ! 77: vp->vm_nswap += wp->vm_nswap; ! 78: vp->vm_idsrss += wp->vm_idsrss; ! 79: vp->vm_ixrss += wp->vm_ixrss; ! 80: if (vp->vm_maxrss < wp->vm_maxrss) ! 81: vp->vm_maxrss = wp->vm_maxrss; ! 82: vp->vm_majflt += wp->vm_majflt; ! 83: vp->vm_minflt += wp->vm_minflt; ! 84: vp->vm_inblk += wp->vm_inblk; ! 85: vp->vm_oublk += wp->vm_oublk; ! 86: } ! 87: ! 88: /* ! 89: * Affect per-process limits. ! 90: * To just return old limit, specify negative new limit. ! 91: */ ! 92: vlimit() ! 93: { ! 94: register struct a { ! 95: unsigned which; ! 96: int limit; ! 97: } *uap; ! 98: ! 99: uap = (struct a *)u.u_ap; ! 100: if (uap->which > NLIMITS) { ! 101: u.u_error = EINVAL; ! 102: return; ! 103: } ! 104: u.u_r.r_val1 = u.u_limit[uap->which]; ! 105: if (uap->limit < 0) ! 106: return; ! 107: switch (uap->which) { ! 108: ! 109: case LIM_DATA: ! 110: if (uap->limit > ctob(maxdsize)) ! 111: uap->limit = ctob(maxdsize); ! 112: break; ! 113: ! 114: case LIM_TEXT: ! 115: if (uap->limit > ctob(maxtsize)) ! 116: uap->limit = ctob(maxtsize); ! 117: break; ! 118: ! 119: case LIM_STACK: ! 120: if (uap->limit > ctob(maxssize)) ! 121: uap->limit = ctob(maxssize); ! 122: break; ! 123: } ! 124: if (u.u_limit[LIM_NORAISE] && uap->limit > u.u_limit[uap->which] && ! 125: !suser()) { ! 126: u.u_error = EACCES; ! 127: return; ! 128: } ! 129: u.u_limit[uap->which] = uap->limit; ! 130: if (uap->which == LIM_MAXRSS) ! 131: u.u_procp->p_maxrss = uap->limit/NBPG; ! 132: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.