I'm writing a kernel module that communicates with a user application via ioctl
. The communication is one-way only - that is, under normal circumstances no output is required. My question is - how should I report errors to the user application?
For example, my module accepts a process ID as an input. Let's say the PID is invalid. I've found no matching error code in errno.h
, so I need an alternative way of reporting this. I can think of several ways:
- Define a (positive) constant
INVALID_PID
in a common header file, return-INVALID_PID
as the return value of theioctl
call, and handle it in the user application - Print a meaningful message to the kernel log and return a generic error code
- The
ioctl
receives an argument from the user application - I can store the error message there - Establish some two-way communication with the user application
What is the standard way of doing this?
Thanks!