diff options
author | Konstantin Belousov <kib@FreeBSD.org> | 2020-12-11 00:37:51 +0000 |
---|---|---|
committer | Konstantin Belousov <kib@FreeBSD.org> | 2020-12-11 00:37:51 +0000 |
commit | 8fc5fd96efcd008beb9bc9a3d3f20717a35f31be (patch) | |
tree | aac970c0109dcf67366baba4540017f4f8118f37 | |
parent | ebd94de61824169ad25d5492381685159cbd1516 (diff) | |
download | src-test2-8fc5fd96efcd008beb9bc9a3d3f20717a35f31be.tar.gz src-test2-8fc5fd96efcd008beb9bc9a3d3f20717a35f31be.zip |
MFC r368343:
Fix compat32 for ntp_adjtime(2).
Notes
Notes:
svn path=/stable/12/; revision=368540
-rw-r--r-- | sys/compat/freebsd32/freebsd32.h | 20 | ||||
-rw-r--r-- | sys/compat/freebsd32/freebsd32_misc.c | 66 | ||||
-rw-r--r-- | sys/compat/freebsd32/syscalls.master | 3 |
3 files changed, 88 insertions, 1 deletions
diff --git a/sys/compat/freebsd32/freebsd32.h b/sys/compat/freebsd32/freebsd32.h index a3774c99a0cb..46dd5e278a48 100644 --- a/sys/compat/freebsd32/freebsd32.h +++ b/sys/compat/freebsd32/freebsd32.h @@ -388,4 +388,24 @@ struct procctl_reaper_pids32 { uint32_t rp_pids; }; +struct timex32 { + unsigned int modes; + int32_t offset; + int32_t freq; + int32_t maxerror; + int32_t esterror; + int status; + int32_t constant; + int32_t precision; + int32_t tolerance; + int32_t ppsfreq; + int32_t jitter; + int shift; + int32_t stabil; + int32_t jitcnt; + int32_t calcnt; + int32_t errcnt; + int32_t stbcnt; +}; + #endif /* !_COMPAT_FREEBSD32_FREEBSD32_H_ */ diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c index eda6d54b4220..76054c8046a0 100644 --- a/sys/compat/freebsd32/freebsd32_misc.c +++ b/sys/compat/freebsd32/freebsd32_misc.c @@ -81,6 +81,7 @@ __FBSDID("$FreeBSD$"); #include <sys/sysproto.h> #include <sys/systm.h> #include <sys/thr.h> +#include <sys/timex.h> #include <sys/unistd.h> #include <sys/ucontext.h> #include <sys/vnode.h> @@ -3543,3 +3544,68 @@ freebsd32_sched_rr_get_interval(struct thread *td, } return (error); } + +static void +timex_to_32(struct timex32 *dst, struct timex *src) +{ + CP(*src, *dst, modes); + CP(*src, *dst, offset); + CP(*src, *dst, freq); + CP(*src, *dst, maxerror); + CP(*src, *dst, esterror); + CP(*src, *dst, status); + CP(*src, *dst, constant); + CP(*src, *dst, precision); + CP(*src, *dst, tolerance); + CP(*src, *dst, ppsfreq); + CP(*src, *dst, jitter); + CP(*src, *dst, shift); + CP(*src, *dst, stabil); + CP(*src, *dst, jitcnt); + CP(*src, *dst, calcnt); + CP(*src, *dst, errcnt); + CP(*src, *dst, stbcnt); +} + +static void +timex_from_32(struct timex *dst, struct timex32 *src) +{ + CP(*src, *dst, modes); + CP(*src, *dst, offset); + CP(*src, *dst, freq); + CP(*src, *dst, maxerror); + CP(*src, *dst, esterror); + CP(*src, *dst, status); + CP(*src, *dst, constant); + CP(*src, *dst, precision); + CP(*src, *dst, tolerance); + CP(*src, *dst, ppsfreq); + CP(*src, *dst, jitter); + CP(*src, *dst, shift); + CP(*src, *dst, stabil); + CP(*src, *dst, jitcnt); + CP(*src, *dst, calcnt); + CP(*src, *dst, errcnt); + CP(*src, *dst, stbcnt); +} + +int +freebsd32_ntp_adjtime(struct thread *td, struct freebsd32_ntp_adjtime_args *uap) +{ + struct timex tx; + struct timex32 tx32; + int error, retval; + + error = copyin(uap->tp, &tx32, sizeof(tx32)); + if (error == 0) { + timex_from_32(&tx, &tx32); + error = kern_ntp_adjtime(td, &tx, &retval); + if (error == 0) { + timex_to_32(&tx32, &tx); + error = copyout(&tx32, uap->tp, sizeof(tx32)); + if (error == 0) + td->td_retval[0] = retval; + } + } + return (error); +} diff --git a/sys/compat/freebsd32/syscalls.master b/sys/compat/freebsd32/syscalls.master index a530836dc80b..38bb9732bab0 100644 --- a/sys/compat/freebsd32/syscalls.master +++ b/sys/compat/freebsd32/syscalls.master @@ -333,7 +333,8 @@ const void *buf, size_t nbyte, int pad, \ uint32_t offset1, uint32_t offset2); } 175 AUE_NULL UNIMPL nosys -176 AUE_NTP_ADJTIME NOPROTO { int ntp_adjtime(struct timex *tp); } +176 AUE_NTP_ADJTIME STD { int freebsd32_ntp_adjtime( \ + struct timex32 *tp); } 177 AUE_NULL UNIMPL sfork (BSD/OS 2.x) 178 AUE_NULL UNIMPL getdescriptor (BSD/OS 2.x) 179 AUE_NULL UNIMPL setdescriptor (BSD/OS 2.x) |