Source-Changes-HG archive

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

[src/trunk]: src/sys Move boottime50 and its associated sysctl into the compa...



details:   https://anonhg.NetBSD.org/src/rev/4bce01b9ea51
branches:  trunk
changeset: 785079:4bce01b9ea51
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Thu Feb 21 01:39:54 2013 +0000

description:
Move boottime50 and its associated sysctl into the compat module.  As
noted on tech-kern.  Should fix PR/47579.

OK christos@

Will request pull-up to 6.0 in a few days.

diffstat:

 sys/compat/common/compat_mod.c      |  36 +++++++++++++++++++++++++++-----
 sys/compat/common/compat_mod.h      |  41 +++++++++++++++++++++++++++++++++++++
 sys/compat/common/compat_util.h     |   5 +---
 sys/compat/common/kern_time_50.c    |  24 +++++++++++++++++++-
 sys/compat/common/vfs_syscalls_43.c |  20 ++++++-----------
 sys/kern/init_main.c                |  17 ++------------
 sys/kern/init_sysctl.c              |  19 +---------------
 7 files changed, 106 insertions(+), 56 deletions(-)

diffs (truncated from 375 to 300 lines):

diff -r b71edd6f5093 -r 4bce01b9ea51 sys/compat/common/compat_mod.c
--- a/sys/compat/common/compat_mod.c    Wed Feb 20 22:45:12 2013 +0000
+++ b/sys/compat/common/compat_mod.c    Thu Feb 21 01:39:54 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_mod.c,v 1.15 2013/01/22 01:47:20 christos Exp $ */
+/*     $NetBSD: compat_mod.c,v 1.16 2013/02/21 01:39:54 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.15 2013/01/22 01:47:20 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.16 2013/02/21 01:39:54 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -52,12 +52,18 @@
 #include <sys/syscall.h>
 #include <sys/syscallargs.h>
 #include <sys/syscallvar.h>
+#include <sys/sysctl.h>
 
 #include <uvm/uvm_extern.h>
 #include <uvm/uvm_object.h>
 
 #include <compat/common/compat_util.h>
+#include <compat/common/compat_mod.h>
 
+#if defined(COMPAT_09) || defined(COMPAT_43) || defined(COMPAT_50)
+static struct sysctllog *compat_clog = NULL;
+#endif
+ 
 MODULE(MODULE_CLASS_MISC, compat, NULL);
 
 int    ttcompat(struct tty *, u_long, void *, int, struct lwp *);
@@ -240,6 +246,9 @@
        { 0, 0, NULL },
 };
 
+#if defined(COMPAT_09) || defined(COMPAT_43) || defined(COMPAT_50)
+#endif
+
 static int
 compat_modcmd(modcmd_t cmd, void *arg)
 {
@@ -270,9 +279,7 @@
                sendsig_sigcontext_vec = sendsig_sigcontext;
 #endif
 #endif
-#if defined(COMPAT_09) || defined(COMPAT_43)
                compat_sysctl_init();
-#endif
                return 0;
 
        case MODULE_CMD_FINI:
@@ -329,12 +336,29 @@
                rw_exit(&exec_lock);
 #endif
 #endif /* COMPAT_16 */
-#if defined(COMPAT_09) || defined(COMPAT_43)
                compat_sysctl_fini();
-#endif
                return 0;
 
        default:
                return ENOTTY;
        }
 }
+
+void
+compat_sysctl_init(void)
+{
+
+#if defined(COMPAT_09) || defined(COMPAT_43)
+       compat_sysctl_vfs(&compat_clog);
+#endif
+#if defined(COMPAT_50)
+       compat_sysctl_time(&compat_clog);
+#endif
+}
+
+void
+compat_sysctl_fini(void)
+{
+ 
+        sysctl_teardown(&compat_clog);
+}
diff -r b71edd6f5093 -r 4bce01b9ea51 sys/compat/common/compat_mod.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/common/compat_mod.h    Thu Feb 21 01:39:54 2013 +0000
@@ -0,0 +1,41 @@
+/*     $NetBSD: compat_mod.h,v 1.1 2013/02/21 01:39:54 pgoyette Exp $  */
+
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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.
+ */
+
+#ifndef        _COMPAT_MOD_H
+#define        _COMPAT_MOD_H
+
+void compat_sysctl_init(void);
+void compat_sysctl_fini(void);
+
+void compat_sysctl_time(struct sysctllog **);
+void compat_sysctl_vfs(struct sysctllog **);
+
+#endif /* !_COMPAT_MOD_H_ */
diff -r b71edd6f5093 -r 4bce01b9ea51 sys/compat/common/compat_util.h
--- a/sys/compat/common/compat_util.h   Wed Feb 20 22:45:12 2013 +0000
+++ b/sys/compat/common/compat_util.h   Thu Feb 21 01:39:54 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_util.h,v 1.22 2009/12/14 04:09:38 mrg Exp $     */
+/*     $NetBSD: compat_util.h,v 1.23 2013/02/21 01:39:54 pgoyette Exp $        */
 
 /*-
  * Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -82,7 +82,4 @@
 
 int compat_elf_check_interp(struct exec_package *, char *, const char *);
 
-void compat_sysctl_init(void);
-void compat_sysctl_fini(void);
-
 #endif /* !_COMPAT_UTIL_H_ */
