2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 * export - EXPORT kernel extension
14 #include <afs/param.h>
15 #include <afsconfig.h>
20 #include "sys/types.h"
23 #include "sys/errno.h"
24 #include "sys/device.h"
27 #include "sys/malloc.h"
33 sym_t *toc_syms; /* symbol table */
34 int toc_nsyms; /* # of symbols */
35 caddr_t toc_strs; /* string table */
36 int toc_size; /* size of toc_syms */
39 * export - entry point to EXPORT kernel extension
42 * cmd - add/delete command
43 * uiop - uio vector describing any config params
51 monster = lockl(&kernel_lock, LOCK_SHORT);
54 case CFG_INIT: /* add EXPORT */
55 if (err = config(uiop))
59 case CFG_TERM: /* remove EXPORT */
60 if (err = export_cleanup())
69 if (monster != LOCK_NEST)
70 unlockl(&kernel_lock);
76 * config - process configuration data
79 register struct uio *uiop; {
81 register struct export_nl *np;
85 if (err = uiomove((char *)&conf, sizeof (conf), UIO_WRITE, uiop))
88 toc_nsyms = conf.nsyms;
89 toc_size = conf.symt_sz + conf.str_sz;
91 if (toc_nsyms * sizeof (sym_t) != conf.symt_sz
92 || toc_size > (1024 * 1024))
95 toc_syms = (sym_t *) xmalloc(toc_size, 2, kernel_heap);
100 toc_strs = (char *) &toc_syms[toc_nsyms];
103 * copy in the symbol table and the string table
105 if (err = copyin(conf.symtab, toc_syms, conf.symt_sz)
106 || (err = copyin(conf.strtab, toc_strs, conf.str_sz))) {
107 xmfree(toc_syms, kernel_heap);
113 * `TOC' format in kernel has offsets relocated to point directly
114 * into the string table.
116 for (sym = toc_syms; sym < &toc_syms[toc_nsyms]; ++sym)
117 if (sym->n_zeroes == 0)
118 sym->n_nptr = sym->n_offset + toc_strs;
124 * export_cleanup - cleanup EXPORT prior to removing kernel extension
129 * get rid of the symbol table
132 xmfree(toc_syms, kernel_heap);
142 * import_kfunc - import a kernel function that was mistakenly left
143 * off the exports list
146 * We are assuming that the functions we are importing from the
147 * kernel really are within the kernel. If they are actually
148 * exported from some other kernel extension (but referenced in
149 * the /unix symbol table) we are in trouble.
151 import_kfunc(struct k_func *kfp) {
153 register caddr_t *toc;
158 sym = sym_lookup("g_toc", 0);
160 printf("\nimport: can't ascertain kernel's TOC\n");
163 g_toc = (u_int *) sym->n_value;
166 sym = sym_lookup(kfp->name, 0);
168 printf("\nimport: function `%s' not found\n", kfp->name);
172 kfp->fdesc[0] = sym->n_value;
173 kfp->fdesc[1] = *g_toc;
176 *(u_int **) kfp->fpp = kfp->fdesc;
182 * import_kvar - import a kernel variable that was mistakenly left
183 * off the exports list
185 import_kvar(struct k_var *kvp, caddr_t *toc) {
190 switch (setjmpx(&jmpbuf)) {
198 sym = sym_lookup(kvp->name, 0);
200 printf("\nimport: variable `%s' not found\n", kvp->name);
205 * look through the caller's TOC for the reference to his surrogate
208 while (*toc != kvp->varp)
211 printf("import(%s): replacing my TOC at 0x%x: 0x%8x with 0x%8x\n"
212 , kvp->name, toc, *toc, sym->n_value);
215 * replace reference to surrogate with reference real
217 pri = i_disable(INTMAX);
218 *toc = (caddr_t) sym->n_value;
228 * Call vanilla syscalls
230 osetgroups(ngroups, gidset)
236 error = setgroups(ngroups, gidset);
241 okioctl(fdes, cmd, arg, ext)
247 error = kioctl(fdes, cmd, arg, ext);
254 struct sigcontext *sigctx;
257 #include <sys/user.h>
258 u.u_sigflags[signo] |= SA_FULLDUMP; /* XXX */
259 error = core(signo, sigctx);