Module Name:    src
Committed By:   pgoyette
Date:           Wed Mar 21 04:48:32 UTC 2018

Modified Files:
        src/sys/compat/common [pgoyette-compat]: Makefile.sysio compat_50_mod.c
            files.common
        src/sys/compat/sys [pgoyette-compat]: clockctl.h
        src/sys/dev [pgoyette-compat]: clockctl.c
        src/sys/kern [pgoyette-compat]: compat_stub.c
        src/sys/modules/clockctl [pgoyette-compat]: Makefile
        src/sys/modules/compat_50 [pgoyette-compat]: Makefile
        src/sys/sys [pgoyette-compat]: compat_stub.h
Added Files:
        src/sys/compat/common [pgoyette-compat]: clockctl_50.c

Log Message:
Split the compat_50 code out from the dev/clockctl driver and include
it in the compat_50 and compat modules.


To generate a diff of this commit:
cvs rdiff -u -r1.7.18.5 -r1.7.18.6 src/sys/compat/common/Makefile.sysio
cvs rdiff -u -r0 -r1.1.2.1 src/sys/compat/common/clockctl_50.c
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/compat/common/compat_50_mod.c
cvs rdiff -u -r1.1.2.14 -r1.1.2.15 src/sys/compat/common/files.common
cvs rdiff -u -r1.4 -r1.4.16.1 src/sys/compat/sys/clockctl.h
cvs rdiff -u -r1.35 -r1.35.14.1 src/sys/dev/clockctl.c
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/kern/compat_stub.c
cvs rdiff -u -r1.1 -r1.1.20.1 src/sys/modules/clockctl/Makefile
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/modules/compat_50/Makefile
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/sys/compat_stub.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/common/Makefile.sysio
diff -u src/sys/compat/common/Makefile.sysio:1.7.18.5 src/sys/compat/common/Makefile.sysio:1.7.18.6
--- src/sys/compat/common/Makefile.sysio:1.7.18.5	Sun Mar 18 21:41:31 2018
+++ src/sys/compat/common/Makefile.sysio	Wed Mar 21 04:48:31 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.sysio,v 1.7.18.5 2018/03/18 21:41:31 pgoyette Exp $
+#	$NetBSD: Makefile.sysio,v 1.7.18.6 2018/03/21 04:48:31 pgoyette Exp $
 
 # Sources for syscall and ioctl compatibility across the versions.
 
@@ -35,7 +35,7 @@ SRCS+=	vfs_syscalls_40.c uipc_syscalls_4
 
 # Compatibility code for NetBSD 5.0
 SRCS+=	kern_50.c kern_time_50.c kern_select_50.c rndpseudo_50.c rtsock_50.c \
-	vfs_syscalls_50.c  uipc_syscalls_50.c uvm_50.c
+	vfs_syscalls_50.c  uipc_syscalls_50.c uvm_50.c clockctl_50.c
 
 # Compatibility code for NetBSD 6.0
 SRCS+=	kern_sa_60.c tty_60.c kern_time_60.c kern_cpu_60.c ccd_60.c

Index: src/sys/compat/common/compat_50_mod.c
diff -u src/sys/compat/common/compat_50_mod.c:1.1.2.1 src/sys/compat/common/compat_50_mod.c:1.1.2.2
--- src/sys/compat/common/compat_50_mod.c:1.1.2.1	Mon Mar 19 21:54:43 2018
+++ src/sys/compat/common/compat_50_mod.c	Wed Mar 21 04:48:31 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_50_mod.c,v 1.1.2.1 2018/03/19 21:54:43 pgoyette Exp $	*/
+/*	$NetBSD: compat_50_mod.c,v 1.1.2.2 2018/03/21 04:48:31 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_50_mod.c,v 1.1.2.1 2018/03/19 21:54:43 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_50_mod.c,v 1.1.2.2 2018/03/21 04:48:31 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -48,6 +48,8 @@ __KERNEL_RCSID(0, "$NetBSD: compat_50_mo
 #include <sys/syscallvar.h>
 #include <sys/syscallargs.h>
 
+#include <compat/sys/clockctl.h>
+
 #include <compat/common/compat_util.h>
 #include <compat/common/compat_mod.h>
 
@@ -74,6 +76,7 @@ compat_50_init(void)
 
 	uvm_50_init();
 	if_50_init();
+	clockctl_50_init();
 
 	return error;
 
@@ -94,6 +97,7 @@ compat_50_fini(void)
 {
 	int error = 0;
 
+	clockctl_50_fini();
 	if_50_fini();
 	uvm_50_fini();
 
@@ -125,6 +129,7 @@ compat_50_fini(void)
  err1:
 	uvm_50_init();
 	if_50_init();
+	clockctl_50_init();
 
 	return error;
 }

Index: src/sys/compat/common/files.common
diff -u src/sys/compat/common/files.common:1.1.2.14 src/sys/compat/common/files.common:1.1.2.15
--- src/sys/compat/common/files.common:1.1.2.14	Mon Mar 19 21:54:43 2018
+++ src/sys/compat/common/files.common	Wed Mar 21 04:48:31 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: files.common,v 1.1.2.14 2018/03/19 21:54:43 pgoyette Exp $
+#	$NetBSD: files.common,v 1.1.2.15 2018/03/21 04:48:31 pgoyette Exp $
 
 #
 # Generic files, used by all compat options.
@@ -64,6 +64,7 @@ file	compat/common/rndpseudo_50.c		compa
 file	compat/common/rtsock_50.c		compat_50
 file	compat/common/vfs_syscalls_50.c		compat_50
 file	compat/common/uipc_syscalls_50.c	compat_50
+file	compat/common/clockctl_50.c		compat_50 & clockctl
 file	compat/common/uvm_50.c			compat_50
 
 # Compatibility code for NetBSD 6.0
@@ -72,7 +73,7 @@ file	compat/common/kern_sa_60.c		compat_
 file	compat/common/tty_60.c			compat_60
 file	compat/common/kern_time_60.c		compat_60
 file	compat/common/kern_cpu_60.c		compat_60
-file	compat/common/ccd_60.c			compat_60
+file	compat/common/ccd_60.c			compat_60 & ccd
 
 # Compatibility code for NetBSD 7.0
 file	compat/common/compat_70_mod.c		compat_70

Index: src/sys/compat/sys/clockctl.h
diff -u src/sys/compat/sys/clockctl.h:1.4 src/sys/compat/sys/clockctl.h:1.4.16.1
--- src/sys/compat/sys/clockctl.h:1.4	Sun Sep  6 06:00:59 2015
+++ src/sys/compat/sys/clockctl.h	Wed Mar 21 04:48:31 2018
@@ -1,4 +1,4 @@
-/*      $NetBSD: clockctl.h,v 1.4 2015/09/06 06:00:59 dholland Exp $ */
+/*      $NetBSD: clockctl.h,v 1.4.16.1 2018/03/21 04:48:31 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -70,6 +70,9 @@ struct clockctl50_ntp_adjtime {
 #ifdef _KERNEL
 struct lwp;
 int compat50_clockctlioctl(dev_t, u_long, void *, int, struct lwp *);
+
+void clockctl_50_init(void);
+void clockctl_50_fini(void);
 #endif
 
 #endif /* _COMPAT_SYS_CLOCKCTL_H_ */

