Date: Sun, 05 Aug 2001 18:46:14 +0100 From: Brian Somers <brian@Awfulhak.org> To: Dima Dorfman <dima@unixfreak.org> Cc: 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: <200108051746.f75HkEu45187@hak.lan.Awfulhak.org> In-Reply-To: Message from Dima Dorfman <dima@unixfreak.org> of "Sun, 05 Aug 2001 09:24:09 PDT." <20010805162414.225003E35@bazooka.unixfreak.org>
next in thread | previous in thread | raw e-mail | index | archive | help
> Brian Somers <brian@Awfulhak.org> writes:
> > > Brian Somers <brian@Awfulhak.org> writes:
> > > > > Programs that control a certain driver or set of drivers (e.g.,
> > > > > ifconfig, ccdconfig, mdconfig) attempt to load the module they'll be
> > > > > working with if it isn't already present. They do it in different
> > > > > ways, and the most correct way (i.e., the one that handles the most
> > > > > cases properly) is liable to change if the kld subsystem ever changes.
> > > > > I propose to add a library routine, kldmaybeload(3), that will check
> > > > > if a certain module is present in the kernel, and load it if it isn't.
> > > > > This will cut down on duplicated code, and may save some headaches
> > > > > later if the kld interface changes.
> > > > >
> > > > > 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
> > > to their name, such as "pci/if_fxp", and modfind() won't find them
> > > unless you give the full name. If it were just the simpler cases as
> > > above, I probably wouldn't propose this; it's them more complex cases
> > > where this would help.
> >
> > Hmm, what's the reasoning behind this. Is one of these an miibus
> > based fxp and the other not ? If so, is the plan to deprecate one ?
> > I find this bizarre - there's no trace of anything about this in
> > NOTES or fxp(4).
>
> This isn't fxp-specific, I just used fxp as an example. Do a "kldstat
> -v" and you'll see a lot of other drivers with bus names in front.
> Here's a small exerpt:
>
> 78 nexus/npx
> 79 isa/npxisa
> 80 nexus/pcib
> 81 pci/hostb
> 82 isa/pcibus_pnp
> 83 atkbdc/atkbd
>
>
> > Nonetheless, shouldn't modfind() be made capable of doing it's job
> > properly (finding "pci/if_fxp" if that's what's really required) ?
>
> Well, no, because the module name really is "pci/if_fxp". The reason
> you can use kldload("if_fxp"); is because the filename is if_fxp.ko.
So maybe the code should be reduced to
if (ID0kldload("if_fxp") == -1 && errno != EEXIST)
errx();
until someone eventually decides how the module -> name mapping
is actually going to work ?
I don't think a userland api is a good idea for something that's
unfinished in the kernel.
--
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?200108051746.f75HkEu45187>
