Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 06 Aug 2001 00:24:40 +0100
From:      Brian Somers <brian@Awfulhak.org>
To:        Mike Smith <msmith@FreeBSD.ORG>
Cc:        Dima Dorfman <dima@unixfreak.org>, Brian Somers <brian@Awfulhak.org>, arch@FreeBSD.ORG, brian@freebsd-services.com, brian@freebsd-services.com
Subject:   Re: Library routine to load a kld if it already isn't 
Message-ID:  <200108052324.f75NOeu49363@hak.lan.Awfulhak.org>
In-Reply-To: Message from Mike Smith <msmith@FreeBSD.ORG>  of "Sun, 05 Aug 2001 15:22:45 PDT." <200108052222.f75MMj100826@mass.dis.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
> > > > Sharball of the implementation and man page is attached (extract into
> > > > src/lib/libc/gen).  Comments?  Suggestions?
> > > 
> > > This is normally done with:
> > > 
> > >   if (modfind("module") == -1 && ID0kldload("module") == -1)
> > >     errx();
> > > 
> > > I don't think it's a good idea to change this.
> > 
> > Only it's wrong in some cases.  Some modules will have a bus attached
> 
> Please see ifmaybeload() in src/sbin/ifconfig/ifconfig.c.
> 
> I would like to see a library function like kmodule_require(), which would 
> take a *module* name and version number constrants similar to those taken 
> by loadable modules themselves.

From sys/kern/kern_linker.c:

/*
 * Find a file which contains given module and load it,
 * if "parent" is not NULL, register a reference to it.
 */
static int
linker_load_module(const char *modname, struct linker_file *parent)
{
    linker_file_t lfdep;
    const char *filename;
    char *pathname;
    int error;
 
    /*
     * There will be a system to look up or guess a file name from
     * a module name.
     * For now we just try to load a file with the same name.
     */
    pathname = linker_search_path(modname);
.....

I don't think it's right to write an API for something that hasn't 
been defined yet.

I'm not saying kmodule_require() doesn't sound like a good idea, just 
that someone's going to have to design & write a module -> filename 
mapping mechanism first (or at the same time).

The linker_search_path() function isn't even a sufficient placeholder 
for that right now -- as Dima has pointed out, modules show up with 
names such as "bus/driver" rather than just "driver", so 
linker_search_path() should be able to take "pci/if_fxp" and turn that 
into "if_fxp" somehow.  That's not as trivial as it sounds (not to me 
anyway - I don't know if/how the module namespace is defined...).

> -- 
> ... every activity meets with opposition, everyone who acts has his
> rivals and unfortunately opponents also.  But not because people want
> to be opponents, rather because the tasks and relationships force
> people to take different points of view.  [Dr. Fritz Todt]
>            V I C T O R Y   N O T   V E N G E A N C E

-- 
Brian <brian@freebsd-services.com>                <brian@Awfulhak.org>
      http://www.freebsd-services.com/        <brian@[uk.]FreeBSD.org>
Don't _EVER_ lose your sense of humour !      <brian@[uk.]OpenBSD.org>



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




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