Hey guys,
I'm currently doing a tutorial for writing kernel modules. Right now I'm still at the very beginning, i.e. writing my helloworld stuff.
But what I like to do now is to write stuff onto the console, and I don't get it. According to my tutorials I can print stuff on the console using the printk()-function as long as the priority-level of the macro used in printk() is lower than the console_loglevel (how can I find that value out btw?).
But it doesn't work for me. Even if I use KERN_EMERG it still gets only logged, but not printed on the console and I thought KERN_EMERG get always printed...
FWIW, here's my code:
Code:
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/init.h>
static int a = 1;
static int b = 2;
module_param(a, int, 0);
module_param(b, int, 0);
static char *mystring = "nix";
module_param(mystring, charp, 0);
static int myStarter(void) {
int c = a + b;
printk(KERN_INFO "hallo welt init!\n");
printk(KERN_EMERG "c = %d\n", c);
return 0;
}
static void goodBye(void) {
int i;
for(i=0; i<b; ++i)
printk(KERN_ALERT "Schleife: %d von %d", i+1, b);
printk(KERN_INFO "dying... o im dying\n");
}
module_init(myStarter);
module_exit(goodBye);
Edit:
As I already posted my code, maybe someone can help me with another problem here:
If I call
Code:
insmod hello a=3 b=6 mystring="somestring"
Everything works fine. But as soon as there are any blanks in mystring, e.g.
Code:
insmod hello a=3 b=6 mystring="some blankish string"
I always get
Code:
insmod: error inserting 'hello.ko': -1 Unknown symbol in module
Why do I get this error and how can I insert string with blanks?