diff --git a/sys/compat/netbsd32/netbsd32_ioctl.c b/sys/compat/netbsd32/netbsd32_ioctl.c index fb28c86d4f3c..503fd433dd50 100644 --- a/sys/compat/netbsd32/netbsd32_ioctl.c +++ b/sys/compat/netbsd32/netbsd32_ioctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_ioctl.c,v 1.84 2016/07/13 11:11:53 jmcneill Exp $ */ +/* $NetBSD: netbsd32_ioctl.c,v 1.85 2016/11/12 16:06:04 mlelstv Exp $ */ /* * Copyright (c) 1998, 2001 Matthew R. Green @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.84 2016/07/13 11:11:53 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.85 2016/11/12 16:06:04 mlelstv Exp $"); #include #include @@ -83,6 +83,7 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.84 2016/07/13 11:11:53 jmcneill #include #include #include +#include #include @@ -921,6 +922,29 @@ netbsd32_from_devrescanargs( NETBSD32PTR32(s32p->locators, p->locators); } +static int +netbsd32_do_clockctl_ntp_adjtime(struct clockctl_ntp_adjtime *args) +{ + + struct netbsd32_timex ntv32; + struct timex ntv; + int error; + + error = copyin(args->tp, &ntv32, sizeof(ntv32)); + if (error) + return (error); + + netbsd32_to_timex(&ntv32, &ntv); + ntp_adjtime1(&ntv); + netbsd32_from_timex(&ntv, &ntv32); + + error = copyout(&ntv32, args->tp, sizeof(ntv)); + if (error == 0) + args->retval = ntp_timestatus(); + + return error; +} + /* * main ioctl syscall. * @@ -1291,8 +1315,26 @@ netbsd32_ioctl(struct lwp *l, const struct netbsd32_ioctl_args *uap, register_t IOCTL_STRUCT_CONV_TO(CLOCKCTL_CLOCK_SETTIME, clockctl_clock_settime); case CLOCKCTL_NTP_ADJTIME32: - IOCTL_STRUCT_CONV_TO(CLOCKCTL_NTP_ADJTIME, - clockctl_ntp_adjtime); + { + size = IOCPARM_LEN(CLOCKCTL_NTP_ADJTIME); + if (size > sizeof(stkbuf)) + data = memp = kmem_alloc(size, KM_SLEEP); + else + data = (void *)stkbuf; + + netbsd32_to_clockctl_ntp_adjtime( + (const struct netbsd32_clockctl_ntp_adjtime *)data32, + (struct clockctl_ntp_adjtime *)data, + CLOCKCTL_NTP_ADJTIME); + error = netbsd32_do_clockctl_ntp_adjtime( + (struct clockctl_ntp_adjtime *)data); + netbsd32_from_clockctl_ntp_adjtime( + (const struct clockctl_ntp_adjtime *)data, + (struct netbsd32_clockctl_ntp_adjtime *)data32, + CLOCKCTL_NTP_ADJTIME); + + break; + } case KIOCGSYMBOL32: IOCTL_STRUCT_CONV_TO(KIOCGSYMBOL, ksyms_gsymbol); diff --git a/sys/compat/netbsd32/netbsd32_ioctl.h b/sys/compat/netbsd32/netbsd32_ioctl.h index 3a0bcb3cdb98..aeb787cd7572 100644 --- a/sys/compat/netbsd32/netbsd32_ioctl.h +++ b/sys/compat/netbsd32/netbsd32_ioctl.h @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_ioctl.h,v 1.54 2016/07/13 11:11:53 jmcneill Exp $ */ +/* $NetBSD: netbsd32_ioctl.h,v 1.55 2016/11/12 16:06:04 mlelstv Exp $ */ /* * Copyright (c) 1998, 2001 Matthew R. Green @@ -552,7 +552,7 @@ struct netbsd32_clockctl_clock_settime { struct netbsd32_clockctl_ntp_adjtime { netbsd32_timexp_t tp; - /* register_t */ int32_t retval; + register32_t retval; }; #define CLOCKCTL_NTP_ADJTIME32 _IOWR('C', 0x8, \