Re: 2.6 kernel module programming guide

From: iamnilo (alain_mosnier_at_yahoo.com)
Date: 09/15/04


Date: Wed, 15 Sep 2004 16:38:12 +0200

init_module wrote:

> I was lookireferredlinux doc project site and found this kernel
> module programming guide. (the one for the 2.6 kernel)
>
> In section 2.6 of the doc "passing command line args to modules", I
> get confused at the output of the module. The output shows it say
> something like "myintArray is -1 to 420". But I don't see anywhere in
> the source that would do this.
>
> Is this doc just incomplete or am I missing something here?
> Also what is the point of passing command line args to modules??

Hello,

I'm going through that book myself.

I just want to say that the code referred to in the original message from
init_module can be tested as is, although not with the examples given by
the author. It looks like the variable names and types got mixed up between
the code and the examples.

My tests went as follows:

Cheers,

Nilo

host:/prog # insmod hello-5.ko
mystring="bebop" myint=255

host:/prog # rmmod hello-5

host:/prog # cat /var/log/messages | tail
| more

Sep 15 16:07:32 host kernel: Hello, world 5
Sep 15 16:07:32 host kernel: =============
Sep 15 16:07:32 host kernel: myshort is a short
integer: 1
Sep 15 16:07:32 host kernel: myint is an integer: 255
Sep 15 16:07:32 host kernel: mylong is a long
integer: 9999
Sep 15 16:07:32 host kernel: mystring is a string:
bebop
Sep 15 16:09:29 host kernel: Goodbye, world 5

host:/prog # insmod hello-5.o
mystring="supercalifragilisticexpialidocious"

host:/prog # rmmod hello-5

host:/prog # cat /var/log/messages | tail
| more

Sep 15 16:11:29 host kernel: Hello, world 5
Sep 15 16:11:29 host kernel: =============
Sep 15 16:11:29 host kernel: myshort is a short
integer: 1
Sep 15 16:11:29 host kernel: myint is an integer: 420
Sep 15 16:11:29 host kernel: mylong is a long
integer: 9999
Sep 15 16:11:29 host kernel: mystring is a string:
supercal
ifragilisticexpialidocious
Sep 15 16:11:33 host kernel: Goodbye, world 5

host:/prog # insmod hello-5.o
mystring="supercalifragilisticexpialidocious" myint=256

host:/prog # rmmod hello-5

host:/prog # cat /var/log/messages | tail
| more

Sep 15 16:13:23 host kernel: Hello, world 5
Sep 15 16:13:23 host kernel: =============
Sep 15 16:13:23 host kernel: myshort is a short
integer: 1
Sep 15 16:13:23 host kernel: myint is an integer: 256
Sep 15 16:13:23 host kernel: mylong is a long
integer: 9999
Sep 15 16:13:23 host kernel: mystring is a string:
supercal
ifragilisticexpialidocious
Sep 15 16:13:27 host kernel: Goodbye, world 5

host:/prog # insmod hello-5.o mylong=hello
insmod: error inserting 'hello-5.o': -1 Invalid parameters

host:/prog # insmod hello-5.o mylong=2456

host:/prog # rmmod hello-5

host:/prog # cat /var/log/messages | tail
| more

Sep 15 16:14:41 host kernel: hello_5: no version
magic, tai
nting kernel.
Sep 15 16:14:41 host kernel: hello_5: `hello' invalid
for p
arameter `mylong'
Sep 15 16:15:12 host kernel: hello_5: no version
magic, tai
nting kernel.
Sep 15 16:15:12 host kernel: Hello, world 5
Sep 15 16:15:12 host kernel: =============
Sep 15 16:15:12 host kernel: myshort is a short
integer: 1
Sep 15 16:15:12 host kernel: myint is an integer: 420
Sep 15 16:15:12 host kernel: mylong is a long
integer: 2456
Sep 15 16:15:12 host kernel: mystring is a string:
blah
Sep 15 16:15:15 host kernel: Goodbye, world 5

-- 
i am nilo