Is there an equvalent for perror in the kernel?

Go To


What would perror() be in the kernel? I can't tell what the error codes are from the error values ,i.e -22 alone.

2012-04-04 06:38
by Dr.Knowitall


The Linux kernel just uses negated errno codes as a convention. So look in asm-generic/errno-base.h or asm-generic/errno.h and find...

#define EINVAL          22      /* Invalid argument */

This can happen if you pass NULL to a function that doesn't accept NULL, for example. It depends on the function.

2012-04-04 06:44
by Dietrich Epp
the question was about using perror(), not about the meaning of the error codes. So this is not a good answer - user3629249 2017-06-07 14:40
@user3629249: This question not actually about using perror, but it's about how to interpret error codes in the kernel. The perror function is only available in userspace, it's not available in the kernel - Dietrich Epp 2017-06-07 19:18