Index: src/sys/dev/clockctl.c
diff -u src/sys/dev/clockctl.c:1.35 src/sys/dev/clockctl.c:1.35.14.1
--- src/sys/dev/clockctl.c:1.35	Mon Nov 21 03:53:59 2016
+++ src/sys/dev/clockctl.c	Wed Mar 21 04:48:32 2018
@@ -1,4 +1,4 @@
-/*      $NetBSD: clockctl.c,v 1.35 2016/11/21 03:53:59 rin Exp $ */
+/*      $NetBSD: clockctl.c,v 1.35.14.1 2018/03/21 04:48:32 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.35 2016/11/21 03:53:59 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.35.14.1 2018/03/21 04:48:32 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ntp.h"
@@ -52,12 +52,12 @@ __KERNEL_RCSID(0, "$NetBSD: clockctl.c,v
 #include <sys/kauth.h>
 #include <sys/module.h>
 #include <sys/mutex.h>
+#include <sys/compat_stub.h>
 
 #include <sys/clockctl.h>
-#ifdef COMPAT_50
 #include <compat/sys/clockctl.h>
 #include <compat/sys/time_types.h>
-#endif
+
 
 kmutex_t clockctl_mtx;
 int clockctl_refcnt;
@@ -263,83 +263,10 @@ clockctlioctl(
 	}
 #endif /* NTP */
 	default:
-#ifdef COMPAT_50
-		error = compat50_clockctlioctl(dev, cmd, data, flags, l);
-#else
-		error = ENOTTY;
-#endif
-	}
-
-	return (error);
-}
-
-#ifdef COMPAT_50
-int
-compat50_clockctlioctl(dev_t dev, u_long cmd, void *data, int flags,
-    struct lwp *l)
-{
-	int error = 0;
-	const struct cdevsw *cd = cdevsw_lookup(dev);
-
-	if (cd == NULL || cd->d_ioctl == NULL)
-		return ENXIO;
-
-	switch (cmd) {
-	case CLOCKCTL_OSETTIMEOFDAY: {
-		struct timeval50 tv50;
-		struct timeval tv;
-		struct clockctl50_settimeofday *args = data;
-
-		error = copyin(args->tv, &tv50, sizeof(tv50));
-		if (error)
-			return (error);
-		timeval50_to_timeval(&tv50, &tv);
-		error = settimeofday1(&tv, false, args->tzp, l, false);
-		break;
-	}
-	case CLOCKCTL_OADJTIME: {
-		struct timeval atv, oldatv;
-		struct timeval50 atv50;
-		struct clockctl50_adjtime *args = data;
-
-		if (args->delta) {
-			error = copyin(args->delta, &atv50, sizeof(atv50));
-			if (error)
-				return (error);
-			timeval50_to_timeval(&atv50, &atv);
-		}
-		adjtime1(args->delta ? &atv : NULL,
-		    args->olddelta ? &oldatv : NULL, l->l_proc);
-		if (args->olddelta) {
-			timeval_to_timeval50(&oldatv, &atv50);
-			error = copyout(&atv50, args->olddelta, sizeof(atv50));
-		}
-		break;
-	}
-	case CLOCKCTL_OCLOCK_SETTIME: {
-		struct timespec50 tp50;
-		struct timespec tp;
-		struct clockctl50_clock_settime *args = data;
-
-		error = copyin(args->tp, &tp50, sizeof(tp50));
-		if (error)
-			return (error);
-		timespec50_to_timespec(&tp50, &tp);
-		error = clock_settime1(l->l_proc, args->clock_id, &tp, true);
-		break;
-	}
-#ifdef NTP
-	case CLOCKCTL_ONTP_ADJTIME: {
-		/* The ioctl number changed but the data did not change. */
-		error = (cd->d_ioctl)(dev, CLOCKCTL_NTP_ADJTIME,
-		    data, flags, l);
-		break;
-	}
-#endif
-	default:
-		error = ENOTTY;
+		error = (*compat_clockctl_ioctl_50)(dev, cmd, data, flags, l);
+		if (error == ENOSYS)
+			error = ENOTTY;
 	}
 
 	return (error);
 }
-#endif

