Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Jul 2004 21:00:43 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Dan Nelson <dnelson@allantgroup.com>
Cc:        John Polstra <jdp@polstra.com>
Subject:   Re: kldload won't load
Message-ID:  <20040714204403.L1642@epsplex.bde.org>
In-Reply-To: <20040712213835.GA98593@dan.emsphone.com>
References:  <20040712194438.B9CFB16A4D1@hub.freebsd.org> <20040712213835.GA98593@dan.emsphone.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 12 Jul 2004, Dan Nelson wrote:

> In the last episode (Jul 12), John Polstra said:
> > On 12-Jul-2004 Bill Paul wrote:
> > > When a kernel module doesn't load correctly, this is your cue to
> > > run "dmesg" and look at the messages printed in the kernel message
> > > buffer. That will tell you why it didn't load. Of course, nobody
> > > ever remembers this, and apparently running xconsole is no longer
> > > in vogue.
> > >
> > > This needs to be a FAQ.
> >
> > No, it needs to be fixed.  It's printing a totally incorrect error
> > message, and nobody should have to use dmesg to find out what's really
> > happened.
>
> Maybe a uprintf would be useful here?  imgact_elf.c does that to add a
> little more info before returning ENOEXEC.

uprintf is worse than printf in most ways, since its output doesn't even
get logged.  Try associating the message in imgact_elf.c with the process
that caused the error when you run something like
"make -k world | tee world.out".

This is not fixed in the following patch.  The patch just attempts to add
printing of the name of what was not found and fixes some style bugs (error
messages are conventionally not termited by a ".").  I'm not sure that
imgp->stringbase is the correct name.  The process name should be printed
too, like err(3) would do it.  I'm not sure if one is available.  IIRC,
userland can't print a message in the usual way because we've committed
to an exec and have destroyed too much of the original process to return
to it.  We may have destroyed its name too.

%%%
Index: imgact_elf.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/imgact_elf.c,v
retrieving revision 1.151
diff -u -2 -r1.151 imgact_elf.c
--- imgact_elf.c	5 Jun 2004 02:18:28 -0000	1.151
+++ imgact_elf.c	5 Jun 2004 06:51:25 -0000
@@ -694,6 +693,6 @@
 	brand_info = __elfN(get_brandinfo)(hdr, interp);
 	if (brand_info == NULL) {
-		uprintf("ELF binary type \"%u\" not known.\n",
-		    hdr->e_ident[EI_OSABI]);
+		uprintf("%s: ELF binary type \"%u\" not known.\n",
+		    imgp->stringbase, hdr->e_ident[EI_OSABI]);
 		error = ENOEXEC;
 		goto fail;
@@ -828,5 +827,6 @@
 		    &imgp->entry_addr, sv->sv_pagesize);
 		if (error != 0) {
-			uprintf("ELF interpreter %s not found\n", interp);
+			uprintf("%s: ELF interpreter %s not found\n",
+			    imgp->stringbase, interp);
 			goto fail;
 		}
%%%

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040714204403.L1642>