Subject: Re: fstat() and cloned devices
To: None <tech-kern@NetBSD.org>
From: Quentin Garnier <cube@cubidou.net>
List: tech-kern
Date: 10/07/2007 19:02:37
--VkCVF37ElD4C4GZ7
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sun, Oct 07, 2007 at 04:56:20PM +0200, Klaus Heinz wrote:
> Hi,
>=20
> qemu does the following in vl.c:
>=20
>   fd =3D open("/dev/tap", O_RDWR);
>   ...
>   fstat(fd, &s);
>   ...
>   dev =3D devname(s.st_rdev, S_IFCHR);
>=20
> This fails on NetBSD 3 because fstat() returns -1 and most (all?)
> members of struct stat are set to 0.
>=20
> I have two questions:
>=20
> - How can I get the name of the cloned interface (tap1, tap2, ...)?

ioctl(TAPGIFNAME)

> - Can anyone please check whether there are any other undocumented
>   errno values for fstat? If fstat() returns -1 errno is set to 45
>   (EOPNOTSUPP) which is not listed on the man page for fstat().

The handler for /dev/tap uses fbadop_stat, which returns EOPNOTSUPP.

--=20
Quentin Garnier - cube@cubidou.net - cube@NetBSD.org
"See the look on my face from staying too long in one place
[...] every time the morning breaks I know I'm closer to falling"
KT Tunstall, Saving My Face, Drastic Fantastic, 2007.

--VkCVF37ElD4C4GZ7
Content-Type: application/pgp-signature
Content-Disposition: inline

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

iQEVAwUBRwkRLdgoQloHrPnoAQLB9wgAu/cf9yRgtCNq13e15328h/fGsdiA6Con
kNJ/pRB0bOAcrQBfoj+dj2463rbihIBhT3R0mx+FMiB6XYcmgPM6OvViyi7pP7iN
oItCSelPK6BFTA5EqIr5R9RsveyNAXGU5xwekjjhvuohLx65xf82YajpGGhFZQgk
I8BdY28mDt42COxvL1bYeytr7UEHGlhBVJtjKbXHwitV5Y2axt1fIRrmCMyAHra+
5QAmsXVQDKT/AnKQazMOwKhHKWuNVXsOVKdnvYo3OCkkGKcv+lRjjHGEok8AGsIK
kKyWRJujR4Lnjo0s9Jy2xGvW99MicCgBkNsucxkaRcIT2pEcjdf8mg==
=sN27
-----END PGP SIGNATURE-----

--VkCVF37ElD4C4GZ7--