From owner-freebsd-arch Sun Aug 5 9: 6:10 2001 Delivered-To: freebsd-arch@freebsd.org Received: from bazooka.unixfreak.org (bazooka.unixfreak.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id 11D5E37B405 for ; Sun, 5 Aug 2001 09:06:07 -0700 (PDT) (envelope-from dima@unixfreak.org) Received: by bazooka.unixfreak.org (Postfix, from userid 1000) id C985F3E35; Sun, 5 Aug 2001 09:06:06 -0700 (PDT) Received: from bazooka.unixfreak.org (localhost [127.0.0.1]) by bazooka.unixfreak.org (Postfix) with ESMTP id BE9B43C12E; Sun, 5 Aug 2001 09:06:06 -0700 (PDT) To: Brian Somers Cc: arch@FreeBSD.ORG, brian@freebsd-services.com Subject: Re: Library routine to load a kld if it already isn't In-Reply-To: <200108051412.f75ECwu42771@hak.lan.Awfulhak.org>; from brian@Awfulhak.org on "Sun, 05 Aug 2001 15:12:58 +0100" Date: Sun, 05 Aug 2001 09:06:01 -0700 From: Dima Dorfman Message-Id: <20010805160606.C985F3E35@bazooka.unixfreak.org> 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 Brian Somers 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. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message