. service tells you which device it couldn't stat
[minix3.git] / servers / pm / time.c
blobb5b519177ad6c4fd05dbe7d8aec744e00b941b9f
1 /* This file takes care of those system calls that deal with time.
3 * The entry points into this file are
4 * do_time: perform the TIME system call
5 * do_stime: perform the STIME system call
6 * do_times: perform the TIMES system call
7 */
9 #include "pm.h"
10 #include <minix/callnr.h>
11 #include <minix/com.h>
12 #include <signal.h>
13 #include "mproc.h"
14 #include "param.h"
16 /*===========================================================================*
17 * do_time *
18 *===========================================================================*/
19 PUBLIC int do_time()
21 /* Perform the time(tp) system call. This returns the time in seconds since
22 * 1.1.1970. MINIX is an astrophysically naive system that assumes the earth
23 * rotates at a constant rate and that such things as leap seconds do not
24 * exist.
26 clock_t uptime;
27 int s;
29 if ( (s=getuptime(&uptime)) != OK)
30 panic(__FILE__,"do_time couldn't get uptime", s);
32 mp->mp_reply.reply_time = (time_t) (boottime + (uptime/HZ));
33 mp->mp_reply.reply_utime = (uptime%HZ)*1000000/HZ;
34 return(OK);
37 /*===========================================================================*
38 * do_stime *
39 *===========================================================================*/
40 PUBLIC int do_stime()
42 /* Perform the stime(tp) system call. Retrieve the system's uptime (ticks
43 * since boot) and store the time in seconds at system boot in the global
44 * variable 'boottime'.
46 clock_t uptime;
47 int s;
49 if (mp->mp_effuid != SUPER_USER) {
50 return(EPERM);
52 if ( (s=getuptime(&uptime)) != OK)
53 panic(__FILE__,"do_stime couldn't get uptime", s);
54 boottime = (long) m_in.stime - (uptime/HZ);
56 if (mp->mp_fs_call != PM_IDLE)
57 panic("pm", "do_stime: not idle", mp->mp_fs_call);
58 mp->mp_fs_call= PM_STIME;
59 s= notify(FS_PROC_NR);
60 if (s != OK) panic("pm", "do_stime: unable to notify FS", s);
62 /* Do not reply until FS is ready to process the stime request */
63 return(SUSPEND);
66 /*===========================================================================*
67 * do_times *
68 *===========================================================================*/
69 PUBLIC int do_times()
71 /* Perform the times(buffer) system call. */
72 register struct mproc *rmp = mp;
73 clock_t t[5];
74 int s;
76 if (OK != (s=sys_times(who_e, t)))
77 panic(__FILE__,"do_times couldn't get times", s);
78 rmp->mp_reply.reply_t1 = t[0]; /* user time */
79 rmp->mp_reply.reply_t2 = t[1]; /* system time */
80 rmp->mp_reply.reply_t3 = rmp->mp_child_utime; /* child user time */
81 rmp->mp_reply.reply_t4 = rmp->mp_child_stime; /* child system time */
82 rmp->mp_reply.reply_t5 = t[4]; /* uptime since boot */
84 return(OK);