Changed clocktl interface to use syscallargs structures
This commit is contained in:
parent
6dce2e2bec
commit
3cdc6f6197
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: clockctl.c,v 1.3 2001/11/15 09:48:03 lukem Exp $ */
|
||||
/* $NetBSD: clockctl.c,v 1.4 2001/12/09 16:10:43 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -31,7 +31,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.3 2001/11/15 09:48:03 lukem Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.4 2001/12/09 16:10:43 manu Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -91,28 +91,31 @@ clockctlioctl(dev, cmd, data, flags, p)
|
|||
|
||||
switch (cmd) {
|
||||
case CLOCKCTL_SETTIMEOFDAY: {
|
||||
struct clockctl_settimeofday_args *args =
|
||||
(struct clockctl_settimeofday_args *)&data;
|
||||
struct sys_settimeofday_args *args =
|
||||
(struct sys_settimeofday_args *)data;
|
||||
|
||||
error = settimeofday1(&args->tv, &args->tzp, p);
|
||||
error = settimeofday1(SCARG(args, tv),
|
||||
SCARG(args, tzp), p);
|
||||
if (error)
|
||||
return (error);
|
||||
break;
|
||||
}
|
||||
case CLOCKCTL_ADJTIME: {
|
||||
struct clockctl_adjtime_args *args =
|
||||
(struct clockctl_adjtime_args *)&data;
|
||||
struct sys_adjtime_args *args =
|
||||
(struct sys_adjtime_args *)data;
|
||||
|
||||
error = adjtime1(&args->delta, &args->olddelta, p);
|
||||
error = adjtime1(SCARG(args, delta),
|
||||
SCARG(args, olddelta), p);
|
||||
if (error)
|
||||
return (error);
|
||||
break;
|
||||
}
|
||||
case CLOCKCTL_CLOCK_SETTIME: {
|
||||
struct clockctl_clock_settime_args *args =
|
||||
(struct clockctl_clock_settime_args *)&data;
|
||||
struct sys_clock_settime_args *args =
|
||||
(struct sys_clock_settime_args *)data;
|
||||
|
||||
error = clock_settime1(args->clock_id, &args->tp);
|
||||
error = clock_settime1(SCARG(args, clock_id),
|
||||
SCARG(args, tp));
|
||||
if (error)
|
||||
return (error);
|
||||
break;
|
||||
|
@ -120,9 +123,9 @@ clockctlioctl(dev, cmd, data, flags, p)
|
|||
#ifdef NTP
|
||||
case CLOCKCTL_NTP_ADJTIME: {
|
||||
struct clockctl_ntp_adjtime_args *args =
|
||||
(struct clockctl_ntp_adjtime_args *)&data;
|
||||
(struct clockctl_ntp_adjtime_args *)data;
|
||||
|
||||
(void*)ntp_adjtime1(&args->tp, &error);
|
||||
(void*)ntp_adjtime1(SCARG(args.uas,tp), &error);
|
||||
return (error);
|
||||
}
|
||||
#endif /* NTP */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_ntptime.c,v 1.16 2001/11/12 15:25:12 lukem Exp $ */
|
||||
/* $NetBSD: kern_ntptime.c,v 1.17 2001/12/09 16:10:43 manu Exp $ */
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
|
@ -50,7 +50,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_ntptime.c,v 1.16 2001/11/12 15:25:12 lukem Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_ntptime.c,v 1.17 2001/12/09 16:10:43 manu Exp $");
|
||||
|
||||
#include "opt_ntp.h"
|
||||
|
||||
|
@ -210,7 +210,6 @@ sys_ntp_adjtime(p, v, retval)
|
|||
sizeof(ntv))) != 0)
|
||||
return (error);
|
||||
|
||||
|
||||
if (ntv.modes != 0 && (error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
||||
return (error);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_time.c,v 1.59 2001/11/13 00:34:21 christos Exp $ */
|
||||
/* $NetBSD: kern_time.c,v 1.60 2001/12/09 16:10:43 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
|
@ -72,7 +72,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.59 2001/11/13 00:34:21 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.60 2001/12/09 16:10:43 manu Exp $");
|
||||
|
||||
#include "fs_nfs.h"
|
||||
#include "opt_nfs.h"
|
||||
|
@ -188,34 +188,31 @@ sys_clock_settime(p, v, retval)
|
|||
syscallarg(clockid_t) clock_id;
|
||||
syscallarg(const struct timespec *) tp;
|
||||
} */ *uap = v;
|
||||
clockid_t clock_id;
|
||||
struct timespec ats;
|
||||
int error;
|
||||
|
||||
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
||||
return (error);
|
||||
|
||||
clock_id = SCARG(uap, clock_id);
|
||||
|
||||
if ((error = copyin(SCARG(uap, tp), &ats, sizeof(ats))) != 0)
|
||||
return (error);
|
||||
|
||||
return (clock_settime1(clock_id, &ats));
|
||||
return (clock_settime1(SCARG(uap, clock_id), SCARG(uap, tp)));
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
clock_settime1(clock_id, ats)
|
||||
clock_settime1(clock_id, tp)
|
||||
clockid_t clock_id;
|
||||
struct timespec *ats;
|
||||
const struct timespec *tp;
|
||||
{
|
||||
struct timespec ats;
|
||||
struct timeval atv;
|
||||
int error;
|
||||
|
||||
if ((error = copyin(tp, &ats, sizeof(ats))) != 0)
|
||||
return (error);
|
||||
|
||||
if (clock_id != CLOCK_REALTIME)
|
||||
return (EINVAL);
|
||||
|
||||
TIMESPEC_TO_TIMEVAL(&atv, ats);
|
||||
TIMESPEC_TO_TIMEVAL(&atv, &ats);
|
||||
if ((error = settime(&atv)) != 0)
|
||||
return (error);
|
||||
|
||||
|
@ -357,39 +354,39 @@ sys_settimeofday(p, v, retval)
|
|||
syscallarg(const struct timeval *) tv;
|
||||
syscallarg(const struct timezone *) tzp;
|
||||
} */ *uap = v;
|
||||
int error;
|
||||
|
||||
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
||||
return (error);
|
||||
|
||||
return settimeofday1(SCARG(uap, tv), SCARG(uap, tzp), p);
|
||||
}
|
||||
|
||||
int
|
||||
settimeofday1(utv, utzp, p)
|
||||
const struct timeval *utv;
|
||||
const struct timezone *utzp;
|
||||
struct proc *p;
|
||||
{
|
||||
struct timeval atv;
|
||||
struct timezone atz;
|
||||
struct timeval *tv = NULL;
|
||||
struct timezone *tzp = NULL;
|
||||
int error;
|
||||
|
||||
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
||||
return (error);
|
||||
|
||||
/* Verify all parameters before changing time. */
|
||||
if (SCARG(uap, tv)) {
|
||||
if ((error = copyin(SCARG(uap, tv), &atv, sizeof(atv))) != 0)
|
||||
if (utv) {
|
||||
if ((error = copyin(utv, &atv, sizeof(atv))) != 0)
|
||||
return (error);
|
||||
tv = &atv;
|
||||
}
|
||||
/* XXX since we don't use tz, probably no point in doing copyin. */
|
||||
if (SCARG(uap, tzp)) {
|
||||
if ((error = copyin(SCARG(uap, tzp), &atz, sizeof(atz))) != 0)
|
||||
if (utzp) {
|
||||
if ((error = copyin(utzp, &atz, sizeof(atz))) != 0)
|
||||
return (error);
|
||||
tzp = &atz;
|
||||
}
|
||||
|
||||
return settimeofday1(tv, tzp, p);
|
||||
}
|
||||
|
||||
int
|
||||
settimeofday1(tv, tzp, p)
|
||||
struct timeval *tv;
|
||||
struct timezone *tzp;
|
||||
struct proc *p;
|
||||
{
|
||||
int error;
|
||||
|
||||
if (tv)
|
||||
if ((error = settime(tv)) != 0)
|
||||
return (error);
|
||||
|
@ -418,36 +415,37 @@ sys_adjtime(p, v, retval)
|
|||
syscallarg(const struct timeval *) delta;
|
||||
syscallarg(struct timeval *) olddelta;
|
||||
} */ *uap = v;
|
||||
struct timeval atv;
|
||||
struct timeval *oatv = NULL;
|
||||
int error;
|
||||
|
||||
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
||||
return (error);
|
||||
|
||||
error = copyin(SCARG(uap, delta), &atv, sizeof(struct timeval));
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
if (SCARG(uap, olddelta) != NULL) {
|
||||
if (uvm_useracc((caddr_t)SCARG(uap, olddelta),
|
||||
sizeof(struct timeval), B_WRITE) == FALSE)
|
||||
return (EFAULT);
|
||||
oatv = SCARG(uap, olddelta);
|
||||
}
|
||||
|
||||
return adjtime1(&atv, oatv, p);
|
||||
return adjtime1(SCARG(uap, delta), SCARG(uap, olddelta), p);
|
||||
}
|
||||
|
||||
int
|
||||
adjtime1(delta, olddelta, p)
|
||||
struct timeval *delta;
|
||||
const struct timeval *delta;
|
||||
struct timeval *olddelta;
|
||||
struct proc *p;
|
||||
{
|
||||
struct timeval atv;
|
||||
struct timeval *oatv = NULL;
|
||||
long ndelta, ntickdelta, odelta;
|
||||
int error;
|
||||
int s;
|
||||
|
||||
error = copyin(delta, &atv, sizeof(struct timeval));
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
if (olddelta != NULL) {
|
||||
if (uvm_useracc((caddr_t)olddelta,
|
||||
sizeof(struct timeval), B_WRITE) == FALSE)
|
||||
return (EFAULT);
|
||||
oatv = olddelta;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute the total correction and the rate at which to apply it.
|
||||
* Round the adjustment down to a whole multiple of the per-tick
|
||||
|
@ -455,7 +453,7 @@ adjtime1(delta, olddelta, p)
|
|||
* hardclock(), tickdelta will become zero, lest the correction
|
||||
* overshoot and start taking us away from the desired final time.
|
||||
*/
|
||||
ndelta = delta->tv_sec * 1000000 + delta->tv_usec;
|
||||
ndelta = atv.tv_sec * 1000000 + atv.tv_usec;
|
||||
if (ndelta > bigadj || ndelta < -bigadj)
|
||||
ntickdelta = 10 * tickadj;
|
||||
else
|
||||
|
@ -477,9 +475,9 @@ adjtime1(delta, olddelta, p)
|
|||
splx(s);
|
||||
|
||||
if (olddelta) {
|
||||
delta->tv_sec = odelta / 1000000;
|
||||
delta->tv_usec = odelta % 1000000;
|
||||
(void) copyout(delta, olddelta, sizeof(struct timeval));
|
||||
atv.tv_sec = odelta / 1000000;
|
||||
atv.tv_usec = odelta % 1000000;
|
||||
(void) copyout(&atv, olddelta, sizeof(struct timeval));
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: clockctl.h,v 1.1 2001/09/16 06:53:54 manu Exp $ */
|
||||
/* $NetBSD: clockctl.h,v 1.2 2001/12/09 16:10:43 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -36,31 +36,20 @@
|
|||
#include <sys/device.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/timex.h>
|
||||
#include <sys/mount.h> /* For fhandle_t */
|
||||
#include <sys/syscallargs.h>
|
||||
|
||||
#ifndef SYS_CLOCKCTL_H
|
||||
#define SYS_CLOCKCTL_H
|
||||
|
||||
struct clockctl_settimeofday_args {
|
||||
struct timeval tv;
|
||||
struct timezone tzp;
|
||||
};
|
||||
struct clockctl_adjtime_args {
|
||||
struct timeval delta;
|
||||
struct timeval olddelta;
|
||||
};
|
||||
struct clockctl_clock_settime_args {
|
||||
clockid_t clock_id;
|
||||
struct timespec tp;
|
||||
};
|
||||
|
||||
struct clockctl_ntp_adjtime_args {
|
||||
struct timex tp;
|
||||
struct sys_ntp_adjtime_args uas;
|
||||
register_t retval;
|
||||
};
|
||||
|
||||
#define CLOCKCTL_SETTIMEOFDAY _IOW('C', 0x1, struct clockctl_settimeofday_args)
|
||||
#define CLOCKCTL_ADJTIME _IOWR('C', 0x2, struct clockctl_adjtime_args)
|
||||
#define CLOCKCTL_CLOCK_SETTIME \
|
||||
_IOW('C', 0x3, struct clockctl_clock_settime_args)
|
||||
#define CLOCKCTL_SETTIMEOFDAY _IOW('C', 0x1, struct sys_settimeofday_args)
|
||||
#define CLOCKCTL_ADJTIME _IOWR('C', 0x2, struct sys_adjtime_args)
|
||||
#define CLOCKCTL_CLOCK_SETTIME _IOW('C', 0x3, struct sys_clock_settime_args)
|
||||
#define CLOCKCTL_NTP_ADJTIME _IOWR('C', 0x4, struct clockctl_ntp_adjtime_args)
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: time.h,v 1.32 2001/09/16 07:14:15 manu Exp $ */
|
||||
/* $NetBSD: time.h,v 1.33 2001/12/09 16:10:43 manu Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1993
|
||||
|
@ -165,9 +165,10 @@ void microtime __P((struct timeval *tv));
|
|||
int settime __P((struct timeval *));
|
||||
int ratecheck __P((struct timeval *, const struct timeval *));
|
||||
int ppsratecheck __P((struct timeval *, int *, int));
|
||||
int settimeofday1 __P((struct timeval *, struct timezone *, struct proc *));
|
||||
int adjtime1 __P((struct timeval *, struct timeval *, struct proc *));
|
||||
int clock_settime1 __P((clockid_t, struct timespec *));
|
||||
int settimeofday1 __P((const struct timeval *, const struct timezone *,
|
||||
struct proc *));
|
||||
int adjtime1 __P((const struct timeval *, struct timeval *, struct proc *));
|
||||
int clock_settime1 __P((clockid_t, const struct timespec *));
|
||||
#else /* !_KERNEL */
|
||||
|
||||
#ifndef _STANDALONE
|
||||
|
|
Loading…
Reference in New Issue