more-or-less working with new proc & user structs
[unix-history] / usr / src / sys / kern / kern_xxx.c
index 6466d0c..dcde651 100644 (file)
-/*     kern_xxx.c      4.3     83/06/02        */
-
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/kernel.h"
-#include "../h/proc.h"
-#include "../h/reboot.h"
-
-gethostid()
-{
+/*
+ * Copyright (c) 1982, 1986, 1989 Regents of the University of California.
+ * All rights reserved.
+ *
+ * %sccs.include.redist.c%
+ *
+ *     @(#)kern_xxx.c  7.16 (Berkeley) %G%
+ */
 
 
-       u.u_r.r_val1 = hostid;
-}
+#include "param.h"
+#include "systm.h"
+#include "user.h"
+#include "kernel.h"
+#include "proc.h"
+#include "reboot.h"
 
 
-sethostid()
+/* ARGSUSED */
+gethostid(p, uap, retval)
+       struct proc *p;
+       void *uap;
+       long *retval;
 {
 {
-       struct a {
-               int     hostid;
-       } *uap = (struct a *)u.u_ap;
 
 
-       if (suser())
-               hostid = uap->hostid;
+       *retval = hostid;
+       return (0);
 }
 
 }
 
-gethostname()
+/* ARGSUSED */
+sethostid(p, uap, retval)
+       struct proc *p;
+       struct args {
+               long    hostid;
+       } *uap;
+       int *retval;
 {
 {
-       register struct a {
-               char    *hostname;
-               int     len;
-       } *uap = (struct a *)u.u_ap;
-       register u_int len;
+       int error;
 
 
-       len = uap->len;
-       if (len > hostnamelen + 1)
-               len = hostnamelen + 1;
-       u.u_error = copyout((caddr_t)hostname, (caddr_t)uap->hostname, len);
 }
 
 }
 
-sethostname()
-{
-       register struct a {
+/* ARGSUSED */
+gethostname(p, uap, retval)
+       struct proc *p;
+       struct args {
                char    *hostname;
                u_int   len;
                char    *hostname;
                u_int   len;
-       } *uap = (struct a *)u.u_ap;
-
-       if (!suser())
-               return;
-       if (uap->len > sizeof (hostname) - 1) {
-               u.u_error = EINVAL;
-               return;
-       }
-       hostnamelen = uap->len;
-       u.u_error = copyin((caddr_t)uap->hostname, hostname, uap->len);
-       hostname[hostnamelen] = 0;
-}
-
-reboot()
-{
-       register struct a {
-               int     opt;
-       };
-
-       if (suser())
-               boot(RB_BOOT, ((struct a *)u.u_ap)->opt);
-}
-
-#ifndef NOCOMPAT
-#include "../h/quota.h"
-
-osetuid()
-{
-       register uid;
-       register struct a {
-               int     uid;
        } *uap;
        } *uap;
-
-       uap = (struct a *)u.u_ap;
-       uid = uap->uid;
-       if (u.u_ruid == uid || u.u_uid == uid || suser()) {
-#ifdef QUOTA
-               if (u.u_quota->q_uid != uid) {
-                       qclean();
-                       qstart(getquota(uid, 0, 0));
-               }
-#endif
-               u.u_uid = uid;
-               u.u_procp->p_uid = uid;
-               u.u_ruid = uid;
-       }
-}
-
-osetgid()
+       int *retval;
 {
 {
-       register gid;
-       register struct a {
-               int     gid;
-       } *uap;
 
 
-       uap = (struct a *)u.u_ap;
-       gid = uap->gid;
-       if (u.u_rgid == gid || u.u_gid == gid || suser()) {
-               leavegroup(u.u_rgid);
-               (void) entergroup(gid);
-               u.u_gid = gid;
-               u.u_rgid = gid;
-       }
+       if (uap->len > hostnamelen + 1)
+               uap->len = hostnamelen + 1;
+       return (copyout((caddr_t)hostname, (caddr_t)uap->hostname, uap->len));
 }
 
 }
 
-/*
- * Pid of zero implies current process.
- * Pgrp -1 is getpgrp system call returning
- * current process group.
- */
-osetpgrp()
-{
-       register struct proc *p;
-       register struct a {
-               int     pid;
-               int     pgrp;
+/* ARGSUSED */
+sethostname(p, uap, retval)
+       struct proc *p;
+       register struct args {
+               char    *hostname;
+               u_int   len;
        } *uap;
        } *uap;
-
-       uap = (struct a *)u.u_ap;
-       if (uap->pid == 0)
-               p = u.u_procp;
-       else {
-               p = pfind(uap->pid);
-               if (p == 0) {
-                       u.u_error = ESRCH;
-                       return;
-               }
-       }
-       if (uap->pgrp <= 0) {
-               u.u_r.r_val1 = p->p_pgrp;
-               return;
-       }
-       if (p->p_uid != u.u_uid && u.u_uid && !inferior(p)) {
-               u.u_error = EPERM;
-               return;
-       }
-       p->p_pgrp = uap->pgrp;
-}
-
-otime()
+       int *retval;
 {
 {
+       int error;
 
 
-       u.u_r.r_time = time.tv_sec;
-}
-
-ostime()
-{
-       register struct a {
-               int     time;
-       } *uap = (struct a *)u.u_ap;
-       struct timeval tv;
-
-       tv.tv_sec = uap->time;
-       tv.tv_usec = 0;
-       setthetime(&tv);
+       if (error = suser(p->p_ucred, &p->p_acflag))
+               return (error);
+       if (uap->len > sizeof (hostname) - 1)
+               return (EINVAL);
+       hostnamelen = uap->len;
+       error = copyin((caddr_t)uap->hostname, hostname, uap->len);
+       hostname[hostnamelen] = 0;
+       return (error);
 }
 
 }
 