Index: src/sys/kern/compat_stub.c
diff -u src/sys/kern/compat_stub.c:1.1.2.1 src/sys/kern/compat_stub.c:1.1.2.2
--- src/sys/kern/compat_stub.c:1.1.2.1	Tue Mar 20 08:11:25 2018
+++ src/sys/kern/compat_stub.c	Wed Mar 21 04:48:32 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.c,v 1.1.2.1 2018/03/20 08:11:25 pgoyette Exp $	*/
+/* $NetBSD: compat_stub.c,v 1.1.2.2 2018/03/21 04:48:32 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -50,6 +50,16 @@ void (*vec_ntp_gettime)(struct ntptimeva
 int (*vec_ntp_timestatus)(void) = NULL;
 #endif
 
+/*
+ * ccd device compatability ioctl
+ */
 int (*compat_ccd_ioctl_60)(dev_t dev, u_long cmd, void *data, int flag,
     struct lwp *l, int (*f)(dev_t, u_long, void *, int, struct lwp *)) =
 	(void *)enosys;
+
+/*
+ * clockctl device compatability ioctl
+ */
+int (*compat_clockctl_ioctl_50)(dev_t dev, u_long cmd, void *data, int flag,
+    struct lwp *l) = (void *)enosys;
+

Index: src/sys/modules/clockctl/Makefile
diff -u src/sys/modules/clockctl/Makefile:1.1 src/sys/modules/clockctl/Makefile:1.1.20.1
--- src/sys/modules/clockctl/Makefile:1.1	Mon Dec  7 03:25:57 2015
+++ src/sys/modules/clockctl/Makefile	Wed Mar 21 04:48:32 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.1 2015/12/07 03:25:57 pgoyette Exp $
+# $NetBSD: Makefile,v 1.1.20.1 2018/03/21 04:48:32 pgoyette Exp $
 
 .include "../Makefile.inc"
 
@@ -8,6 +8,4 @@ KMOD=		clockctl
 IOCONF=		clockctl.ioconf
 SRCS=		clockctl.c
 
-CPPFLAGS+=	-DNTP -DCOMPAT_50
-
 .include <bsd.kmodule.mk>

Index: src/sys/modules/compat_50/Makefile
diff -u src/sys/modules/compat_50/Makefile:1.1.2.1 src/sys/modules/compat_50/Makefile:1.1.2.2
--- src/sys/modules/compat_50/Makefile:1.1.2.1	Mon Mar 19 21:54:43 2018
+++ src/sys/modules/compat_50/Makefile	Wed Mar 21 04:48:32 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.1.2.1 2018/03/19 21:54:43 pgoyette Exp $
+#	$NetBSD: Makefile,v 1.1.2.2 2018/03/21 04:48:32 pgoyette Exp $
 
 .include "../Makefile.inc"
 
@@ -11,6 +11,7 @@ CPPFLAGS+=	-DCOMPAT_50 -DCOMPAT_60 -DCOM
 SRCS+=	compat_50_mod.c
 SRCS+=	kern_50.c kern_time_50.c kern_select_50.c
 SRCS+=	vfs_syscalls_50.c uipc_syscalls_50.c uvm_50.c
-#SRCS+=	rndpseudo_50.c rtsock_50.c
+SRCS+=	rndpseudo_50.c clockctl_50.c
+#SRCS+=	rtsock_50.c
 
 .include <bsd.kmodule.mk>

Index: src/sys/sys/compat_stub.h
diff -u src/sys/sys/compat_stub.h:1.1.2.1 src/sys/sys/compat_stub.h:1.1.2.2
--- src/sys/sys/compat_stub.h:1.1.2.1	Tue Mar 20 08:11:26 2018
+++ src/sys/sys/compat_stub.h	Wed Mar 21 04:48:32 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.h,v 1.1.2.1 2018/03/20 08:11:26 pgoyette Exp $	*/
+/* $NetBSD: compat_stub.h,v 1.1.2.2 2018/03/21 04:48:32 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -49,4 +49,10 @@ extern int (*vec_ntp_timestatus)(void);
 extern int (*compat_ccd_ioctl_60)(dev_t, u_long, void *, int, struct lwp *,
     int (*f)(dev_t, u_long, void *, int, struct lwp *));
 
+/*
+ * Routine vector for dev/clockctl ioctl()
+ */
+
+extern int (*compat_clockctl_ioctl_50)(dev_t, u_long, void *, int,
+    struct lwp *);
 #endif	/* _SYS_COMPAT_STUB_H */

