tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: ioctl() and driver function d_ioctl return values
On Mon, May 19, 2025 at 05:12:37PM +0200, Beesdeckar wrote:
> Hello,
>
> I am calling ioctl() with control code created with __IOWR() macro and third
> argument contains address of user-mode structure.
> When module's d_ioctl() returns non-zero value then user-mode ioctl()
> returns always -1 and structure in user mode does not contain data filled by
> module.
>
> Are both above things by design ?
Yes, see src/sys/kern/sys_generic.c line 677ff:
/*
* Copy any data to user, size was
* already set and checked above.
*/
if (error == 0 && (com&IOC_OUT) && size) {
error = copyout(data, SCARG(uap, data),
zero_size(size));
ktrgenio(SCARG(uap, fd), UIO_READ, SCARG(uap, data),
size, error);
}
Only if the ioctl() succeeds (errror == 0) the copyout of the output structure
is done.
Martin
Home |
Main Index |
Thread Index |
Old Index