EINVAL is defined in the header file errno.h
#define EINVAL (_SIGN 22) /* invalid argument */
In header files kernel.h, vfs.h, and pm.h, the macro _SYSTEM is defined (with value 1). Then errno.h is included.
In errno.h, _SIGN is defined so that it can be included by a system process or by a user process:
#ifdef _SYSTEM # define _SIGN - # define OK 0 #else # define _SIGN #endif
So in a system process, EINVAL will be (-22)
In a user process, EINVAL will be (22)