From owner-freebsd-arch Sun Aug 5 16:25:20 2001 Delivered-To: freebsd-arch@freebsd.org Received: from Awfulhak.org (gw.Awfulhak.org [217.204.245.18]) by hub.freebsd.org (Postfix) with ESMTP id 11D0F37B405; Sun, 5 Aug 2001 16:25:14 -0700 (PDT) (envelope-from brian@Awfulhak.org) Received: from hak.lan.Awfulhak.org (root@hak.lan.Awfulhak.org [172.16.0.12]) by Awfulhak.org (8.11.4/8.11.4) with ESMTP id f75NOfj02490; Mon, 6 Aug 2001 00:25:01 +0100 (BST) (envelope-from brian@lan.Awfulhak.org) Received: from hak.lan.Awfulhak.org (brian@localhost [127.0.0.1]) by hak.lan.Awfulhak.org (8.11.4/8.11.4) with ESMTP id f75NOeu49363; Mon, 6 Aug 2001 00:24:40 +0100 (BST) (envelope-from brian@hak.lan.Awfulhak.org) Message-Id: <200108052324.f75NOeu49363@hak.lan.Awfulhak.org> X-Mailer: exmh version 2.5 07/13/2001 with nmh-1.0.4 To: Mike Smith Cc: Dima Dorfman , Brian Somers , arch@FreeBSD.ORG, brian@freebsd-services.com, brian@freebsd-services.com Subject: Re: Library routine to load a kld if it already isn't In-Reply-To: Message from Mike Smith of "Sun, 05 Aug 2001 15:22:45 PDT." <200108052222.f75MMj100826@mass.dis.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 06 Aug 2001 00:24:40 +0100 From: Brian Somers Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > > > > 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 http://www.freebsd-services.com/ Don't _EVER_ lose your sense of humour ! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message