Added files:

Index: src/sys/compat/common/clockctl_50.c
diff -u /dev/null src/sys/compat/common/clockctl_50.c:1.1.2.1
--- /dev/null	Wed Mar 21 04:48:32 2018
+++ src/sys/compat/common/clockctl_50.c	Wed Mar 21 04:48:31 2018
@@ -0,0 +1,137 @@
+/*      $NetBSD: clockctl_50.c,v 1.1.2.1 2018/03/21 04:48:31 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Emmanuel Dreyfus.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: clockctl_50.c,v 1.1.2.1 2018/03/21 04:48:31 pgoyette Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/errno.h>
+#include <sys/ioctl.h>
+#include <sys/device.h>
+#include <sys/time.h>
+#include <sys/conf.h>
+#include <sys/timex.h>
+#include <sys/kauth.h>
+#include <sys/module.h>
+#include <sys/mutex.h>
+#include <sys/compat_stub.h>
+
+#include <sys/clockctl.h>
+#include <compat/sys/clockctl.h>
+#include <compat/sys/time_types.h>
+
+int
+compat50_clockctlioctl(dev_t dev, u_long cmd, void *data, int flags,
+    struct lwp *l)
+{
+	int error = 0;
+	const struct cdevsw *cd = cdevsw_lookup(dev);
+
+	if (cd == NULL || cd->d_ioctl == NULL)
+		return ENXIO;
+
+	switch (cmd) {
+	case CLOCKCTL_OSETTIMEOFDAY: {
+		struct timeval50 tv50;
+		struct timeval tv;
+		struct clockctl50_settimeofday *args = data;
+
+		error = copyin(args->tv, &tv50, sizeof(tv50));
+		if (error)
+			return (error);
+		timeval50_to_timeval(&tv50, &tv);
+		error = settimeofday1(&tv, false, args->tzp, l, false);
+		break;
+	}
+	case CLOCKCTL_OADJTIME: {
+		struct timeval atv, oldatv;
+		struct timeval50 atv50;
+		struct clockctl50_adjtime *args = data;
+
+		if (args->delta) {
+			error = copyin(args->delta, &atv50, sizeof(atv50));
+			if (error)
+				return (error);
+			timeval50_to_timeval(&atv50, &atv);
+		}
+		adjtime1(args->delta ? &atv : NULL,
+		    args->olddelta ? &oldatv : NULL, l->l_proc);
+		if (args->olddelta) {
+			timeval_to_timeval50(&oldatv, &atv50);
+			error = copyout(&atv50, args->olddelta, sizeof(atv50));
+		}
+		break;
+	}
+	case CLOCKCTL_OCLOCK_SETTIME: {
+		struct timespec50 tp50;
+		struct timespec tp;
+		struct clockctl50_clock_settime *args = data;
+
+		error = copyin(args->tp, &tp50, sizeof(tp50));
+		if (error)
+			return (error);
+		timespec50_to_timespec(&tp50, &tp);
+		error = clock_settime1(l->l_proc, args->clock_id, &tp, true);
+		break;
+	}
+	case CLOCKCTL_ONTP_ADJTIME: {
+		if (vec_ntp_timestatus == NULL) {
+			error = ENOTTY;
+			break;
+		}
+		/* The ioctl number changed but the data did not change. */
+		error = (cd->d_ioctl)(dev, CLOCKCTL_NTP_ADJTIME,
+		    data, flags, l);
+		break;
+	}
+	default:
+		error = ENOTTY;
+	}
+
+	return (error);
+}
+
+void
+clockctl_50_init(void)
+{
+
+	compat_clockctl_ioctl_50 = compat50_clockctlioctl;
+}
+
+void
+clockctl_50_fini(void)
+{
+
+	compat_clockctl_ioctl_50 = (void *)enosys;
+}

Reply via email to