Date: Thu, 7 Oct 2010 19:13:38 +0300 From: Kostik Belousov <kostikbel@gmail.com> To: mdf@freebsd.org Cc: FreeBSD Arch <freebsd-arch@freebsd.org> Subject: Re: freebsd32_ioctl.c Message-ID: <20101007161338.GK2392@deviant.kiev.zoral.com.ua> In-Reply-To: <AANLkTinYascWzAn8dWMsKaDqcD0WuMr40=SJ_KX3Dfn0@mail.gmail.com> References: <AANLkTinYascWzAn8dWMsKaDqcD0WuMr40=SJ_KX3Dfn0@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On Thu, Oct 07, 2010 at 09:05:49AM -0700, mdf@freebsd.org wrote:
> I added some more ioctls to those translated by freebsd32_ioctl in my
> local tree, and then I started thinking. If we support all the
> various drivers as loadable modules, but the ioctl translation is in
> the base kernel, that's a lot of code to have for COMPAT_IA32 that may
> never get run. It would be nice to keep the ioctl argument munging in
> the driver, but while it's not hard to check in the driver's ioctl
> function if p_sysent is freebsd32_sysent, the code isn't as clean as a
> passthrough function like freebsd32_ioctl().
>
> So I was wondering if that would be considered an issue. Should we
> just be adding ioctl argument munging as we go along and not worry
> about the size? Or is there simple way to keep the munging inside the
> driver? Perhaps my making the driver's ioctl look something like:
I think that in-driver variant is the best.
>
> #ifdef COMPAT_IA32
> static int
> xxx_ioctl32(struct cdev *dev, u_long com32, caddr_t arg, int flag,
> struct thread *td)
> {
> struct xxx_32 *cmd32 = (void *)arg;
> struct xxx cmd;
> u_long com;
> int error;
>
> CP(*cmd32, cmd, field1);
> /* ... */
> error = xxx_ioctl(dev, com, &cmd, flag, td);
> if (error == 0 && (com & IOC_OUT) != 0) {
> CP(cmd, *cmd32, field1);
> /* ... */
> }
> return (error);
> }
> #endif /* COMPAT_IA32 */
>
> static int
> xxx_ioctl_devsw(struct cdev *dev, u_long com, caddr_t arg, int flag,
> struct thread *td)
> {
> #ifdef COMPAT_IA32
> if (td->td_proc->p_sysent == &ia32_freebsd_sysvec)
> return (xxx_ioctl32(dev, com, arg, flag, td));
> #endif
> return (xxx_ioctl(dev, com, arg, flag, td);
> }
>
> ... and the check for p_sysent == &ia32_freebsd_sysvec should probably
> be a more-correct macro.
if (SV_CURPROC_FLAG(SV_ILP32))
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (FreeBSD)
iEYEARECAAYFAkyt8bEACgkQC3+MBN1Mb4gU0ACeOIZs5hjj+7kK5TwHQrYNAaG/
GMoAoJ7qeI2y9KGHOClUMBopyo93ImrC
=mL3O
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20101007161338.GK2392>
