Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/pgoyette-compat]: src/sys Split the compat_50 code out from the dev/cloc...



details:   https://anonhg.NetBSD.org/src/rev/5343d4667f59
branches:  pgoyette-compat
changeset: 321075:5343d4667f59
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Wed Mar 21 04:48:31 2018 +0000

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

diffstat:

 sys/compat/common/Makefile.sysio  |    4 +-
 sys/compat/common/clockctl_50.c   |  137 ++++++++++++++++++++++++++++++++++++++
 sys/compat/common/compat_50_mod.c |    9 +-
 sys/compat/common/files.common    |    5 +-
 sys/compat/sys/clockctl.h         |    5 +-
 sys/dev/clockctl.c                |   87 +----------------------
 sys/kern/compat_stub.c            |   12 +++-
 sys/modules/clockctl/Makefile     |    4 +-
 sys/modules/compat_50/Makefile    |    5 +-
 sys/sys/compat_stub.h             |    8 +-
 10 files changed, 182 insertions(+), 94 deletions(-)

diffs (truncated from 455 to 300 lines):

diff -r 734dbf9db6f4 -r 5343d4667f59 sys/compat/common/Makefile.sysio
--- a/sys/compat/common/Makefile.sysio  Wed Mar 21 02:01:34 2018 +0000
+++ b/sys/compat/common/Makefile.sysio  Wed Mar 21 04:48:31 2018 +0000
@@ -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 @@
 
 # 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
diff -r 734dbf9db6f4 -r 5343d4667f59 sys/compat/common/clockctl_50.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/common/clockctl_50.c   Wed Mar 21 04:48:31 2018 +0000
@@ -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;
+}
diff -r 734dbf9db6f4 -r 5343d4667f59 sys/compat/common/compat_50_mod.c
--- a/sys/compat/common/compat_50_mod.c Wed Mar 21 02:01:34 2018 +0000
+++ b/sys/compat/common/compat_50_mod.c Wed Mar 21 04:48:31 2018 +0000
@@ -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 @@
 #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 @@
 
        uvm_50_init();
        if_50_init();
+       clockctl_50_init();
 
        return error;
 
@@ -94,6 +97,7 @@
 {
        int error = 0;
 
+       clockctl_50_fini();
        if_50_fini();
        uvm_50_fini();
 
@@ -125,6 +129,7 @@
  err1:
        uvm_50_init();
        if_50_init();
+       clockctl_50_init();
 
        return error;
 }
diff -r 734dbf9db6f4 -r 5343d4667f59 sys/compat/common/files.common
--- a/sys/compat/common/files.common    Wed Mar 21 02:01:34 2018 +0000
+++ b/sys/compat/common/files.common    Wed Mar 21 04:48:31 2018 +0000
@@ -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/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/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
diff -r 734dbf9db6f4 -r 5343d4667f59 sys/compat/sys/clockctl.h
--- a/sys/compat/sys/clockctl.h Wed Mar 21 02:01:34 2018 +0000
+++ b/sys/compat/sys/clockctl.h Wed Mar 21 04:48:31 2018 +0000
@@ -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 @@
 #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_ */
diff -r 734dbf9db6f4 -r 5343d4667f59 sys/dev/clockctl.c
--- a/sys/dev/clockctl.c        Wed Mar 21 02:01:34 2018 +0000
+++ b/sys/dev/clockctl.c        Wed Mar 21 04:48:31 2018 +0000
@@ -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 @@
 #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 @@
        }
 #endif /* NTP */
        default:
-#ifdef COMPAT_50
-               error = compat50_clockctlioctl(dev, cmd, data, flags, l);
-#else
-               error = ENOTTY;
-#endif
+               error = (*compat_clockctl_ioctl_50)(dev, cmd, data, flags, l);
+               if (error == ENOSYS)
+                       error = ENOTTY;



Home | Main Index | Thread Index | Old Index