diff options
author | dfr <dfr@FreeBSD.org> | 1999-01-09 14:59:50 +0000 |
---|---|---|
committer | dfr <dfr@FreeBSD.org> | 1999-01-09 14:59:50 +0000 |
commit | 24b62c894f6eedf71185e326e377b40bfe3aa113 (patch) | |
tree | 24f9f2d63d987cb22020a57c75538f5252f97d26 /sys/kern/kern_module.c | |
parent | 1c2ce69de1c6327a976692e04b95597ef93d83e6 (diff) | |
download | FreeBSD-src-24b62c894f6eedf71185e326e377b40bfe3aa113.zip FreeBSD-src-24b62c894f6eedf71185e326e377b40bfe3aa113.tar.gz |
Implement a mechanism for a module to report a small amount of module
specific data back to the user via kldstat(2). Use that mechanism in
the syscall handler to report the syscall number used.
Diffstat (limited to 'sys/kern/kern_module.c')
-rw-r--r-- | sys/kern/kern_module.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/sys/kern/kern_module.c b/sys/kern/kern_module.c index 34b5c67..5fd126f 100644 --- a/sys/kern/kern_module.c +++ b/sys/kern/kern_module.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: kern_module.c,v 1.11 1998/10/16 03:55:00 peter Exp $ + * $Id: kern_module.c,v 1.12 1998/11/06 02:18:57 peter Exp $ */ #include <sys/param.h> @@ -48,6 +48,7 @@ struct module { char *name; /* module name */ modeventhand_t handler; /* event handler */ void *arg; /* argument for handler */ + modspecific_t data; /* module specific data */ }; #define MOD_EVENT(mod, type) (mod)->handler((mod), (type), (mod)->arg) @@ -107,6 +108,7 @@ module_register(const char* name, modeventhand_t handler, void* arg, void *file) strcpy(newmod->name, name); newmod->handler = handler; newmod->arg = arg; + bzero(&newmod->data, sizeof(newmod->data)); TAILQ_INSERT_TAIL(&modules, newmod, link); if (container == NULL) @@ -196,6 +198,12 @@ module_getfnext(module_t mod) return TAILQ_NEXT(mod, flink); } +void +module_setspecific(module_t mod, modspecific_t *datap) +{ + mod->data = *datap; +} + /* * Syscalls. */ @@ -243,6 +251,13 @@ modfnext(struct proc* p, struct modfnext_args* uap) return 0; } +struct module_stat_v1 { + int version; /* set to sizeof(struct module_stat) */ + char name[MAXMODNAME]; + int refs; + int id; +}; + int modstat(struct proc* p, struct modstat_args* uap) { @@ -263,7 +278,8 @@ modstat(struct proc* p, struct modstat_args* uap) */ if (error = copyin(&stat->version, &version, sizeof(version))) goto out; - if (version != sizeof(struct module_stat)) { + if (version != sizeof(struct module_stat_v1) + && version != sizeof(struct module_stat)) { error = EINVAL; goto out; } @@ -279,6 +295,15 @@ modstat(struct proc* p, struct modstat_args* uap) if (error = copyout(&mod->id, &stat->id, sizeof(int))) goto out; + /* + * >v1 stat includes module data. + */ + if (version == sizeof(struct module_stat)) { + if (error = copyout(&mod->data, &stat->data, sizeof(mod->data))) + goto out; + } else + printf("kldstat: v1 request\n"); + p->p_retval[0] = 0; out: |