_IOWR when errno != 0

Pawel Jakub Dawidek pjd at FreeBSD.org
Thu Apr 15 06:41:55 UTC 2010


On Mon, Apr 12, 2010 at 03:28:35PM -0700, Xin LI 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;
> ===========

I'd like to note that OpenSolaris does copy data back even if an error
occurs. I needed to change ZFS to return 0 for ioctl(2) and return an
error within zfs_cmd structure.

I think FreeBSD way is better, BTW. ioctl(2) can fail for other reasons,
for example data pointer is invalid, so we return EFAULT and we are
unable to copy data back in that case anyway.

-- 
Pawel Jakub Dawidek                       http://www.wheelsystems.com
pjd at FreeBSD.org                           http://www.FreeBSD.org
FreeBSD committer                         Am I Evil? Yes, I Am!
-------------- 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/20100415/411496f0/attachment.pgp


More information about the freebsd-arch mailing list