From owner-cvs-src@FreeBSD.ORG Sat Feb 18 17:35:46 2006 Return-Path: X-Original-To: cvs-src@FreeBSD.org Delivered-To: cvs-src@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 052D916A429; Sat, 18 Feb 2006 17:35:46 +0000 (GMT) (envelope-from pjd@garage.freebsd.pl) Received: from mail.garage.freebsd.pl (arm132.internetdsl.tpnet.pl [83.17.198.132]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4DF3043D46; Sat, 18 Feb 2006 17:35:45 +0000 (GMT) (envelope-from pjd@garage.freebsd.pl) Received: by mail.garage.freebsd.pl (Postfix, from userid 65534) id 5506E50B91; Sat, 18 Feb 2006 18:35:43 +0100 (CET) Received: from localhost (dlm157.neoplus.adsl.tpnet.pl [83.24.42.157]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.garage.freebsd.pl (Postfix) with ESMTP id 2646551688; Sat, 18 Feb 2006 18:35:38 +0100 (CET) Date: Sat, 18 Feb 2006 18:35:26 +0100 From: Pawel Jakub Dawidek To: Dag-Erling Sm?rgrav Message-ID: <20060218173526.GC849@garage.freebsd.pl> References: <200602181125.k1IBPSBu021102@repoman.freebsd.org> <20060218114331.GA849@garage.freebsd.pl> <86accor6wh.fsf@xps.des.no> <20060218172241.GB849@garage.freebsd.pl> <8664ncr2zz.fsf@xps.des.no> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="w7PDEPdKQumQfZlR" Content-Disposition: inline In-Reply-To: <8664ncr2zz.fsf@xps.des.no> X-PGP-Key-URL: http://people.freebsd.org/~pjd/pjd.asc X-OS: FreeBSD 7.0-CURRENT i386 User-Agent: mutt-ng/devel-r535 (FreeBSD) X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on mail.garage.freebsd.pl X-Spam-Level: X-Spam-Status: No, score=-0.5 required=3.0 tests=BAYES_00,RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL autolearn=no version=3.0.4 Cc: cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/lib/libutil Makefile kld.3 kld.c libutil.h X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Feb 2006 17:35:46 -0000 --w7PDEPdKQumQfZlR Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Feb 18, 2006 at 06:27:44PM +0100, Dag-Erling Sm?rgrav wrote: +> Pawel Jakub Dawidek writes: +> > It doesn't change your API, just extends it. With this change I'll be +> > able to use this functions in geom(8) without wrappers around them. +> > And this is the whole point of having them, right? +>=20 +> Please tell me what semantics you want instead of expecting me to read +> your mind. There are some cases where you cannot decide which module to load, because it is provided at run-time. In geom(8) I've something like this currently: static void load_module(void) { char name1[64], name2[64]; =20 snprintf(name1, sizeof(name1), "g_%s", class_name); snprintf(name2, sizeof(name2), "geom_%s", class_name); if (modfind(name1) < 0) { /* Not present in kernel, try loading it. */ if (kldload(name2) < 0 || modfind(name1) < 0) { if (errno !=3D EEXIST) { errx(EXIT_FAILURE, "%s module not available!", name2); } } } } Changing it to the version below doesn't really buy me anything: static void load_module(void) { char name1[64], name2[64]; =20 snprintf(name1, sizeof(name1), "g_%s", class_name); snprintf(name2, sizeof(name2), "geom_%s", class_name); if (!kld_isloaded(name1) && kld_load(name2) =3D=3D -1) err(1, "failed to load %s module", name2); } But changing it to the code below, or removing load_module entirely looks like improvement: static void load_module(void) { if (!kld_isloaded("g_%s", class_name) && kld_load("geom_%s", class_name) =3D=3D -1) { err(1, "failed to load geom_%s module", class_name); } } Yet another option is to reimplement kld_load(3) to: kld_load(const char *modname, const char *kldname); (and eventually remove kld_isloaded(3)). --=20 Pawel Jakub Dawidek http://www.wheel.pl pjd@FreeBSD.org http://www.FreeBSD.org FreeBSD committer Am I Evil? Yes, I Am! --w7PDEPdKQumQfZlR Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (FreeBSD) iD8DBQFD91reForvXbEpPzQRAhjKAJ0dGx17niyMFqZ1OXs/2BzhC/bnHwCgnAyP 7bbTsePqM0P2+POsYYp3Odc= =xVtF -----END PGP SIGNATURE----- --w7PDEPdKQumQfZlR--