* weekly column and a question about module_init() error codes
@ 2009-07-04 16:33 Robert P. J. Day
0 siblings, 0 replies; only message in thread
From: Robert P. J. Day @ 2009-07-04 16:33 UTC (permalink / raw)
To: Linux Kernel Mailing List
in a spate of self-promotion that probably has little interest for
members of *this* list, i'm now writing a weekly column for linux.com
for kernel newbies, first two pieces here:
http://cli.gs/8WMgM9
http://cli.gs/Zd2MuG
yes, i know it's trivial stuff but look at it this way -- if i can
explain it properly, then they won't be bugging *you* with those
questions. :-)
and regarding return codes from module_init() routines, i realize
that you need to return zero to represent success so that the module
is loaded but, if anything goes wrong, you should return a negative
value corresponding to some value out of
include/asm-generic/errno-base.h:
#define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No such file or directory */
#define ESRCH 3 /* No such process */
#define EINTR 4 /* Interrupted system call */
#define EIO 5 /* I/O error */
... snip ...
however, based on some tests i ran, regardless of what error code i
return, a manual "insmod" always returns a shell error code ($?) of 1.
the message *printed* will correspond to the actual error value
returned, such as returning -EIO printing:
# insmod hi.ko
insmod: error inserting 'hi.ko': -1 Input/output error
#
i'm assuming that, if i'm running insmod as part of a script and can
check only the return code, all i'm going to get is 0 or 1 (success or
fail), and there's no way to extract the actual value. (i could
capture the error string printed, but that's a bit of a pain --
getting the numeric value would be so much easier.)
or am i missing something painfully obvious? thanks.
rday
--
========================================================================
Robert P. J. Day Waterloo, Ontario, CANADA
Linux Consulting, Training and Annoying Kernel Pedantry.
Web page: http://crashcourse.ca
Linked In: http://www.linkedin.com/in/rpjday
Twitter: http://twitter.com/rpjday
========================================================================
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-07-04 16:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-04 16:33 weekly column and a question about module_init() error codes Robert P. J. Day
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.