error in module_param_string.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am trying out 2.6.9
wrote a module and used module_param_string for passing string values
into kernel. I can pass params into kernel. But could not really
understand the function module_param_string. I checked the
include/linux/moduleparams.h. What I understand is that the "string
value" (in the below code) will be copied to the defcharray. But I am
unable to print that array.

#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
/* this is required for module parameter passing */
#include <linux/moduleparam.h>

static char *defstring = NULL;
module_param (defstring, charp, 0);
static char defcharray[32];
module_param_string (defcharray, "string value", 13, 0);
static int defval = 100;
module_param (defval, int, 0);

int hello_init (void)
{
	printk (KERN_EMERG "hello init\n");
	printk (KERN_EMERG "defval = %d\n", defval);
	printk (KERN_EMERG "defstring = %s\n", defstring);
	printk (KERN_EMERG "defcharray = %s\n", defcharray);

	return 0;
}

void hello_exit (void)
{
	printk (KERN_EMERG "hello exit\n");
	return;
}

module_init (hello_init);
module_exit (hello_exit);

MODULE_LICENSE ("GPL");

[root@localhost /home/om/prg/mod_hello2]# 
Message from syslogd@localhost at Sat Nov 20 13:03:15 2004 ...
localhost kernel: defval = 100

Message from syslogd@localhost at Sat Nov 20 13:03:15 2004 ...
localhost kernel: defstring = <NULL>

Message from syslogd@localhost at Sat Nov 20 13:03:15 2004 ...
localhost kernel: hello init

Message from syslogd@localhost at Sat Nov 20 13:03:15 2004 ...
localhost kernel: defcharray = 

[root@localhost /home/om/prg/mod_hello2]# rmmod hello2
[root@localhost /home/om/prg/mod_hello2]# 
Message from syslogd@localhost at Sat Nov 20 13:03:23 2004 ...
localhost kernel: hello exit


Am I missing something basic?

Regards,
Om.

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux