fix for savecore: disk drivers decrease bcount near end of partition,
[unix-history] / usr / src / sys / kern / kern_time.c
index 34e30fb..7a9a856 100644 (file)
@@ -1,20 +1,27 @@
 /*
 /*
- * 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.
+ * Copyright (c) 1982, 1986, 1989 Regents of the University of California.
+ * All rights reserved.
  *
  *
- *     @(#)kern_time.c 7.4 (Berkeley) %G%
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ *     @(#)kern_time.c 7.10 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
-#include "dir.h"               /* XXX */
 #include "user.h"
 #include "kernel.h"
 #include "user.h"
 #include "kernel.h"
-#include "inode.h"
 #include "proc.h"
 
 #include "proc.h"
 
-#include "../machine/reg.h"
-#include "../machine/cpu.h"
 
 /* 
  * Time of day and interval timer support.
 
 /* 
  * Time of day and interval timer support.
@@ -54,33 +61,25 @@ settimeofday()
        } *uap = (struct a *)u.u_ap;
        struct timeval atv;
        struct timezone atz;
        } *uap = (struct a *)u.u_ap;
        struct timeval atv;
        struct timezone atz;
+       int s;
 
 
+       if (u.u_error = suser(u.u_cred, &u.u_acflag))
+               return;
        if (uap->tv) {
                u.u_error = copyin((caddr_t)uap->tv, (caddr_t)&atv,
                        sizeof (struct timeval));
                if (u.u_error)
                        return;
        if (uap->tv) {
                u.u_error = copyin((caddr_t)uap->tv, (caddr_t)&atv,
                        sizeof (struct timeval));
                if (u.u_error)
                        return;
-               setthetime(&atv);
+               /* WHAT DO WE DO ABOUT PENDING REAL-TIME TIMEOUTS??? */
+               boottime.tv_sec += atv.tv_sec - time.tv_sec;
+               s = splhigh(); time = atv; splx(s);
+               resettodr();
        }
        }
-       if (uap->tzp && suser()) {
-               u.u_error = copyin((caddr_t)uap->tzp, (caddr_t)&atz,
-                       sizeof (atz));
-               if (u.u_error == 0)
-                       tz = atz;
-       }
-}
-
-setthetime(tv)
-       struct timeval *tv;
-{
-       int s;
-
-       if (!suser())
+       if (uap->tzp == 0)
                return;
                return;
-/* WHAT DO WE DO ABOUT PENDING REAL-TIME TIMEOUTS??? */
-       boottime.tv_sec += tv->tv_sec - time.tv_sec;
-       s = splhigh(); time = *tv; splx(s);
-       resettodr();
+       u.u_error = copyin((caddr_t)uap->tzp, (caddr_t)&atz, sizeof (atz));
+       if (u.u_error == 0)
+               tz = atz;
 }
 
 extern int tickadj;                    /* "standard" clock skew, us./tick */
 }
 
 extern int tickadj;                    /* "standard" clock skew, us./tick */
@@ -98,7 +97,7 @@ adjtime()
        register long ndelta;
        int s;
 
        register long ndelta;
        int s;
 
-       if (!suser()) 
+       if (u.u_error = suser(u.u_cred, &u.u_acflag))
                return;
        u.u_error = copyin((caddr_t)uap->delta, (caddr_t)&atv,
                sizeof (struct timeval));
                return;
        u.u_error = copyin((caddr_t)uap->delta, (caddr_t)&atv,
                sizeof (struct timeval));
@@ -156,7 +155,7 @@ getitimer()
        struct itimerval aitv;
        int s;
 
        struct itimerval aitv;
        int s;
 
-       if (uap->which > 2) {
+       if (uap->which > ITIMER_PROF) {
                u.u_error = EINVAL;
                return;
        }
                u.u_error = EINVAL;
                return;
        }
@@ -187,24 +186,25 @@ setitimer()
                u_int   which;
                struct  itimerval *itv, *oitv;
        } *uap = (struct a *)u.u_ap;
                u_int   which;
                struct  itimerval *itv, *oitv;
        } *uap = (struct a *)u.u_ap;
-       struct itimerval aitv, *aitvp;
+       struct itimerval aitv;
+       register struct itimerval *itvp;
        int s;
        register struct proc *p = u.u_procp;
 
        int s;
        register struct proc *p = u.u_procp;
 
-       if (uap->which > 2) {
+       if (uap->which > ITIMER_PROF) {
                u.u_error = EINVAL;
                return;
        }
                u.u_error = EINVAL;
                return;
        }
-       aitvp = uap->itv;
-       if (uap->oitv) {
-               uap->itv = uap->oitv;
+       itvp = uap->itv;
+       if (itvp && (u.u_error = copyin((caddr_t)itvp, (caddr_t)&aitv,
+           sizeof(struct itimerval))))
+               return;
+       if (uap->itv = uap->oitv) {
                getitimer();
                getitimer();
+               if (u.u_error)
+                       return;
        }
        }
-       if (aitvp == 0)
-               return;
-       u.u_error = copyin((caddr_t)aitvp, (caddr_t)&aitv,
-           sizeof (struct itimerval));
-       if (u.u_error)
+       if (itvp == 0)
                return;
        if (itimerfix(&aitv.it_value) || itimerfix(&aitv.it_interval)) {
                u.u_error = EINVAL;
                return;
        if (itimerfix(&aitv.it_value) || itimerfix(&aitv.it_interval)) {
                u.u_error = EINVAL;