1: /*
   2:  * Copyright (c) 1982, 1986 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  *
   6:  *	@(#)kern_xxx.c	7.1 (Berkeley) 6/5/86
   7:  */
   8: 
   9: #include "param.h"
  10: #include "systm.h"
  11: #include "dir.h"
  12: #include "user.h"
  13: #include "kernel.h"
  14: #include "proc.h"
  15: #include "reboot.h"
  16: 
  17: gethostid()
  18: {
  19: 
  20:     u.u_r.r_val1 = hostid;
  21: }
  22: 
  23: sethostid()
  24: {
  25:     struct a {
  26:         long    hostid;
  27:     } *uap = (struct a *)u.u_ap;
  28: 
  29:     if (suser())
  30:         hostid = uap->hostid;
  31: }
  32: 
  33: gethostname()
  34: {
  35:     register struct a {
  36:         char    *hostname;
  37:         u_int   len;
  38:     } *uap = (struct a *)u.u_ap;
  39:     register u_int len;
  40: 
  41:     len = uap->len;
  42:     if (len > hostnamelen + 1)
  43:         len = hostnamelen + 1;
  44:     u.u_error = copyout((caddr_t)hostname, (caddr_t)uap->hostname, len);
  45: }
  46: 
  47: sethostname()
  48: {
  49:     register struct a {
  50:         char    *hostname;
  51:         u_int   len;
  52:     } *uap = (struct a *)u.u_ap;
  53: 
  54:     if (!suser())
  55:         return;
  56:     if (uap->len > sizeof (hostname) - 1) {
  57:         u.u_error = EINVAL;
  58:         return;
  59:     }
  60:     hostnamelen = uap->len;
  61:     u.u_error = copyin((caddr_t)uap->hostname, hostname, uap->len);
  62:     hostname[hostnamelen] = 0;
  63: }
  64: 
  65: reboot()
  66: {
  67:     register struct a {
  68:         int opt;
  69:     };
  70: 
  71:     if (suser())
  72:         boot(RB_BOOT, ((struct a *)u.u_ap)->opt);
  73: }
  74: 
  75: #ifdef COMPAT
  76: #include "../h/quota.h"
  77: 
  78: osetuid()
  79: {
  80:     register uid;
  81:     register struct a {
  82:         int uid;
  83:     } *uap;
  84: 
  85:     uap = (struct a *)u.u_ap;
  86:     uid = uap->uid;
  87:     if (u.u_ruid == uid || u.u_uid == uid || suser()) {
  88: #ifdef QUOTA
  89:         if (u.u_quota->q_uid != uid) {
  90:             qclean();
  91:             qstart(getquota(uid, 0, 0));
  92:         }
  93: #endif
  94:         u.u_uid = uid;
  95:         u.u_procp->p_uid = uid;
  96:         u.u_ruid = uid;
  97:     }
  98: }
  99: 
 100: osetgid()
 101: {
 102:     register gid;
 103:     register struct a {
 104:         int gid;
 105:     } *uap;
 106: 
 107:     uap = (struct a *)u.u_ap;
 108:     gid = uap->gid;
 109:     if (u.u_rgid == gid || u.u_gid == gid || suser()) {
 110:         leavegroup(u.u_rgid);
 111:         (void) entergroup(gid);
 112:         u.u_gid = gid;
 113:         u.u_rgid = gid;
 114:     }
 115: }
 116: 
 117: /*
 118:  * Pid of zero implies current process.
 119:  * Pgrp -1 is getpgrp system call returning
 120:  * current process group.
 121:  */
 122: osetpgrp()
 123: {
 124:     register struct proc *p;
 125:     register struct a {
 126:         int pid;
 127:         int pgrp;
 128:     } *uap;
 129: 
 130:     uap = (struct a *)u.u_ap;
 131:     if (uap->pid == 0)
 132:         p = u.u_procp;
 133:     else {
 134:         p = pfind(uap->pid);
 135:         if (p == 0) {
 136:             u.u_error = ESRCH;
 137:             return;
 138:         }
 139:     }
 140:     if (uap->pgrp <= 0) {
 141:         u.u_r.r_val1 = p->p_pgrp;
 142:         return;
 143:     }
 144:     if (p->p_uid != u.u_uid && u.u_uid && !inferior(p)) {
 145:         u.u_error = EPERM;
 146:         return;
 147:     }
 148:     p->p_pgrp = uap->pgrp;
 149: }
 150: 
 151: otime()
 152: {
 153: 
 154:     u.u_r.r_time = time.tv_sec;
 155: }
 156: 
 157: ostime()
 158: {
 159:     register struct a {
 160:         int time;
 161:     } *uap = (struct a *)u.u_ap;
 162:     struct timeval tv;
 163: 
 164:     tv.tv_sec = uap->time;
 165:     tv.tv_usec = 0;
 166:     setthetime(&tv);
 167: }
 168: 
 169: /* from old timeb.h */
 170: struct timeb {
 171:     time_t  time;
 172:     u_short millitm;
 173:     short   timezone;
 174:     short   dstflag;
 175: };
 176: 
 177: oftime()
 178: {
 179:     register struct a {
 180:         struct  timeb   *tp;
 181:     } *uap;
 182:     struct timeb tb;
 183:     int s;
 184: 
 185:     uap = (struct a *)u.u_ap;
 186:     s = splhigh();
 187:     tb.time = time.tv_sec;
 188:     tb.millitm = time.tv_usec / 1000;
 189:     splx(s);
 190:     tb.timezone = tz.tz_minuteswest;
 191:     tb.dstflag = tz.tz_dsttime;
 192:     u.u_error = copyout((caddr_t)&tb, (caddr_t)uap->tp, sizeof (tb));
 193: }
 194: 
 195: oalarm()
 196: {
 197:     register struct a {
 198:         int deltat;
 199:     } *uap = (struct a *)u.u_ap;
 200:     register struct proc *p = u.u_procp;
 201:     int s = splhigh();
 202: 
 203:     untimeout(realitexpire, (caddr_t)p);
 204:     timerclear(&p->p_realtimer.it_interval);
 205:     u.u_r.r_val1 = 0;
 206:     if (timerisset(&p->p_realtimer.it_value) &&
 207:         timercmp(&p->p_realtimer.it_value, &time, >))
 208:         u.u_r.r_val1 = p->p_realtimer.it_value.tv_sec - time.tv_sec;
 209:     if (uap->deltat == 0) {
 210:         timerclear(&p->p_realtimer.it_value);
 211:         splx(s);
 212:         return;
 213:     }
 214:     p->p_realtimer.it_value = time;
 215:     p->p_realtimer.it_value.tv_sec += uap->deltat;
 216:     timeout(realitexpire, (caddr_t)p, hzto(&p->p_realtimer.it_value));
 217:     splx(s);
 218: }
 219: 
 220: onice()
 221: {
 222:     register struct a {
 223:         int niceness;
 224:     } *uap = (struct a *)u.u_ap;
 225:     register struct proc *p = u.u_procp;
 226: 
 227:     donice(p, (p->p_nice-NZERO)+uap->niceness);
 228: }
 229: 
 230: #include "../h/times.h"
 231: 
 232: otimes()
 233: {
 234:     register struct a {
 235:         struct  tms *tmsb;
 236:     } *uap = (struct a *)u.u_ap;
 237:     struct tms atms;
 238: 
 239:     atms.tms_utime = scale60(&u.u_ru.ru_utime);
 240:     atms.tms_stime = scale60(&u.u_ru.ru_stime);
 241:     atms.tms_cutime = scale60(&u.u_cru.ru_utime);
 242:     atms.tms_cstime = scale60(&u.u_cru.ru_stime);
 243:     u.u_error = copyout((caddr_t)&atms, (caddr_t)uap->tmsb, sizeof (atms));
 244: }
 245: 
 246: scale60(tvp)
 247:     register struct timeval *tvp;
 248: {
 249: 
 250:     return (tvp->tv_sec * 60 + tvp->tv_usec / 16667);
 251: }
 252: 
 253: #include "../h/vtimes.h"
 254: 
 255: ovtimes()
 256: {
 257:     register struct a {
 258:         struct  vtimes *par;
 259:         struct  vtimes *chi;
 260:     } *uap = (struct a *)u.u_ap;
 261:     struct vtimes avt;
 262: 
 263:     if (uap->par) {
 264:         getvtimes(&u.u_ru, &avt);
 265:         u.u_error = copyout((caddr_t)&avt, (caddr_t)uap->par,
 266:             sizeof (avt));
 267:         if (u.u_error)
 268:             return;
 269:     }
 270:     if (uap->chi) {
 271:         getvtimes(&u.u_cru, &avt);
 272:         u.u_error = copyout((caddr_t)&avt, (caddr_t)uap->chi,
 273:             sizeof (avt));
 274:         if (u.u_error)
 275:             return;
 276:     }
 277: }
 278: 
 279: #include "../machine/psl.h"
 280: #include "../machine/reg.h"
 281: 
 282: owait()
 283: {
 284:     struct rusage ru;
 285:     struct vtimes *vtp, avt;
 286: 
 287:     if ((u.u_ar0[PS] & PSL_ALLCC) != PSL_ALLCC) {
 288:         u.u_error = wait1(0, (struct rusage *)0);
 289:         return;
 290:     }
 291:     vtp = (struct vtimes *)u.u_ar0[R1];
 292:     u.u_error = wait1(u.u_ar0[R0], &ru);
 293:     if (u.u_error)
 294:         return;
 295:     getvtimes(&ru, &avt);
 296:     (void) copyout((caddr_t)&avt, (caddr_t)vtp, sizeof (struct vtimes));
 297: }
 298: 
 299: getvtimes(aru, avt)
 300:     register struct rusage *aru;
 301:     register struct vtimes *avt;
 302: {
 303: 
 304:     avt->vm_utime = scale60(&aru->ru_utime);
 305:     avt->vm_stime = scale60(&aru->ru_stime);
 306:     avt->vm_idsrss = ((aru->ru_idrss+aru->ru_isrss) / hz) * 60;
 307:     avt->vm_ixrss = aru->ru_ixrss / hz * 60;
 308:     avt->vm_maxrss = aru->ru_maxrss;
 309:     avt->vm_majflt = aru->ru_majflt;
 310:     avt->vm_minflt = aru->ru_minflt;
 311:     avt->vm_nswap = aru->ru_nswap;
 312:     avt->vm_inblk = aru->ru_inblock;
 313:     avt->vm_oublk = aru->ru_oublock;
 314: }
 315: 
 316: ovlimit()
 317: {
 318: 
 319:     u.u_error = EACCES;
 320: }
 321: 
 322: ossig()
 323: {
 324:     struct a {
 325:         int signo;
 326:         int (*fun)();
 327:     } *uap = (struct a *)u.u_ap;
 328:     register int a;
 329:     struct sigvec vec;
 330:     register struct sigvec *sv = &vec;
 331:     struct proc *p = u.u_procp;
 332: 
 333:     a = uap->signo;
 334:     sv->sv_handler = uap->fun;
 335:     /*
 336: 	 * Kill processes trying to use job control facilities
 337: 	 * (this'll help us find any vestiges of the old stuff).
 338: 	 */
 339:     if ((a &~ 0377) ||
 340:         (sv->sv_handler != SIG_DFL && sv->sv_handler != SIG_IGN &&
 341:          ((int)sv->sv_handler) & 1)) {
 342:         psignal(p, SIGSYS);
 343:         return;
 344:     }
 345:     if (a <= 0 || a >= NSIG || a == SIGKILL || a == SIGSTOP ||
 346:         a == SIGCONT && sv->sv_handler == SIG_IGN) {
 347:         u.u_error = EINVAL;
 348:         return;
 349:     }
 350:     sv->sv_mask = 0;
 351:     sv->sv_flags = SV_INTERRUPT;
 352:     u.u_r.r_val1 = (int)u.u_signal[a];
 353:     setsigvec(a, sv);
 354:     p->p_flag |= SOUSIG;        /* mark as simulating old stuff */
 355: }
 356: #endif

Defined functions

gethostid defined in line 17; used 2 times
gethostname defined in line 33; used 2 times
getvtimes defined in line 299; used 3 times
oalarm defined in line 195; used 1 times
oftime defined in line 177; used 1 times
onice defined in line 220; used 1 times
osetgid defined in line 100; used 1 times
osetpgrp defined in line 122; used 1 times
osetuid defined in line 78; used 1 times
ossig defined in line 322; used 1 times
ostime defined in line 157; used 1 times
otime defined in line 151; used 1 times
otimes defined in line 232; used 1 times
ovlimit defined in line 316; used 1 times
ovtimes defined in line 255; used 1 times
owait defined in line 282; used 1 times
reboot defined in line 65; used 2 times
scale60 defined in line 246; used 6 times
sethostid defined in line 23; used 2 times
sethostname defined in line 47; used 2 times

Defined struct's

a defined in line 324; used 28 times
timeb defined in line 170; used 4 times
Last modified: 1986-06-05
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1412
Valid CSS Valid XHTML 1.0 Strict