1*7424Sroot /* kern_time.c 5.1 82/07/15 */ 2*7424Sroot 3*7424Sroot #include "../h/param.h" 4*7424Sroot #include "../h/systm.h" 5*7424Sroot #include "../h/dir.h" 6*7424Sroot #include "../h/user.h" 7*7424Sroot #include "../h/reg.h" 8*7424Sroot #include "../h/inode.h" 9*7424Sroot #include "../h/proc.h" 10*7424Sroot #include "../h/clock.h" 11*7424Sroot #include "../h/mtpr.h" 12*7424Sroot #include "../h/timeb.h" 13*7424Sroot #include "../h/times.h" 14*7424Sroot #include "../h/reboot.h" 15*7424Sroot #include "../h/fs.h" 16*7424Sroot #include "../h/conf.h" 17*7424Sroot #include "../h/buf.h" 18*7424Sroot #include "../h/mount.h" 19*7424Sroot 20*7424Sroot /* 21*7424Sroot * return the current time (old-style entry) 22*7424Sroot */ 23*7424Sroot gtime() 24*7424Sroot { 25*7424Sroot u.u_r.r_time = time; 26*7424Sroot if (clkwrap()) 27*7424Sroot clkset(); 28*7424Sroot } 29*7424Sroot 30*7424Sroot /* 31*7424Sroot * New time entry-- return TOD with milliseconds, timezone, 32*7424Sroot * DST flag 33*7424Sroot */ 34*7424Sroot ftime() 35*7424Sroot { 36*7424Sroot register struct a { 37*7424Sroot struct timeb *tp; 38*7424Sroot } *uap; 39*7424Sroot struct timeb t; 40*7424Sroot register unsigned ms; 41*7424Sroot 42*7424Sroot uap = (struct a *)u.u_ap; 43*7424Sroot (void) spl7(); 44*7424Sroot t.time = time; 45*7424Sroot ms = lbolt; 46*7424Sroot (void) spl0(); 47*7424Sroot if (ms > hz) { 48*7424Sroot ms -= hz; 49*7424Sroot t.time++; 50*7424Sroot } 51*7424Sroot t.millitm = (1000*ms)/hz; 52*7424Sroot t.timezone = timezone; 53*7424Sroot t.dstflag = dstflag; 54*7424Sroot if (copyout((caddr_t)&t, (caddr_t)uap->tp, sizeof(t)) < 0) 55*7424Sroot u.u_error = EFAULT; 56*7424Sroot if (clkwrap()) 57*7424Sroot clkset(); 58*7424Sroot } 59*7424Sroot 60*7424Sroot /* 61*7424Sroot * Set the time 62*7424Sroot */ 63*7424Sroot stime() 64*7424Sroot { 65*7424Sroot register struct a { 66*7424Sroot time_t time; 67*7424Sroot } *uap; 68*7424Sroot 69*7424Sroot uap = (struct a *)u.u_ap; 70*7424Sroot if (suser()) { 71*7424Sroot bootime += uap->time - time; 72*7424Sroot time = uap->time; 73*7424Sroot clkset(); 74*7424Sroot } 75*7424Sroot } 76*7424Sroot 77*7424Sroot times() 78*7424Sroot { 79*7424Sroot register struct a { 80*7424Sroot time_t (*times)[4]; 81*7424Sroot } *uap; 82*7424Sroot struct tms tms; 83*7424Sroot 84*7424Sroot tms.tms_utime = u.u_vm.vm_utime; 85*7424Sroot tms.tms_stime = u.u_vm.vm_stime; 86*7424Sroot tms.tms_cutime = u.u_cvm.vm_utime; 87*7424Sroot tms.tms_cstime = u.u_cvm.vm_stime; 88*7424Sroot uap = (struct a *)u.u_ap; 89*7424Sroot if (copyout((caddr_t)&tms, (caddr_t)uap->times, sizeof(struct tms)) < 0) 90*7424Sroot u.u_error = EFAULT; 91*7424Sroot } 92