#endif
typedef struct {
- struct timeval tv;
+ struct timespec ts;
} ReqSetTime;
typedef struct {
/* ======================================================================= */
-/* HELPER - perform settimeofday() */
+/* HELPER - perform clock_settime() */
#ifdef PRIVOPS_SETTIME
static void
do_set_time(const ReqSetTime *req, PrvResponse *res)
{
- res->rc = settimeofday(&req->tv, NULL);
+ res->rc = clock_settime(CLOCK_REALTIME, &req->ts);
if (res->rc)
res->res_errno = errno;
}
/* ======================================================================= */
-/* DAEMON - request settimeofday() */
+/* DAEMON - request clock_settime() */
#ifdef PRIVOPS_SETTIME
int
-PRV_SetTime(const struct timeval *tp, const struct timezone *tzp)
+PRV_SetTime(clockid_t clockid, const struct timespec *tp)
{
PrvRequest req;
PrvResponse res;
- /* only support setting the time */
- assert(tp != NULL);
- assert(tzp == NULL);
+ if (clockid != CLOCK_REALTIME)
+ return -1;
if (!have_helper())
- return settimeofday(tp, NULL);
+ return clock_settime(clockid, tp);
memset(&req, 0, sizeof (req));
req.op = OP_SETTIME;
- req.data.set_time.tv = *tp;
+ req.data.set_time.ts = *tp;
submit_request(&req, &res);
#endif
#ifdef PRIVOPS_SETTIME
-int PRV_SetTime(const struct timeval *tp, const struct timezone *tzp);
+int PRV_SetTime(clockid_t clockid, const struct timespec *tp);
#else
-#define PRV_SetTime settimeofday
+#define PRV_SetTime clock_settime
#endif
#ifdef PRIVOPS_BINDSOCKET
apply_step_offset(double offset)
{
struct timespec old_time, new_time;
- struct timeval new_time_tv;
double err;
LCL_ReadRawTime(&old_time);
UTI_AddDoubleToTimespec(&old_time, -offset, &new_time);
- UTI_TimespecToTimeval(&new_time, &new_time_tv);
- if (PRV_SetTime(&new_time_tv, NULL) < 0) {
- DEBUG_LOG("settimeofday() failed");
+ if (PRV_SetTime(CLOCK_REALTIME, &new_time) < 0) {
+ DEBUG_LOG("clock_settime() failed");
return 0;
}
SCMP_SYS(clock_gettime64),
#endif
SCMP_SYS(gettimeofday),
- SCMP_SYS(settimeofday),
+ SCMP_SYS(clock_settime),
SCMP_SYS(time),
/* Process */
UTI_AddDoubleToTimespec(&old_time, -offset, &new_time);
UTI_TimespecToTimeval(&new_time, &new_time_tv);
- if (PRV_SetTime(&new_time_tv, NULL) < 0) {
- DEBUG_LOG("settimeofday() failed");
+ if (PRV_SetTime(CLOCK_REALTIME, &new_time_tv) < 0) {
+ DEBUG_LOG("clock_settime() failed");
return 0;
}