libc: add adjtime() system call.

Implement the adjtime() system call and add a test for it to test69.
Additionally, install the adjtime.2 and clock_*.2 man pages.
This commit is contained in:
Thomas Cort
2013-03-31 01:24:24 +00:00
committed by Ben Gras
parent 516fec97d9
commit 15b3d77268
13 changed files with 136 additions and 14 deletions

View File

@@ -17,12 +17,20 @@
*===========================================================================*/
int do_settime(struct proc * caller, message * m_ptr)
{
clock_t newclock;
clock_t newclock, ticks;
time_t timediff;
if (m_ptr->T_CLOCK_ID != CLOCK_REALTIME) /* only realtime can change */
return EINVAL;
if (m_ptr->T_SETTIME_NOW == 0) { /* user just wants to adjtime() */
/* convert delta value from seconds and nseconds to ticks */
ticks = (m_ptr->T_TIME_SEC * system_hz) +
(m_ptr->T_TIME_NSEC/(1000000000/system_hz));
set_adjtime_delta(ticks);
return(OK);
} /* else user wants to set the time */
/* prevent a negative value for realtime */
if (m_ptr->T_TIME_SEC <= boottime) {
/* boottime was likely wrong, try to correct it. */
@@ -35,9 +43,7 @@ int do_settime(struct proc * caller, message * m_ptr)
timediff = m_ptr->T_TIME_SEC - boottime;
newclock = (timediff*system_hz) + (m_ptr->T_TIME_NSEC/(1000000000/system_hz));
if (m_ptr->T_SETTIME_NOW) {
set_realtime(newclock);
} /* else used adjtime() method (to be implemented) */
set_realtime(newclock);
return(OK);
}