kern_module.c (42439) | kern_module.c (43301) |
---|---|
1/*- 2 * Copyright (c) 1997 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 1997 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $Id: kern_module.c,v 1.13 1999/01/09 14:59:50 dfr Exp $ | 26 * $Id: kern_module.c,v 1.14 1999/01/09 16:50:04 dfr Exp $ |
27 */ 28 29#include <sys/param.h> 30#include <sys/kernel.h> 31#include <sys/systm.h> 32#include <sys/malloc.h> 33#include <sys/sysproto.h> 34#include <sys/sysent.h> --- 79 unchanged lines hidden (view full) --- 114 if (container == NULL) 115 container = linker_current_file; 116 if (container) { 117 TAILQ_INSERT_TAIL(&container->modules, newmod, flink); 118 newmod->file = container; 119 } else 120 newmod->file = 0; 121 | 27 */ 28 29#include <sys/param.h> 30#include <sys/kernel.h> 31#include <sys/systm.h> 32#include <sys/malloc.h> 33#include <sys/sysproto.h> 34#include <sys/sysent.h> --- 79 unchanged lines hidden (view full) --- 114 if (container == NULL) 115 container = linker_current_file; 116 if (container) { 117 TAILQ_INSERT_TAIL(&container->modules, newmod, flink); 118 newmod->file = container; 119 } else 120 newmod->file = 0; 121 |
122 if (error = MOD_EVENT(newmod, MOD_LOAD)) { | 122 if ((error = MOD_EVENT(newmod, MOD_LOAD)) != 0) { |
123 MOD_EVENT(newmod, MOD_UNLOAD); 124 module_release(newmod); 125 return error; 126 } 127 128 return 0; 129} 130 --- 140 unchanged lines hidden (view full) --- 271 if (!mod) 272 return ENOENT; 273 274 stat = SCARG(uap, stat); 275 276 /* 277 * Check the version of the user's structure. 278 */ | 123 MOD_EVENT(newmod, MOD_UNLOAD); 124 module_release(newmod); 125 return error; 126 } 127 128 return 0; 129} 130 --- 140 unchanged lines hidden (view full) --- 271 if (!mod) 272 return ENOENT; 273 274 stat = SCARG(uap, stat); 275 276 /* 277 * Check the version of the user's structure. 278 */ |
279 if (error = copyin(&stat->version, &version, sizeof(version))) | 279 if ((error = copyin(&stat->version, &version, sizeof(version))) != 0) |
280 goto out; 281 if (version != sizeof(struct module_stat_v1) 282 && version != sizeof(struct module_stat)) { 283 error = EINVAL; 284 goto out; 285 } 286 287 namelen = strlen(mod->name) + 1; 288 if (namelen > MAXMODNAME) 289 namelen = MAXMODNAME; | 280 goto out; 281 if (version != sizeof(struct module_stat_v1) 282 && version != sizeof(struct module_stat)) { 283 error = EINVAL; 284 goto out; 285 } 286 287 namelen = strlen(mod->name) + 1; 288 if (namelen > MAXMODNAME) 289 namelen = MAXMODNAME; |
290 if (error = copyout(mod->name, &stat->name[0], namelen)) | 290 if ((error = copyout(mod->name, &stat->name[0], namelen)) != 0) |
291 goto out; 292 | 291 goto out; 292 |
293 if (error = copyout(&mod->refs, &stat->refs, sizeof(int))) | 293 if ((error = copyout(&mod->refs, &stat->refs, sizeof(int))) != 0) |
294 goto out; | 294 goto out; |
295 if (error = copyout(&mod->id, &stat->id, sizeof(int))) | 295 if ((error = copyout(&mod->id, &stat->id, sizeof(int))) != 0) |
296 goto out; 297 298 /* 299 * >v1 stat includes module data. 300 */ 301 if (version == sizeof(struct module_stat)) { | 296 goto out; 297 298 /* 299 * >v1 stat includes module data. 300 */ 301 if (version == sizeof(struct module_stat)) { |
302 if (error = copyout(&mod->data, &stat->data, sizeof(mod->data))) | 302 if ((error = copyout(&mod->data, &stat->data, sizeof(mod->data))) != 0) |
303 goto out; 304 } 305 306 p->p_retval[0] = 0; 307 308out: 309 return error; 310} 311 312int 313modfind(struct proc* p, struct modfind_args* uap) 314{ 315 int error = 0; 316 char name[MAXMODNAME]; 317 module_t mod; 318 | 303 goto out; 304 } 305 306 p->p_retval[0] = 0; 307 308out: 309 return error; 310} 311 312int 313modfind(struct proc* p, struct modfind_args* uap) 314{ 315 int error = 0; 316 char name[MAXMODNAME]; 317 module_t mod; 318 |
319 if (error = copyinstr(SCARG(uap, name), name, sizeof name, 0)) | 319 if ((error = copyinstr(SCARG(uap, name), name, sizeof name, 0)) != 0) |
320 goto out; 321 322 mod = module_lookupbyname(name); 323 if (!mod) 324 error = ENOENT; 325 else 326 p->p_retval[0] = mod->id; 327 328out: 329 return error; 330} | 320 goto out; 321 322 mod = module_lookupbyname(name); 323 if (!mod) 324 error = ENOENT; 325 else 326 p->p_retval[0] = mod->id; 327 328out: 329 return error; 330} |