| Summary: | kldload(8) should be more sensitive to errors in *_module_handler(..., MOD_LOAD, ...) | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Base System | Reporter: | isupov <isupov> | ||||
| Component: | bin | Assignee: | freebsd-bugs (Nobody) <bugs> | ||||
| Status: | Closed FIXED | ||||||
| Severity: | Affects Only Me | ||||||
| Priority: | Normal | ||||||
| Version: | Unspecified | ||||||
| Hardware: | Any | ||||||
| OS: | Any | ||||||
| Attachments: |
|
||||||
State Changed From-To: open->feedback Is this problem still present? At least kern_module.c:module_register_init() (ver. 1.28) and kern_linker.c:linker_file_sysinit() (ver. 1.73) are still of type void, so all it's errors aren't recognized by kldload(2) and kldload(8)... Proposed patches for kldload(8) were workaround, which constatate, not solves a problem, and not satisfactory for all possible situations. State Changed From-To: feedback->open Doug, are you still looking after kld* utilities? Responsible Changed From-To: freebsd-bugs->dfr Feedback acquired. Responsible Changed From-To: dfr->peter Peter, Doug says you're my best bet for an interested party. Are you still interested in kld*(8)-related PRs? State Changed From-To: open->closed The enclosed patch is still wrong, as per the previous comment. Closing as WONTFIX, if only gnats had such a state. Responsible Changed From-To: peter->freebsd-bugs The enclosed patch is still wrong, as per the previous comment. Closing as WONTFIX, if only gnats had such a state. |
In the -current kldload(8) returns 0 (success), if error occur in *_module_handler(..., MOD_LOAD, ...), because of kern_module.c:module_register_init() and kern_linker.c:linker_file_sysinit() are of type void. As I can see, change their type not so easy :) , so we can't (???) solve the problem in kldload(2). But kldload(8) can at least try to resolve post-loading situation and returns different exit status for: 1) loaded file doesn't contains modules at all (f.e. EX_SOFTWARE); 2) loaded file contains some modules (f.e. number_of_modules); Unfortunately, so we will not success code (EX_OK), because of we can't know, what number of modules loaded file must contains, if loading is successful. But case 1) will be reliably distinguished. We can also unload file in the case 1). Fix: Here is a patches for kldload.c v 1.5 : -------------------------------------------------------------------- and for kldload.8 v 1.5 : -----------------------------------------------------------------------------9zDE0TDMlx5txDS5G2HpQ2USAjHcfGyqZ725yX3o7DzJW9wy Content-Type: text/plain; name="file.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="file.diff" *** kldload.c.orig Wed Jul 7 11:12:55 1999 --- kldload.c Wed Jul 7 11:30:36 1999 *************** *** 34,39 **** --- 34,41 ---- #include <unistd.h> #include <sys/param.h> #include <sys/linker.h> + #include <sys/module.h> + #include <sysexits.h> static void usage(void) *************** *** 48,53 **** --- 50,56 ---- int c; int verbose = 0; int fileid; + int modid, mod_cnt = 0; while ((c = getopt(argc, argv, "v")) != -1) switch (c) { *************** *** 65,74 **** fileid = kldload(argv[0]); if (fileid < 0) ! err(1, "can't load %s", argv[0]); ! else if (verbose) ! printf("Loaded %s, id=%d\n", argv[0], fileid); ! return 0; } --- 68,86 ---- fileid = kldload(argv[0]); if (fileid < 0) ! err(EX_OSERR, "can't load %s", argv[0]); ! ! for (modid = kldfirstmod(fileid); modid > 0; modid = modfnext(modid)) ! mod_cnt++; ! ! if (!mod_cnt) { ! if (kldunload(fileid) < 0) ! err(EX_OSERR, "can't unload file"); ! } else { if (verbose) ! printf("Loaded %s, id=%d with %d modules\n", ! argv[0], fileid, mod_cnt); ! } ! return (mod_cnt ? mod_cnt : EX_SOFTWARE); }