From cee1e037da7213db868bb6bfc99884926330de56 Mon Sep 17 00:00:00 2001 From: markj Date: Wed, 14 Aug 2013 00:42:21 +0000 Subject: Use kld_{load,unload} instead of mod_{load,unload} for the linker file load and unload event handlers added in r254266. Reported by: jhb X-MFC with: r254266 --- share/man/man9/EVENTHANDLER.9 | 8 +++--- .../contrib/opensolaris/uts/common/dtrace/dtrace.c | 8 +++--- sys/cddl/dev/dtrace/dtrace_load.c | 10 +++---- sys/cddl/dev/dtrace/dtrace_unload.c | 4 +-- sys/cddl/dev/sdt/sdt.c | 32 +++++++++++----------- sys/kern/kern_linker.c | 4 +-- sys/sys/eventhandler.h | 10 +++---- 7 files changed, 38 insertions(+), 38 deletions(-) diff --git a/share/man/man9/EVENTHANDLER.9 b/share/man/man9/EVENTHANDLER.9 index ee015cd..c3b646d 100644 --- a/share/man/man9/EVENTHANDLER.9 +++ b/share/man/man9/EVENTHANDLER.9 @@ -199,10 +199,10 @@ Callbacks invoked when a new network interface appears. Callbacks invoked when a network interface is taken down. .It Vt bpf_track Callbacks invoked when a BPF listener attaches to/detaches from network interface. -.It Vt mod_load -Callbacks invoked after a module has been loaded. -.It Vt mod_unload -Callbacks invoked before a module is about to be unloaded. +.It Vt kld_load +Callbacks invoked after a linker file has been loaded. +.It Vt kld_unload +Callbacks invoked before a linker file is about to be unloaded. These callbacks may be used to return an error and prevent the unload from proceeding. .It Vt power_profile_change diff --git a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c index 425b445..9c007e7 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c +++ b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c @@ -241,8 +241,8 @@ int dtrace_in_probe; /* non-zero if executing a probe */ #if defined(__i386__) || defined(__amd64__) || defined(__mips__) || defined(__powerpc__) uintptr_t dtrace_in_probe_addr; /* Address of invop when already in probe */ #endif -static eventhandler_tag dtrace_modload_tag; -static eventhandler_tag dtrace_modunload_tag; +static eventhandler_tag dtrace_kld_load_tag; +static eventhandler_tag dtrace_kld_unload_tag; #endif /* @@ -15344,14 +15344,14 @@ dtrace_module_unloaded(modctl_t *ctl, int *error) #if !defined(sun) static void -dtrace_mod_load(void *arg __unused, linker_file_t lf) +dtrace_kld_load(void *arg __unused, linker_file_t lf) { dtrace_module_loaded(lf); } static void -dtrace_mod_unload(void *arg __unused, linker_file_t lf, int *error) +dtrace_kld_unload(void *arg __unused, linker_file_t lf, int *error) { if (*error != 0) diff --git a/sys/cddl/dev/dtrace/dtrace_load.c b/sys/cddl/dev/dtrace/dtrace_load.c index a153e7e..f37d593 100644 --- a/sys/cddl/dev/dtrace/dtrace_load.c +++ b/sys/cddl/dev/dtrace/dtrace_load.c @@ -56,11 +56,11 @@ dtrace_load(void *dummy) /* Hang our hook for exceptions. */ dtrace_invop_init(); - /* Register callbacks for module load and unload events. */ - dtrace_modload_tag = EVENTHANDLER_REGISTER(mod_load, - dtrace_mod_load, NULL, EVENTHANDLER_PRI_ANY); - dtrace_modunload_tag = EVENTHANDLER_REGISTER(mod_unload, - dtrace_mod_unload, NULL, EVENTHANDLER_PRI_ANY); + /* Register callbacks for linker file load and unload events. */ + dtrace_kld_load_tag = EVENTHANDLER_REGISTER(kld_load, + dtrace_kld_load, NULL, EVENTHANDLER_PRI_ANY); + dtrace_kld_unload_tag = EVENTHANDLER_REGISTER(kld_unload, + dtrace_kld_unload, NULL, EVENTHANDLER_PRI_ANY); /* * Initialise the mutexes without 'witness' because the dtrace diff --git a/sys/cddl/dev/dtrace/dtrace_unload.c b/sys/cddl/dev/dtrace/dtrace_unload.c index f8d2ec6..9e37114 100644 --- a/sys/cddl/dev/dtrace/dtrace_unload.c +++ b/sys/cddl/dev/dtrace/dtrace_unload.c @@ -67,8 +67,8 @@ dtrace_unload() } dtrace_provider = NULL; - EVENTHANDLER_DEREGISTER(mod_load, dtrace_modload_tag); - EVENTHANDLER_DEREGISTER(mod_unload, dtrace_modunload_tag); + EVENTHANDLER_DEREGISTER(kld_load, dtrace_kld_load_tag); + EVENTHANDLER_DEREGISTER(kld_unload, dtrace_kld_unload_tag); if ((state = dtrace_anon_grab()) != NULL) { /* diff --git a/sys/cddl/dev/sdt/sdt.c b/sys/cddl/dev/sdt/sdt.c index 493ab9b..a1cd1e2 100644 --- a/sys/cddl/dev/sdt/sdt.c +++ b/sys/cddl/dev/sdt/sdt.c @@ -58,8 +58,8 @@ static void sdt_load(void *); static int sdt_unload(void *); static void sdt_create_provider(struct sdt_provider *); static void sdt_create_probe(struct sdt_probe *); -static void sdt_modload(void *, struct linker_file *); -static void sdt_modunload(void *, struct linker_file *, int *); +static void sdt_kld_load(void *, struct linker_file *); +static void sdt_kld_unload(void *, struct linker_file *, int *); static MALLOC_DEFINE(M_SDT, "SDT", "DTrace SDT providers"); @@ -94,8 +94,8 @@ static struct cdev *sdt_cdev; static TAILQ_HEAD(, sdt_provider) sdt_prov_list; -eventhandler_tag modload_tag; -eventhandler_tag modunload_tag; +eventhandler_tag sdt_kld_load_tag; +eventhandler_tag sdt_kld_unload_tag; static void sdt_create_provider(struct sdt_provider *prov) @@ -229,7 +229,7 @@ sdt_destroy(void *arg, dtrace_id_t id, void *parg) * and dtrace_register() will try to acquire it again. */ static void -sdt_modload(void *arg __unused, struct linker_file *lf) +sdt_kld_load(void *arg __unused, struct linker_file *lf) { struct sdt_provider **prov, **begin, **end; struct sdt_probe **probe, **p_begin, **p_end; @@ -260,7 +260,7 @@ sdt_modload(void *arg __unused, struct linker_file *lf) } static void -sdt_modunload(void *arg __unused, struct linker_file *lf, int *error __unused) +sdt_kld_unload(void *arg __unused, struct linker_file *lf, int *error __unused) { struct sdt_provider *prov, **curr, **begin, **end, *tmp; @@ -268,12 +268,12 @@ sdt_modunload(void *arg __unused, struct linker_file *lf, int *error __unused) /* We already have an error, so don't do anything. */ return; else if (linker_file_lookup_set(lf, "sdt_providers_set", &begin, &end, NULL)) - /* No DTrace providers are declared in this module. */ + /* No DTrace providers are declared in this file. */ return; /* - * Go through all the providers declared in this module and unregister - * any that aren't declared in another loaded module. + * Go through all the providers declared in this linker file and + * unregister any that aren't declared in another loaded file. */ for (curr = begin; curr < end; curr++) { TAILQ_FOREACH_SAFE(prov, &sdt_prov_list, prov_entry, tmp) { @@ -296,7 +296,7 @@ static int sdt_linker_file_cb(linker_file_t lf, void *arg __unused) { - sdt_modload(NULL, lf); + sdt_kld_load(NULL, lf); return (0); } @@ -313,12 +313,12 @@ sdt_load(void *arg __unused) sdt_probe_func = dtrace_probe; - modload_tag = EVENTHANDLER_REGISTER(mod_load, sdt_modload, NULL, - EVENTHANDLER_PRI_ANY); - modunload_tag = EVENTHANDLER_REGISTER(mod_unload, sdt_modunload, NULL, + sdt_kld_load_tag = EVENTHANDLER_REGISTER(kld_load, sdt_kld_load, NULL, EVENTHANDLER_PRI_ANY); + sdt_kld_unload_tag = EVENTHANDLER_REGISTER(kld_unload, sdt_kld_unload, + NULL, EVENTHANDLER_PRI_ANY); - /* Pick up probes from the kernel and already-loaded modules. */ + /* Pick up probes from the kernel and already-loaded linker files. */ linker_file_foreach(sdt_linker_file_cb, NULL); } @@ -327,8 +327,8 @@ sdt_unload(void *arg __unused) { struct sdt_provider *prov, *tmp; - EVENTHANDLER_DEREGISTER(mod_load, modload_tag); - EVENTHANDLER_DEREGISTER(mod_unload, modunload_tag); + EVENTHANDLER_DEREGISTER(kld_load, sdt_kld_load_tag); + EVENTHANDLER_DEREGISTER(kld_unload, sdt_kld_unload_tag); sdt_probe_func = sdt_probe_stub; diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c index 252bd2e..3e500f3 100644 --- a/sys/kern/kern_linker.c +++ b/sys/kern/kern_linker.c @@ -1046,7 +1046,7 @@ kern_kldload(struct thread *td, const char *file, int *fileid) if (fileid != NULL) *fileid = lf->id; - EVENTHANDLER_INVOKE(mod_load, lf); + EVENTHANDLER_INVOKE(kld_load, lf); #ifdef HWPMC_HOOKS KLD_DOWNGRADE(); @@ -1103,7 +1103,7 @@ kern_kldunload(struct thread *td, int fileid, int flags) if (lf) { KLD_DPF(FILE, ("kldunload: lf->userrefs=%d\n", lf->userrefs)); - EVENTHANDLER_INVOKE(mod_unload, lf, &error); + EVENTHANDLER_INVOKE(kld_unload, lf, &error); if (error != 0) error = EBUSY; else if (lf->userrefs == 0) { diff --git a/sys/sys/eventhandler.h b/sys/sys/eventhandler.h index 7e1eee2..a1f9c55 100644 --- a/sys/sys/eventhandler.h +++ b/sys/sys/eventhandler.h @@ -266,11 +266,11 @@ EVENTHANDLER_DECLARE(nmbclusters_change, uma_zone_chfn); EVENTHANDLER_DECLARE(nmbufs_change, uma_zone_chfn); EVENTHANDLER_DECLARE(maxsockets_change, uma_zone_chfn); -/* Module load and unload events */ +/* Kernel linker file load and unload events */ struct linker_file; -typedef void (*mod_load_fn)(void *, struct linker_file *); -typedef void (*mod_unload_fn)(void *, struct linker_file *, int *); -EVENTHANDLER_DECLARE(mod_load, mod_load_fn); -EVENTHANDLER_DECLARE(mod_unload, mod_unload_fn); +typedef void (*kld_load_fn)(void *, struct linker_file *); +typedef void (*kld_unload_fn)(void *, struct linker_file *, int *); +EVENTHANDLER_DECLARE(kld_load, kld_load_fn); +EVENTHANDLER_DECLARE(kld_unload, kld_unload_fn); #endif /* SYS_EVENTHANDLER_H */ -- cgit v1.1