public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Robert P. J. Day" <rpjday@crashcourse.ca>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: weekly column and a question about module_init() error codes
Date: Sat, 4 Jul 2009 12:33:48 -0400 (EDT)	[thread overview]
Message-ID: <alpine.LFD.2.00.0907041221330.2912@localhost> (raw)


  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
========================================================================

                 reply	other threads:[~2009-07-04 16:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.00.0907041221330.2912@localhost \
    --to=rpjday@crashcourse.ca \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox