From owner-cvs-src@FreeBSD.ORG Wed Jun 21 11:56:24 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 1897616A479; Wed, 21 Jun 2006 11:56:24 +0000 (UTC) (envelope-from flz@FreeBSD.org) Received: from smtp4-g19.free.fr (smtp4-g19.free.fr [212.27.42.30]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5EA8B43D46; Wed, 21 Jun 2006 11:56:22 +0000 (GMT) (envelope-from flz@FreeBSD.org) Received: from smtp.xbsd.org (xbsd.org [82.233.2.192]) by smtp4-g19.free.fr (Postfix) with ESMTP id 6B9B75497C; Wed, 21 Jun 2006 13:56:21 +0200 (CEST) Received: from localhost (localhost.xbsd.org [127.0.0.1]) by smtp.xbsd.org (Postfix) with ESMTP id CA5D01169F; Wed, 21 Jun 2006 13:56:20 +0200 (CEST) Received: from smtp.xbsd.org ([127.0.0.1]) by localhost (srv1.xbsd.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 80037-10; Wed, 21 Jun 2006 13:56:10 +0200 (CEST) Received: from mayday.esat.net (mayday.esat.net [193.95.134.156]) by smtp.xbsd.org (Postfix) with ESMTP id C834C11472; Wed, 21 Jun 2006 13:56:09 +0200 (CEST) From: Florent Thoumie To: Yar Tikhiy In-Reply-To: <20060621113901.GG45947@comp.chem.msu.su> References: <200606210942.k5L9gtAi060504@repoman.freebsd.org> <1150883785.3467.4.camel@mayday.esat.net> <20060621105253.GE45947@comp.chem.msu.su> <1150887909.3467.18.camel@mayday.esat.net> <20060621113901.GG45947@comp.chem.msu.su> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-sDxB763PUYMVFRprHiJA" Date: Wed, 21 Jun 2006 12:56:08 +0100 Message-Id: <1150890968.3467.39.camel@mayday.esat.net> Mime-Version: 1.0 X-Mailer: Evolution 2.6.2 FreeBSD GNOME Team Port X-Virus-Scanned: amavisd-new at xbsd.org Cc: cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/etc rc.subr src/share/man/man8 rc.subr.8 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: Wed, 21 Jun 2006 11:56:24 -0000 --=-sDxB763PUYMVFRprHiJA Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Wed, 2006-06-21 at 15:39 +0400, Yar Tikhiy wrote: > On Wed, Jun 21, 2006 at 12:05:09PM +0100, Florent Thoumie wrote: > > On Wed, 2006-06-21 at 14:52 +0400, Yar Tikhiy wrote: > > > On Wed, Jun 21, 2006 at 10:56:25AM +0100, Florent Thoumie wrote: > > > > On Wed, 2006-06-21 at 09:42 +0000, Yar Tikhiy wrote: > > > > > yar 2006-06-21 09:42:55 UTC > > > > >=20 > > > > > FreeBSD src repository > > > > >=20 > > > > > Modified files: > > > > > etc rc.subr=20 > > > > > share/man/man8 rc.subr.8=20 > > > > > Log: > > > > > Quite a number of rc.d scripts try to load kernel modules. Man= y > > > > > of them do that conditionally depending on kldstat. The code i= s > > > > > duplicated all over, but bugs can be uniqie. > > > > > =20 > > > > > To make the things more consistent, introduce a new rc.subr fun= ction, > > > > > load_kld, which takes care of loading a kernel module condition= ally. > > > > > =20 > > > > > (Found this lying for a while in my p4 branch for various hacks= .) > > > >=20 > > > > I added such a function some weeks ago (far more simple though). Ta= lking > > > > with pjd, I've backed it out to use the somewhat straight-forward m= ethod > > > > he used in rc.d/geli. > > >=20 > > > rc.d/geli doesn't use kldload directlty, so it certainly won't > > > benefit from the function I introduced. > >=20 > > Then I'm not sure what script would benefit from this function. Can you > > point me to an example? >=20 > abi > archdep > atm1 > hcsecd > ipfilter > mdconfig > mdconfig2 > pf > pflog > pfsync > sdpd > syscons >=20 > They all do kldstat then kldload. Some of them do grep or egrep > on kldstat output. Some of them don't forget to check status from > kldload and emit a error message on failure. Besides, there are > scripts that forget to do kldstat in the first place, they just do > kldload. Now all this ado can become just a call to my function. Removing all scripts using 'kldstat -q -m foo', we have: $ grep kldstat * | grep -v -- "-q -m" | cut -d':' -f1 | sort -u abi archdep atm1 ipfilter syscons archdep, atm1 and ipfilter could use this 'kldstat -q -m foo' method, so that's only two candidates. Most scripts calling kldload without kldstat first could use this method as well. But ok, those are definitely scripts I do not read very often. > > > > I don't have a particular feeling against your function but it uses > > > > commands that may not be available early enough (getopt, egrep). Wh= ile > > > > it's easy to remove the getopt dependency (see rc.d/mdconfig), it's= not > > > > the case for egrep. > > >=20 > > > It's POSIX getopts, which ought to be a shell built-it by its design. > > > egrep is used with -e only, one can avoid using it if egrep isn't > > > available yet. The only issue is true and false, I was sure they > > > were in /bin, but it can be fixed easily. >=20 > As I've just found, we have true and false as undocumented sh(1) > builtins from the beginning of times. So using true and false is > no issue in rc.subr either. >=20 > > Still, with /bin/sh, getopt isn't a builtin: > >=20 > > $ sh -c 'which getopt' > > /usr/bin/getopt >=20 > You still mistake my words. It's getopts, not getopt. See sh(1). Yes, indeed, missed the 's'. > > You won't gain anything using grep instead of egrep since they're both > > in /usr/bin. >=20 > Have I ever tried to? I guessed that's what you meant saying "grep is used with -e only, one can avoid using it if egrep isn't available yet." What are you planning to do then? --=20 Florent Thoumie flz@FreeBSD.org FreeBSD Committer --=-sDxB763PUYMVFRprHiJA Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (FreeBSD) iD8DBQBEmTPYMxEkbVFH3PQRAlhWAJ93QkgIgVE8COx/Ssmnqpgf/q/LHQCfRydw S9k2SjYrHJ5BSC/ZKBO94Pc= =UBmg -----END PGP SIGNATURE----- --=-sDxB763PUYMVFRprHiJA--