diff -r b71edd6f5093 -r 4bce01b9ea51 sys/compat/common/kern_time_50.c
--- a/sys/compat/common/kern_time_50.c  Wed Feb 20 22:45:12 2013 +0000
+++ b/sys/compat/common/kern_time_50.c  Thu Feb 21 01:39:54 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_time_50.c,v 1.24 2012/11/03 23:22:21 njoly Exp $  */
+/*     $NetBSD: kern_time_50.c,v 1.25 2013/02/21 01:39:54 pgoyette Exp $       */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_time_50.c,v 1.24 2012/11/03 23:22:21 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_time_50.c,v 1.25 2013/02/21 01:39:54 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_aio.h"
@@ -58,14 +58,18 @@
 #include <sys/aio.h>
 #include <sys/poll.h>
 #include <sys/syscallargs.h>
+#include <sys/sysctl.h>
 #include <sys/resource.h>
 
 #include <compat/common/compat_util.h>
+#include <compat/common/compat_mod.h>
 #include <compat/sys/time.h>
 #include <compat/sys/timex.h>
 #include <compat/sys/resource.h>
 #include <compat/sys/clockctl.h>
 
+struct timeval50 boottime50; 
+
 int
 compat_50_sys_clock_gettime(struct lwp *l,
     const struct compat_50_sys_clock_gettime_args *uap, register_t *retval)
@@ -706,3 +710,19 @@
 
        return error;
 }
+
+void
+compat_sysctl_time(struct sysctllog **clog)
+{
+       struct timeval tv;
+
+       TIMESPEC_TO_TIMEVAL(&tv, &boottime);
+       timeval_to_timeval50(&tv, &boottime50);
+
+       sysctl_createv(clog, 0, NULL, NULL,
+               CTLFLAG_PERMANENT, 
+               CTLTYPE_STRUCT, "oboottime", 
+               SYSCTL_DESCR("System boot time"),
+               NULL, 0, &boottime50, sizeof(boottime50),
+               CTL_KERN, KERN_OBOOTTIME, CTL_EOL);
+}
diff -r b71edd6f5093 -r 4bce01b9ea51 sys/compat/common/vfs_syscalls_43.c
--- a/sys/compat/common/vfs_syscalls_43.c       Wed Feb 20 22:45:12 2013 +0000
+++ b/sys/compat/common/vfs_syscalls_43.c       Thu Feb 21 01:39:54 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_syscalls_43.c,v 1.54 2010/11/19 06:44:36 dholland Exp $    */
+/*     $NetBSD: vfs_syscalls_43.c,v 1.55 2013/02/21 01:39:54 pgoyette Exp $    */
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_43.c,v 1.54 2010/11/19 06:44:36 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_43.c,v 1.55 2013/02/21 01:39:54 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -58,6 +58,7 @@
 #include <sys/malloc.h>
 #include <sys/ioctl.h>
 #include <sys/fcntl.h>
+#include <sys/sysctl.h>
 #include <sys/syslog.h>
 #include <sys/unistd.h>
 #include <sys/resourcevar.h>
@@ -71,6 +72,7 @@
 #include <compat/sys/mount.h>
 
 #include <compat/common/compat_util.h>
+#include <compat/common/compat_mod.h>
 
 static void cvtstat(struct stat *, struct stat43 *);
 
@@ -458,7 +460,6 @@
  * sysctl helper routine for vfs.generic.conf lookups.
  */
 #if defined(COMPAT_09) || defined(COMPAT_43) || defined(COMPAT_44)
-static struct sysctllog *compat_clog;
 
 static int
 sysctl_vfs_generic_conf(SYSCTLFN_ARGS)
@@ -498,17 +499,17 @@
  * Top level filesystem related information gathering.
  */
 void
-compat_sysctl_init(void)
+compat_sysctl_vfs(struct sysctllog **clog)
 {
        extern int nmountcompatnames;
 
-       sysctl_createv(&compat_clog, 0, NULL, NULL,
+       sysctl_createv(clog, 0, NULL, NULL,
                       CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
                       CTLTYPE_INT, "maxtypenum",
                       SYSCTL_DESCR("Highest valid filesystem type number"),
                       NULL, nmountcompatnames, NULL, 0,
                       CTL_VFS, VFS_GENERIC, VFS_MAXTYPENUM, CTL_EOL);
-       sysctl_createv(&compat_clog, 0, NULL, NULL,
+       sysctl_createv(clog, 0, NULL, NULL,
                       CTLFLAG_PERMANENT,
                       CTLTYPE_STRUCT, "conf",
                       SYSCTL_DESCR("Filesystem configuration information"),
@@ -516,11 +517,4 @@
                       sizeof(struct vfsconf),
                       CTL_VFS, VFS_GENERIC, VFS_CONF, CTL_EOL);
 }
-
-void
-compat_sysctl_fini(void)
-{
-
-       sysctl_teardown(&compat_clog);
-}
 #endif
diff -r b71edd6f5093 -r 4bce01b9ea51 sys/kern/init_main.c
--- a/sys/kern/init_main.c      Wed Feb 20 22:45:12 2013 +0000
+++ b/sys/kern/init_main.c      Thu Feb 21 01:39:54 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init_main.c,v 1.446 2013/02/09 00:31:21 christos Exp $ */
+/*     $NetBSD: init_main.c,v 1.447 2013/02/21 01:39:55 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.446 2013/02/09 00:31:21 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.447 2013/02/21 01:39:55 pgoyette Exp $");
 
 #include "opt_ddb.h"



Home | Main Index | Thread Index | Old Index