_IOWR when errno != 0

Alfred Perlstein alfred at freebsd.org
Mon Apr 12 23:49:23 UTC 2010


* Xin LI <delphij at delphij.net> [100412 15:28] wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi,
> 
> Is there a sane way to copyout ioctl request when the returning errno !=
> 0?  Looking at the code, currently, in sys/kern/sys_generic.c, we have:
> 
> ===========
>         error = kern_ioctl(td, uap->fd, com, data);
> 
>         if (error == 0 && (com & IOC_OUT))
>                 error = copyout(data, uap->data, (u_int)size);
> ===========
> 
> Is there any objection if I change it to something like:
> 
> ===========
>         saved_error = kern_ioctl(td, uap->fd, com, data);
> 
>         if (com & IOC_OUT)
>                 error = copyout(data, uap->data, (u_int)size);
>         if (saved_error)
>                 error = saved_error;
> ===========

Is this for linux compat?

I'm not sure this would work, it might seriously break userland
compat.  Have you looked around/queiried what the expected outcome
is from a bad ioctl?  By default the buffer will be zero'd this
might be unexpected by apps.  (all or nothing)

-- 
- Alfred Perlstein
.- AMA, VMOA #5191, 03 vmax, 92 gs500, 85 ch250
.- FreeBSD committer


More information about the freebsd-arch mailing list