lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <alpine.LFD.2.00.0907041221330.2912@localhost>
Date:	Sat, 4 Jul 2009 12:33:48 -0400 (EDT)
From:	"Robert P. J. Day" <rpjday@...shcourse.ca>
To:	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: weekly column and a question about module_init() error codes


  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
========================================================================
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