From isupov@moonhe.jinr.ru Wed Jul 7 00:50:04 1999 Return-Path: Received: from jimex.jinr.ru (jimex.jinr.ru [159.93.17.7]) by hub.freebsd.org (Postfix) with ESMTP id 272D214C8B for ; Wed, 7 Jul 1999 00:49:51 -0700 (PDT) (envelope-from isupov@moonhe.jinr.ru) Received: from moonhe.jinr.ru (isupov@moonhe.jinr.ru [159.93.18.27]) by jimex.jinr.ru (8.8.8/8.8.4) with ESMTP id LAA18798 for ; Wed, 7 Jul 1999 11:49:33 +0400 (MSD) Received: (from isupov@localhost) by moonhe.jinr.ru (8.8.8/8.8.8) id LAA11890; Wed, 7 Jul 1999 11:49:09 +0400 (MSD) (envelope-from isupov) Message-Id: <199907070749.LAA11890@moonhe.jinr.ru> Date: Wed, 7 Jul 1999 11:49:09 +0400 (MSD) From: isupov@moonhe.jinr.ru Reply-To: isupov@moonhe.jinr.ru To: FreeBSD-gnats-submit@freebsd.org Subject: kldload(8) should be more sensitive to errors in *_module_handler(..., MOD_LOAD, ...) X-Send-Pr-Version: 3.2 >Number: 12545 >Category: bin >Synopsis: kldload(8) should be more sensitive to errors in *_module_handler(..., MOD_LOAD, ...) >Confidential: no >Severity: non-critical >Priority: low >Responsible: peter >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Jul 7 01:00:00 PDT 1999 >Closed-Date: >Last-Modified: Tue Feb 05 01:50:55 PST 2002 >Originator: Isupov A.Yu. >Release: FreeBSD -current >Organization: JINR, LHE >Environment: FreeBSD -current >Description: 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). >How-To-Repeat: >Fix: Here is a patches for kldload.c v 1.5 : *** kldload.c.orig Wed Jul 7 11:12:55 1999 --- kldload.c Wed Jul 7 11:30:36 1999 *************** *** 34,39 **** --- 34,41 ---- #include #include #include + #include + #include 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); } -------------------------------------------------------------------- and for kldload.8 v 1.5 : *** kldload.8.orig Wed Jul 7 11:34:24 1999 --- kldload.8 Wed Jul 7 11:41:19 1999 *************** *** 54,62 **** .Sh DIAGNOSTICS The .Nm ! utility exits with a status of 0 on success ! and with a nonzero status if an error occurs. .Sh SEE ALSO .Xr kldstat 8 , .Xr kldunload 8 .Sh HISTORY --- 54,64 ---- .Sh DIAGNOSTICS The .Nm ! utility returns the number of modules in the loaded file as exit code, ! the EX_SOFTWARE if file doesn't contains any successful modules and was unloaded, ! and the EX_OSERR if other error occurs. .Sh SEE ALSO + .Xr sysexits 3 , .Xr kldstat 8 , .Xr kldunload 8 .Sh HISTORY --------------------------------------------------------------------------- >Release-Note: >Audit-Trail: State-Changed-From-To: open->feedback State-Changed-By: iedowse State-Changed-When: Sun Jan 20 10:15:50 PST 2002 State-Changed-Why: Is this problem still present? http://www.FreeBSD.org/cgi/query-pr.cgi?pr=12545 From: "A.Yu.Isupov" To: freebsd-gnats-submit@freebsd.org Cc: Subject: Re: bin/12545 Date: Mon, 21 Jan 2002 11:34:13 +0300 (MSK) 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 State-Changed-By: sheldonh State-Changed-When: Thu Jan 31 07:07:22 PST 2002 State-Changed-Why: Doug, are you still looking after kld* utilities? Responsible-Changed-From-To: freebsd-bugs->dfr Responsible-Changed-By: sheldonh Responsible-Changed-When: Thu Jan 31 07:07:22 PST 2002 Responsible-Changed-Why: Feedback acquired. http://www.FreeBSD.org/cgi/query-pr.cgi?pr=12545 Responsible-Changed-From-To: dfr->peter Responsible-Changed-By: sheldonh Responsible-Changed-When: Tue Feb 5 01:50:17 PST 2002 Responsible-Changed-Why: Peter, Doug says you're my best bet for an interested party. Are you still interested in kld*(8)-related PRs? http://www.FreeBSD.org/cgi/query-pr.cgi?pr=12545 >Unformatted: