Module Name:    src
Committed By:   pooka
Date:           Mon Dec  9 16:49:43 UTC 2013

Modified Files:
        src/sys/kern: kern_subr.c kern_syscall.c

Log Message:
Group more syscall related routines together (kern_subr -> kern_syscall)


To generate a diff of this commit:
cvs rdiff -u -r1.213 -r1.214 src/sys/kern/kern_subr.c
cvs rdiff -u -r1.7 -r1.8 src/sys/kern/kern_syscall.c

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

Modified files:

Index: src/sys/kern/kern_subr.c
diff -u src/sys/kern/kern_subr.c:1.213 src/sys/kern/kern_subr.c:1.214
--- src/sys/kern/kern_subr.c:1.213	Sun Jun 10 17:05:18 2012
+++ src/sys/kern/kern_subr.c	Mon Dec  9 16:49:43 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_subr.c,v 1.213 2012/06/10 17:05:18 mlelstv Exp $	*/
+/*	$NetBSD: kern_subr.c,v 1.214 2013/12/09 16:49:43 pooka Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 1999, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@@ -79,13 +79,10 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.213 2012/06/10 17:05:18 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.214 2013/12/09 16:49:43 pooka Exp $");
 
 #include "opt_ddb.h"
 #include "opt_md.h"
-#include "opt_syscall_debug.h"
-#include "opt_ktrace.h"
-#include "opt_ptrace.h"
 #include "opt_tftproot.h"
 
 #include <sys/param.h>
@@ -98,8 +95,6 @@ __KERNEL_RCSID(0, "$NetBSD: kern_subr.c,
 #include <sys/disk.h>
 #include <sys/disklabel.h>
 #include <sys/queue.h>
-#include <sys/ktrace.h>
-#include <sys/ptrace.h>
 #include <sys/fcntl.h>
 #include <sys/kauth.h>
 #include <sys/stat.h>
@@ -656,81 +651,3 @@ parsedisk(char *str, int len, int defpar
 	*cp = c;
 	return (dv);
 }
-
-/*
- * Return true if system call tracing is enabled for the specified process.
- */
-bool
-trace_is_enabled(struct proc *p)
-{
-#ifdef SYSCALL_DEBUG
-	return (true);
-#endif
-#ifdef KTRACE
-	if (ISSET(p->p_traceflag, (KTRFAC_SYSCALL | KTRFAC_SYSRET)))
-		return (true);
-#endif
-#ifdef PTRACE
-	if (ISSET(p->p_slflag, PSL_SYSCALL))
-		return (true);
-#endif
-
-	return (false);
-}
-
-/*
- * Start trace of particular system call. If process is being traced,
- * this routine is called by MD syscall dispatch code just before
- * a system call is actually executed.
- */
-int
-trace_enter(register_t code, const register_t *args, int narg)
-{
-	int error = 0;
-
-#ifdef SYSCALL_DEBUG
-	scdebug_call(code, args);
-#endif /* SYSCALL_DEBUG */
-
-	ktrsyscall(code, args, narg);
-
-#ifdef PTRACE
-	if ((curlwp->l_proc->p_slflag & (PSL_SYSCALL|PSL_TRACED)) ==
-	    (PSL_SYSCALL|PSL_TRACED)) {
-		process_stoptrace();
-		if (curlwp->l_proc->p_slflag & PSL_SYSCALLEMU) {
-			/* tracer will emulate syscall for us */
-			error = EJUSTRETURN;
-		}
-	}
-#endif
-	return error;
-}
-
-/*
- * End trace of particular system call. If process is being traced,
- * this routine is called by MD syscall dispatch code just after
- * a system call finishes.
- * MD caller guarantees the passed 'code' is within the supported
- * system call number range for emulation the process runs under.
- */
-void
-trace_exit(register_t code, register_t rval[], int error)
-{
-#ifdef PTRACE
-	struct proc *p = curlwp->l_proc;
-#endif
-
-#ifdef SYSCALL_DEBUG
-	scdebug_ret(code, error, rval);
-#endif /* SYSCALL_DEBUG */
-
-	ktrsysret(code, error, rval);
-	
-#ifdef PTRACE
-	if ((p->p_slflag & (PSL_SYSCALL|PSL_TRACED|PSL_SYSCALLEMU)) ==
-	    (PSL_SYSCALL|PSL_TRACED))
-		process_stoptrace();
-	CLR(p->p_slflag, PSL_SYSCALLEMU);
-#endif
-}

