Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/netbsd32 Fix netbsd32 emulation for clockctl_ntp_...
details: https://anonhg.NetBSD.org/src/rev/b431256a7db2
branches: trunk
changeset: 819010:b431256a7db2
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Sat Nov 12 16:06:04 2016 +0000
description:
Fix netbsd32 emulation for clockctl_ntp_adjtime.
The ioctl args reference a timex structure that needs to be
transformed to 64bit layout and back.
The 32bit ioctl definition was wrong for mips, as register_t is 64bit
for N32 abi.
diffstat:
sys/compat/netbsd32/netbsd32_ioctl.c | 50 +++++++++++++++++++++++++++++++++--
sys/compat/netbsd32/netbsd32_ioctl.h | 4 +-
2 files changed, 48 insertions(+), 6 deletions(-)
diffs (103 lines):
diff -r 7d8a46b336bf -r b431256a7db2 sys/compat/netbsd32/netbsd32_ioctl.c
--- a/sys/compat/netbsd32/netbsd32_ioctl.c Sat Nov 12 15:12:59 2016 +0000
+++ b/sys/compat/netbsd32/netbsd32_ioctl.c Sat Nov 12 16:06:04 2016 +0000
@@ -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 <sys/cdefs.h>
-__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 <sys/param.h>
#include <sys/systm.h>
@@ -83,6 +83,7 @@
#include <compat/netbsd32/netbsd32.h>
#include <compat/netbsd32/netbsd32_ioctl.h>
#include <compat/netbsd32/netbsd32_syscallargs.h>
+#include <compat/netbsd32/netbsd32_conv.h>
#include <dev/vndvar.h>
@@ -921,6 +922,29 @@
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 @@
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 -r 7d8a46b336bf -r b431256a7db2 sys/compat/netbsd32/netbsd32_ioctl.h
--- a/sys/compat/netbsd32/netbsd32_ioctl.h Sat Nov 12 15:12:59 2016 +0000
+++ b/sys/compat/netbsd32/netbsd32_ioctl.h Sat Nov 12 16:06:04 2016 +0000
@@ -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_ntp_adjtime {
netbsd32_timexp_t tp;
- /* register_t */ int32_t retval;
+ register32_t retval;
};
#define CLOCKCTL_NTP_ADJTIME32 _IOWR('C', 0x8, \
Home |
Main Index |
Thread Index |
Old Index