Subject: Re: Upgrade of `struct vnd_ioctl'
To: Quentin Garnier <cube@cubidou.net>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 02/14/2007 12:39:58
--wac7ysb48OaltWcw
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Feb 12, 2007 at 09:06:22PM +0100, Quentin Garnier wrote:
> On Mon, Feb 12, 2007 at 07:49:33PM +0000, Christos Zoulas wrote:
> > In article <20070212054652.GA24959@baal.public.ulaval.ca>,
> > Arnaud Lacombe  <arnaud.lacombe.1@ulaval.ca> wrote:
> > >-=3D-=3D-=3D-=3D-=3D-
> > >
> > >On Sun, Feb 11, 2007 at 11:46:39PM +0100, Quentin Garnier wrote:
> > >> On Sun, Feb 11, 2007 at 02:27:22PM -0500, Arnaud Lacombe wrote:
> > >
> > >> > Does the change needs any compatibility layer to be added ?=20
> > >>=20
> > >> The process is quite simple:  keep a copy of the current structure w=
ith
> > >> a different name (e.g., oldvnd_ioctl), and create new ioctl commands
> > >> referencing that structure with the name OXXX.
> > >>=20
> > >> E.g.:
> > >>=20
> > >> #define OVNDIOCSET       _IOWR('F', 0, struct oldvnd_ioctl)
> > >>=20
> > >> Then you add an entry in ioctl handler for those commands that do wh=
at
> > >> they're supposed to do (i.e., in that case convert the value), and p=
ut
> > >> those specific parts under COMPAT_40.
> > >>=20
> > >does the attached patch looks good ?
>=20
> Huh, no.
>=20
> First, you should decide if you want VNDIOOxxx or OVNDIOxxx and make it
> consistent all through the patch.

Indeed.

> Then, with that patch, VNDIOOCSET will not have the intended result...
> And will write 4 extra bytes in memory or fault, depending on some
> factors.
>=20
> What you need to do in the OVNDIOxxx cases is actually *convert* data
> (which points to a struct oldvnd_ioctl) into a struct vnd_ioctl.

Actually, this time I think we can get away with a little type casting=20
magic. As I understand it, we are changing the length of the last field,=20
so we need only adjust how we handle it. Note: I'm also assuming we'll not=
=20
add more components in the future; if we were to, we should make the=20
above-suggested change for conversion.

	vio->vnd_size =3D dbtob(((struct vnd_oioctl *)vnd)->sc_size);

should work for now.

It's clear this patch was never tested on a BE system; the above problem=20
would have been readily apparent. :-)

Take care,

Bill

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

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

iD8DBQFF03OeWz+3JHUci9cRApAJAKCQckhdRE2eE8l6HINdQnPXqa0xSACfdpwQ
Vhh0nzqeP43MUdAhOhqpEdU=
=sYhH
-----END PGP SIGNATURE-----

--wac7ysb48OaltWcw--