-/* from old timeb.h */
-struct timeb {
-       time_t  time;
-       u_short millitm;
-       short   timezone;
-       short   dstflag;
-};
-
-oftime()
-{
-       register struct a {
-               struct  timeb   *tp;
+/* ARGSUSED */
+reboot(p, uap, retval)
+       struct proc *p;
+       struct args {
+               int     opt;
        } *uap;
        } *uap;
-       struct timeb tb;
-
-       uap = (struct a *)u.u_ap;
-       (void) spl7();
-       tb.time = time.tv_sec;
-       tb.millitm = time.tv_usec / 1000;
-       (void) spl0();
-       tb.timezone = tz.tz_minuteswest;
-       tb.dstflag = tz.tz_dsttime;
-       u.u_error = copyout((caddr_t)&tb, (caddr_t)uap->tp, sizeof (tb));
-}
-
-oalarm()
-{
-       register struct a {
-               int     deltat;
-       } *uap = (struct a *)u.u_ap;
-       register struct proc *p = u.u_procp;
-       int s = spl7();
-
-       untimeout(realitexpire, (caddr_t)p);
-       timerclear(&p->p_realtimer.it_interval);
-       u.u_r.r_val1 = 0;
-       if (timerisset(&p->p_realtimer.it_value) &&
-           timercmp(&p->p_realtimer.it_value, &time, >))
-               u.u_r.r_val1 = p->p_realtimer.it_value.tv_sec - time.tv_sec;
-       if (uap->deltat == 0) {
-               timerclear(&p->p_realtimer.it_value);
-               splx(s);
-               return;
-       }
-       p->p_realtimer.it_value = time;
-       p->p_realtimer.it_value.tv_sec += uap->deltat;
-       timeout(realitexpire, (caddr_t)p, hzto(&p->p_realtimer.it_value));
-       splx(s);
-}
-
-onice()
-{
-       register struct a {
-               int     niceness;
-       } *uap = (struct a *)u.u_ap;
-       register struct proc *p = u.u_procp;
-
-       donice(p, (p->p_nice-NZERO)+uap->niceness);
-}
-
-#include "../h/times.h"
-
-otimes()
-{
-       register struct a {
-               struct  tms *tmsb;
-       } *uap = (struct a *)u.u_ap;
-       struct tms atms;
-
-       atms.tms_utime = scale60(&u.u_ru.ru_utime);
-       atms.tms_stime = scale60(&u.u_ru.ru_stime);
-       atms.tms_cutime = scale60(&u.u_cru.ru_utime);
-       atms.tms_cstime = scale60(&u.u_cru.ru_stime);
-       u.u_error = copyout((caddr_t)&atms, (caddr_t)uap->tmsb, sizeof (atms));
-}
-
-scale60(tvp)
-       register struct timeval *tvp;
-{
-
-       return (tvp->tv_sec * 60 + tvp->tv_usec / 16667);
-}
-
-#include "../h/vtimes.h"
-
-ovtimes()
-{
-       register struct a {
-               struct  vtimes *par;
-               struct  vtimes *chi;
-       } *uap = (struct a *)u.u_ap;
-       struct vtimes avt;
-
-       if (uap->par) {
-               getvtimes(&u.u_ru, &avt);
-               u.u_error = copyout((caddr_t)&avt, (caddr_t)uap->par,
-                       sizeof (avt));
-               if (u.u_error)
-                       return;
-       }
-       if (uap->chi) {
-               getvtimes(&u.u_cru, &avt);
-               u.u_error = copyout((caddr_t)&avt, (caddr_t)uap->chi,
-                       sizeof (avt));
-               if (u.u_error)
-                       return;
-       }
-}
-
-#include "../machine/psl.h"
-#include "../machine/reg.h"
-
-owait()
-{
-       struct rusage ru;
-       struct vtimes *vtp, avt;
-
-       if ((u.u_ar0[PS] & PSL_ALLCC) != PSL_ALLCC) {
-               u.u_error = wait1(0, (struct rusage *)0);
-               return;
-       }
-       vtp = (struct vtimes *)u.u_ar0[R1];
-       u.u_error = wait1(u.u_ar0[R0], &ru);
-       if (u.u_error)
-               return;
-       getvtimes(&ru, &avt);
-       (void) copyout((caddr_t)&avt, (caddr_t)vtp, sizeof (struct vtimes));
-}
-
-getvtimes(aru, avt)
-       register struct rusage *aru;
-       register struct vtimes *avt;
-{
-
-       avt->vm_utime = scale60(&aru->ru_utime);
-       avt->vm_stime = scale60(&aru->ru_stime);
-       avt->vm_idsrss = ((aru->ru_idrss+aru->ru_isrss) / hz) * 60;
-       avt->vm_ixrss = aru->ru_ixrss / hz * 60;
-       avt->vm_maxrss = aru->ru_maxrss;
-       avt->vm_majflt = aru->ru_majflt;
-       avt->vm_minflt = aru->ru_minflt;
-       avt->vm_nswap = aru->ru_nswap;
-       avt->vm_inblk = aru->ru_inblock;
-       avt->vm_oublk = aru->ru_oublock;
-}
-
-ovlimit()
+       int *retval;
 {
 {
+       int error;
 
 
-       u.u_error = EACCES;
 }
 
 }
 
-okill()
+ovhangup()
 {
 {
-       register struct a {
-               int     pid;
-               int     signo;
-       } *uap = (struct a *)u.u_ap;
 
 
-       u.u_error = kill1(uap->signo < 0,
-               uap->signo < 0 ? -uap->signo : uap->signo, uap->pid);
+       return (EINVAL);
 }
 
 }
 
-ossig()
+oldquota()
 {
 {
-       struct a {
-               int     signo;
-               int     (*fun)();
-       } *uap = (struct a *)u.u_ap;
-       register int a, (*f)();
-       struct proc *p = u.u_procp;
 
 
-       f = uap->fun;
-       a = uap->signo;
-       /*
-        * Kill processes trying to use job control facilities
-        * (this'll help us find any vestiges of the old stuff).
-        */
-       if ((a &~ 0377) ||
-           (f != SIG_DFL && f != SIG_IGN && ((int)f) & 1)) {
-               psignal(p, SIGSYS);
-               return;
-       }
-       if (a <= 0 || a >= NSIG || a == SIGKILL || a == SIGSTOP ||
-           a == SIGCONT && (f == SIG_IGN || f == SIG_HOLD)) {
-               u.u_error = EINVAL;
-               return;
-       }
-       setsignal(a, f, 0);
-       p->p_flag |= SOUSIG;            /* mark as simulating old stuff */
+       return (EINVAL);
 }
 }
-#endif