LdB wrote: ↑
Tue Feb 04, 2020 1:43 pm
Incorrect the kernel prints that error when you try to IOControl a none existent device ... his code is being executed and that is the error message the kernel spits to the console which is by default STDERR output.
No, that is not how Linux works at all. The kernel never writes to stderr except when userspace does write(2, …), etc.
If a system call fails, Linux returns a negative error number such as -EREMOTEIO. The C library copies the positive version of the error code into the current thread's errno variable and returns -1, because that is the calling convention.
No error message will ever be printed unless the user code does something to consult errno and look up the translated message according to the current locale. The code in the OP never does that, so it cannot print "Remote I/O error".
Since we never see the intended message "Error: Couldn't find device on address!" either, we know that the ioctl() is in fact succeeding. That makes sense, because this particular request cannot fail with EREMOTEIO; it can only fail with EBUSY or EINVAL.
It is a different or subsequent, unposted piece of code that is actually failing, and does have a call to perror(), but with an empty message; hence the leading colon-space on the error. We need to call perror() after every failed system call, and to include a sufficient message to make it clear where we are.
Of course you are quite correct about the meaning of the Remote I/O error, but you had already addressed that.