Subject: Re: Bug in ofdev.c of the ofwboot package?
To: Christian M?ller <cmue81@gmx.de>
From: Bill Studenmund <wrstuden@netbsd.org>
List: port-macppc
Date: 11/02/2005 11:35:01
--i9LlY+UWpKt15+FH
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Nov 01, 2005 at 03:45:58AM +0100, Christian M?ller wrote:
> Please forgive me if I'm wrong (and please tell me in that case why it=20
> does work the way it works).
>=20
> Full listing:=20
> http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/macppc/stand/ofwboot/ofd=
ev.c?rev=3D1.15&content-type=3Dtext/x-cvsweb-markup
>=20
> static char *
> filename(char *str, char *ppart)
> {
> [...]
> 	for (cp =3D str; *cp; lp =3D cp) {
> 		/* For each component of the path name... */
> 		while (*++cp && *cp !=3D '/')
> 			;
> 		savec =3D *cp;
> 		*cp =3D 0;
> 		/* ...look whether there is a device with this name */
>=20
> [NEXT LINE: SHOULD IT NOT BE cp INSTEAD OF str?  Why else would you save =
cp=20
> in savec?]

No. cp is a pointer to a character. We save the character that cp points=20
to.

What we're doing is taking a path and figuring out what bits of it are a=20
device and what bits are arguements. We do this by selectively turning '/'=
=20
characters into NULs and seeing if OF agrees that's a device.

So given the boot device /pci/pci-bridge@D/ADPT,2930@3/@5:9,\ofwboot.xcf=20
we try:

/pci
/pci/pci-bridge@D
/pci/pci-bridge@D/ADPT,2930@3
/pci/pci-bridge@D/ADPT,2930@3/@5:9,\ofwboot.xcf

The last one isn't a device, so we hit the dhandle =3D=3D -1 path.

> 		dhandle =3D OF_finddevice(str);
> 		*cp =3D savec;
> [...]
> 	}
> 	return 0;
> }

Take care,

Bill

--i9LlY+UWpKt15+FH
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)

iD8DBQFDaRTlWz+3JHUci9cRAgopAJ4wdH0yFbsqlAU+qTIZiFBPdaCu0QCfb86S
DK5zDCgoFnwnH/gRNRlwrYE=
=Fj8I
-----END PGP SIGNATURE-----

--i9LlY+UWpKt15+FH--