Subject: Re: /dev/null symlink and suse_base
To: Dan McMahill <dmcmahill@NetBSD.org>
From: Quentin Garnier <cube@cubidou.net>
List: tech-pkg
Date: 07/04/2005 14:27:08
--2WS97oupGEGbYNpW
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Mon, Jul 04, 2005 at 02:07:06PM +0200, Quentin Garnier wrote:
> On Mon, Jul 04, 2005 at 07:19:23AM -0400, Dan McMahill wrote:
> > I've run into a compat_linux problem which stems from ${EMULDIR}/dev/nu=
ll
> > being a symlink to /dev/null.
> >=20
> > In the install target in emulators/suse_base/Makefile, this is done wit=
h:
> >=20
> > ${LN} -fs /dev/null ${EMULDIR}/dev/null
> >=20
> > I've seen some linux programs which use realpath() and readlink() on
> > /dev/null. The problem is when looking for /dev/null, compat_linux
> > will look for ${EMULDIR}/dev/null first and the program loops a whole
> > bunch of times until you get an error about too many symlinks.
> >=20
> > I'm wondering if we should instead do something like
> >=20
> > ${CP} -p /dev/MAKEDEV ${EMULDIR}/dev
> > cd ${EMULDIR}/dev && ${SH} ./MAKEDEV std
> >=20
> > or some such thing. I tried just running
> >=20
> > cd /emul/linux/dev && mknod -m 666 -g wheel -u root null c 2 2
> >=20
> > to create a /dev/null in the emulation root which was not a symlink.
> > It seemed to have gotten past the problem I'd been having.
> >=20
> > Does anyone see a problem with changing the suse_base and suse91_base
> > packages to do this? Maybe there is a better fix? Someone had suggest=
ed
> >=20
> > cd /emul/linux/dev && ln -s ../../../dev/null
> >=20
> > but that also failed.
>=20
> It should be "ln -s /../dev/null". The leading "/../" is magic.
Ignore that. I didn't switch the brains on.
But now that I think of it, that's something I should add to my special
namei() function.
Now back to your issue. It is weird. I guess realpath() would
typically the function that fails, reading each component individually.
readlink() is a simple syscall, so there is no risk of it doing
anything wrong, but indeed realpath() is a problem.
I guess your solution is acceptable in the /dev/null case, but the
issue can arise with any symlink of that kind.
--=20
Quentin Garnier - cube@cubidou.net - cube@NetBSD.org
"When I find the controls, I'll go where I like, I'll know where I want
to be, but maybe for now I'll stay right here on a silent sea."
KT Tunstall, Silent Sea, Eye to the Telescope, 2004.
--2WS97oupGEGbYNpW
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (NetBSD)
iQEVAwUBQskrHNgoQloHrPnoAQI6dwf6AwKRcYBBIvf0g/S/C+19aqSkkGTAChXm
HfLUMuo1DYw8qFmbd6C9DEcm/zGKQS9NrqvOtIPbc9qjC6Rj2OELohPQrQqwqmEM
qtsX3SSgyAnOfmH2NzxmEK2XiahBhygrqktpjJCqaZVc+KwkbimFf4rujkFWECOp
CxMLF4p5ZzNJkw0sGehMrakOrnrNkFQKCeDslXj+7N+buVoZKk5s/mtn6JVgYezs
wzEJZI4rS3IeoZf0j914ppOhuMxjxonXwd/94hnVYF3wt5EHDnLc68x4VRJ8uoqA
EaRbWh/jIdNmeKSvYeqwSRbdNoY4UwM1QpyaKlBW5elaKrPY057Fjw==
=E2pr
-----END PGP SIGNATURE-----
--2WS97oupGEGbYNpW--