freebsd32_ioctl.c
Kostik Belousov
kostikbel at gmail.com
Thu Oct 7 16:13:44 UTC 2010
On Thu, Oct 07, 2010 at 09:05:49AM -0700, mdf at 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))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20101007/66758530/attachment.pgp
More information about the freebsd-arch
mailing list