summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_exec.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2003-03-24 21:15:35 +0000
committerjhb <jhb@FreeBSD.org>2003-03-24 21:15:35 +0000
commit98a481610a9dcb442e9c2e851c6ef2a330027e45 (patch)
tree41fad1aa97bccfd68308cf8a8ff0de8b8f243493 /sys/kern/kern_exec.c
parent01298a9735ccfad61628107327cfb25e49f8248b (diff)
downloadFreeBSD-src-98a481610a9dcb442e9c2e851c6ef2a330027e45.zip
FreeBSD-src-98a481610a9dcb442e9c2e851c6ef2a330027e45.tar.gz
Replace the at_fork, at_exec, and at_exit functions with the slightly more
flexible process_fork, process_exec, and process_exit eventhandlers. This reduces code duplication and also means that I don't have to go duplicate the eventhandler locking three more times for each of at_fork, at_exec, and at_exit. Reviewed by: phk, jake, almost complete silence on arch@
Diffstat (limited to 'sys/kern/kern_exec.c')
-rw-r--r--sys/kern/kern_exec.c61
1 files changed, 2 insertions, 59 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index a359b75..a8c668b 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -31,6 +31,7 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/eventhandler.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/sysproto.h>
@@ -72,25 +73,12 @@
MALLOC_DEFINE(M_PARGS, "proc-args", "Process arguments");
-static MALLOC_DEFINE(M_ATEXEC, "atexec", "atexec callback");
-
static int sysctl_kern_ps_strings(SYSCTL_HANDLER_ARGS);
static int sysctl_kern_usrstack(SYSCTL_HANDLER_ARGS);
static int sysctl_kern_stackprot(SYSCTL_HANDLER_ARGS);
static int kern_execve(struct thread *td, char *fname, char **argv,
char **envv, struct mac *mac_p);
-/*
- * callout list for things to do at exec time
- */
-struct execlist {
- execlist_fn function;
- TAILQ_ENTRY(execlist) next;
-};
-
-TAILQ_HEAD(exec_list_head, execlist);
-static struct exec_list_head exec_list = TAILQ_HEAD_INITIALIZER(exec_list);
-
/* XXX This should be vm_size_t. */
SYSCTL_PROC(_kern, KERN_PS_STRINGS, ps_strings, CTLTYPE_ULONG|CTLFLAG_RD,
NULL, 0, sysctl_kern_ps_strings, "LU", "");
@@ -840,7 +828,6 @@ exec_new_vmspace(imgp, sv)
struct sysentvec *sv;
{
int error;
- struct execlist *ep;
struct proc *p = imgp->proc;
struct vmspace *vmspace = p->p_vmspace;
vm_offset_t stack_addr;
@@ -852,11 +839,7 @@ exec_new_vmspace(imgp, sv)
imgp->vmspace_destroyed = 1;
- /*
- * Perform functions registered with at_exec().
- */
- TAILQ_FOREACH(ep, &exec_list, next)
- (*ep->function)(p);
+ EVENTHANDLER_INVOKE(process_exec, p);
/*
* Blow away entire process VM, if address space not shared,
@@ -1223,43 +1206,3 @@ exec_unregister(execsw_arg)
execsw = newexecsw;
return (0);
}
-
-int
-at_exec(function)
- execlist_fn function;
-{
- struct execlist *ep;
-
-#ifdef INVARIANTS
- /* Be noisy if the programmer has lost track of things */
- if (rm_at_exec(function))
- printf("WARNING: exec callout entry (%p) already present\n",
- function);
-#endif
- ep = malloc(sizeof(*ep), M_ATEXEC, M_NOWAIT);
- if (ep == NULL)
- return (ENOMEM);
- ep->function = function;
- TAILQ_INSERT_TAIL(&exec_list, ep, next);
- return (0);
-}
-
-/*
- * Scan the exec callout list for the given item and remove it.
- * Returns the number of items removed (0 or 1)
- */
-int
-rm_at_exec(function)
- execlist_fn function;
-{
- struct execlist *ep;
-
- TAILQ_FOREACH(ep, &exec_list, next) {
- if (ep->function == function) {
- TAILQ_REMOVE(&exec_list, ep, next);
- free(ep, M_ATEXEC);
- return (1);
- }
- }
- return (0);
-}
OpenPOWER on IntegriCloud