Source-Changes-HG archive

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

[src/trunk]: src/sys add KERN_USRSTACK (this is not dynamically defined for F...



details:   https://anonhg.NetBSD.org/src/rev/6ba61cbf12aa
branches:  trunk
changeset: 782037:6ba61cbf12aa
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Oct 13 15:35:55 2012 +0000

description:
add KERN_USRSTACK (this is not dynamically defined for FreeBSD compatibility)

diffstat:

 sys/kern/kern_exec.c |  30 ++++++++++++++++++++++++++++--
 sys/sys/sysctl.h     |   6 ++++--
 2 files changed, 32 insertions(+), 4 deletions(-)

diffs (92 lines):

diff -r 18c9e93e4c17 -r 6ba61cbf12aa sys/kern/kern_exec.c
--- a/sys/kern/kern_exec.c      Sat Oct 13 15:28:33 2012 +0000
+++ b/sys/kern/kern_exec.c      Sat Oct 13 15:35:55 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_exec.c,v 1.355 2012/08/29 18:56:39 dholland Exp $ */
+/*     $NetBSD: kern_exec.c,v 1.356 2012/10/13 15:35:55 christos Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.355 2012/08/29 18:56:39 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.356 2012/10/13 15:35:55 christos Exp $");
 
 #include "opt_exec.h"
 #include "opt_ktrace.h"
@@ -104,6 +104,7 @@
 #include <sys/spawn.h>
 #include <sys/prot.h>
 #include <sys/cprng.h>
+#include <sys/sysctl.h>
 
 #include <uvm/uvm_extern.h>
 
@@ -1617,6 +1618,30 @@
        return 0;
 }
 
+static int
+sysctl_kern_usrstack(SYSCTLFN_ARGS)
+{  
+       u_long ptr;
+       struct sysctlnode node = *rnode;
+       node.sysctl_data = &ptr;
+       ptr = l->l_proc->p_stackbase;
+       return sysctl_lookup(SYSCTLFN_CALL(&node));
+}
+
+static void
+sysctl_kern_usrstack_setup(void)
+{
+       struct sysctllog *kern_usrstack_sysctllog;
+
+       kern_usrstack_sysctllog = NULL;
+       sysctl_createv(&kern_usrstack_sysctllog, 0, NULL, NULL,
+           CTLFLAG_PERMANENT|CTLFLAG_READONLY,
+           CTLTYPE_LONG, "usrstack", 
+           SYSCTL_DESCR("User process stack base"),
+           sysctl_kern_usrstack, 0, NULL, 0,
+           CTL_KERN, KERN_USRSTACK, CTL_EOL);
+}
+
 /*
  * Initialize exec structures. If init_boot is true, also does necessary
  * one-time initialization (it's called from main() that way).
@@ -1640,6 +1665,7 @@
                pool_init(&exec_pool, NCARGS, 0, 0, PR_NOALIGN|PR_NOTOUCH,
                    "execargs", &exec_palloc, IPL_NONE);
                pool_sethardlimit(&exec_pool, maxexec, "should not happen", 0);
+               sysctl_kern_usrstack_setup();
        } else {
                KASSERT(rw_write_held(&exec_lock));
        }
diff -r 18c9e93e4c17 -r 6ba61cbf12aa sys/sys/sysctl.h
--- a/sys/sys/sysctl.h  Sat Oct 13 15:28:33 2012 +0000
+++ b/sys/sys/sysctl.h  Sat Oct 13 15:35:55 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sysctl.h,v 1.201 2012/06/09 02:31:15 christos Exp $    */
+/*     $NetBSD: sysctl.h,v 1.202 2012/10/13 15:35:56 christos Exp $    */
 
 /*
  * Copyright (c) 1989, 1993
@@ -273,7 +273,8 @@
 #define        KERN_SYSVIPC            82      /* node: SysV IPC parameters */
 #define        KERN_BOOTTIME           83      /* struct: time kernel was booted */
 #define        KERN_EVCNT              84      /* struct: evcnts */
-#define        KERN_MAXID              85      /* number of valid kern ids */
+#define        KERN_USRSTACK           85      /* long: user stack base */
+#define        KERN_MAXID              86      /* number of valid kern ids */
 
 
 #define        CTL_KERN_NAMES { \
@@ -362,6 +363,7 @@
        { "sysvipc", CTLTYPE_STRUCT }, \
        { "boottime", CTLTYPE_STRUCT }, \
        { "evcnt", CTLTYPE_STRUCT }, \
+       { "usrstack", CTLTYPE_LONG }, \
 }
 
 /*



Home | Main Index | Thread Index | Old Index