Index: src/sys/kern/kern_syscall.c
diff -u src/sys/kern/kern_syscall.c:1.7 src/sys/kern/kern_syscall.c:1.8
--- src/sys/kern/kern_syscall.c:1.7	Sat May  5 19:37:37 2012
+++ src/sys/kern/kern_syscall.c	Mon Dec  9 16:49:43 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_syscall.c,v 1.7 2012/05/05 19:37:37 christos Exp $	*/
+/*	$NetBSD: kern_syscall.c,v 1.8 2013/12/09 16:49:43 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,9 +30,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_syscall.c,v 1.7 2012/05/05 19:37:37 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_syscall.c,v 1.8 2013/12/09 16:49:43 pooka Exp $");
 
+#ifdef _KERNEL_OPT
 #include "opt_modular.h"
+#include "opt_syscall_debug.h"
+#include "opt_ktrace.h"
+#include "opt_ptrace.h"
+#endif
 
 /* XXX To get syscall prototypes. */
 #define SYSVSHM
@@ -47,6 +52,8 @@ __KERNEL_RCSID(0, "$NetBSD: kern_syscall
 #include <sys/syscallvar.h>
 #include <sys/systm.h>
 #include <sys/xcall.h>
+#include <sys/ktrace.h>
+#include <sys/ptrace.h>
 
 int
 sys_nomodule(struct lwp *l, const void *v, register_t *retval)
@@ -334,3 +341,81 @@ syscall_disestablish(const struct emul *
 
 	return 0;
 }
+
+/*
+ * Return true if system call tracing is enabled for the specified process.
+ */
+bool
+trace_is_enabled(struct proc *p)
+{
+#ifdef SYSCALL_DEBUG
+	return (true);
+#endif
+#ifdef KTRACE
+	if (ISSET(p->p_traceflag, (KTRFAC_SYSCALL | KTRFAC_SYSRET)))
+		return (true);
+#endif
+#ifdef PTRACE
+	if (ISSET(p->p_slflag, PSL_SYSCALL))
+		return (true);
+#endif
+
+	return (false);
+}
+
+/*
+ * Start trace of particular system call. If process is being traced,
+ * this routine is called by MD syscall dispatch code just before
+ * a system call is actually executed.
+ */
+int
+trace_enter(register_t code, const register_t *args, int narg)
+{
+	int error = 0;
+
+#ifdef SYSCALL_DEBUG
+	scdebug_call(code, args);
+#endif /* SYSCALL_DEBUG */
+
+	ktrsyscall(code, args, narg);
+
+#ifdef PTRACE
+	if ((curlwp->l_proc->p_slflag & (PSL_SYSCALL|PSL_TRACED)) ==
+	    (PSL_SYSCALL|PSL_TRACED)) {
+		process_stoptrace();
+		if (curlwp->l_proc->p_slflag & PSL_SYSCALLEMU) {
+			/* tracer will emulate syscall for us */
+			error = EJUSTRETURN;
+		}
+	}
+#endif
+	return error;
+}
+
+/*
+ * End trace of particular system call. If process is being traced,
+ * this routine is called by MD syscall dispatch code just after
+ * a system call finishes.
+ * MD caller guarantees the passed 'code' is within the supported
+ * system call number range for emulation the process runs under.
+ */
+void
+trace_exit(register_t code, register_t rval[], int error)
+{
+#ifdef PTRACE
+	struct proc *p = curlwp->l_proc;
+#endif
+
+#ifdef SYSCALL_DEBUG
+	scdebug_ret(code, error, rval);
+#endif /* SYSCALL_DEBUG */
+
+	ktrsysret(code, error, rval);
+	
+#ifdef PTRACE
+	if ((p->p_slflag & (PSL_SYSCALL|PSL_TRACED|PSL_SYSCALLEMU)) ==
+	    (PSL_SYSCALL|PSL_TRACED))
+		process_stoptrace();
+	CLR(p->p_slflag, PSL_SYSCALLEMU);
+#endif
+}

Reply via email to