Date: Wed, 21 Jun 2006 17:23:49 +0100 From: Florent Thoumie <flz@FreeBSD.org> To: Yar Tikhiy <yar@comp.chem.msu.su> 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 Message-ID: <1150907029.3467.49.camel@mayday.esat.net> In-Reply-To: <20060621122331.GI45947@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> <1150890968.3467.39.camel@mayday.esat.net> <20060621122331.GI45947@comp.chem.msu.su>
next in thread | previous in thread | raw e-mail | index | archive | help
--=-6qm72DJR54IufmcWnBTj Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Wed, 2006-06-21 at 16:23 +0400, Yar Tikhiy wrote: > On Wed, Jun 21, 2006 at 12:56:08PM +0100, Florent Thoumie wrote: > > 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. = Many > > > > > > > of them do that conditionally depending on kldstat. The co= de is > > > > > > > duplicated all over, but bugs can be uniqie. > > > > > > > =20 > > > > > > > To make the things more consistent, introduce a new rc.subr= function, > > > > > > > load_kld, which takes care of loading a kernel module condi= tionally. > > > > > > > =20 > > > > > > > (Found this lying for a while in my p4 branch for various h= acks.) > > > > > >=20 > > > > > > I added such a function some weeks ago (far more simple though)= . Talking > > > > > > with pjd, I've backed it out to use the somewhat straight-forwa= rd method > > > > > > 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. > >=20 > > Removing all scripts using 'kldstat -q -m foo', we have: >=20 > Why should we omit them from our consideration? The scripts now > doing 'kldstat -q -m foo' can benefit from my function, too, because > they should do error checking and reporting, the error-handling > code being duplicated inconsistently: some of them warn on error, > others print a message on success and so on. The long line (or its > multi-line equivalent): >=20 > kldstat -q -m foo || kldload foo >/dev/null 2>&1 || echo "Damn! Failed t= o kldload foo :-(" >=20 > becomes just: >=20 > load_kld foo >=20 > Note that egrep is not used to process such a request in load_kld. >=20 > > $ grep kldstat * | grep -v -- "-q -m" | cut -d':' -f1 | sort -u > > abi > > archdep > > atm1 > > ipfilter > > syscons > >=20 > > archdep, atm1 and ipfilter could use this 'kldstat -q -m foo' method, s= o > > that's only two candidates. Most scripts calling kldload without kldsta= t > > first could use this method as well. > >=20 > > But ok, those are definitely scripts I do not read very often. > > > > > > You won't gain anything using grep instead of egrep since they're b= oth > > > > in /usr/bin. > > >=20 > > > Have I ever tried to? > >=20 > > 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 > I meant -e to my function, not to grep. That is, if one doesn't > specify -e to load_kld, it won't try to invoke egrep at all. (FWIW, > grep and egrep are links to the same binary. And grep -e is not > the same as grep -E ;-) >=20 > Without a "-e regex" option, load_kld will just do kldstat. Therefore, > load_kld won't break scripts that aren't broken yet by using grep > or egrep too early in the boot sequence. Makes sense. > BTW, grep can be emulated with /bin/expr if needed: >=20 > _grep() > { > while read _line; do > [ `expr "$_line" : ".*$1"` !=3D 0 ] && echo "$_line" > done > } >=20 > Ditto for "grep -q". I guess we can even just use shell pattern matching with 'case'. --=20 Florent Thoumie flz@FreeBSD.org FreeBSD Committer --=-6qm72DJR54IufmcWnBTj 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) iD8DBQBEmXKVMxEkbVFH3PQRAkTrAJ9IoMAnKjI+vKAYFcnsh1sDurChKgCffEMO W90DtYSG1g6FH6DXI3okXZk= =Z2Ru -----END PGP SIGNATURE----- --=-6qm72DJR54IufmcWnBTj--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1150907029.3467.49.camel>