LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   too few arguments to function 'register_sysctl_table' (https://www.linuxquestions.org/questions/linux-kernel-70/too-few-arguments-to-function-%27register_sysctl_table%27-744069/)

Richard.Yang 07-31-2009 01:10 AM

too few arguments to function 'register_sysctl_table'
 
Hi, all

I met a strange error while building a kernel module.

I am new in kernel module and want to build one with /proc/sys support.

Below is the source code.

#include <linux/init.h>
#include <linux/module.h>
#include <linux/sysctl.h>

MODULE_LICENSE("Dual BSD/GPL");

unsigned int hello_log;

static ctl_table powersave_nap_ctl_table[]={
{
.ctl_name = KERN_PPC_POWERSAVE_NAP,
.procname = "yw-test",
.data = &hello_log,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = &proc_dointvec,
},
{}
};
static ctl_table hello_table[] = {
{
.ctl_name = CTL_KERN,
.procname = "kernel",
.mode = 0755,
.child = powersave_nap_ctl_table,
},
{}
};


static struct ctl_table_header *hello_table_header;

static int hello_init(void)
{
printk(KERN_ALERT "Hello, world\n");
hello_table_header = register_sysctl_table(hello_table);

if(!hello_table_header)
return -ENOMEM;
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, cruel world\n");
unregister_sysctl_table(hello_table_header);
}


module_init(hello_init);
module_exit(hello_exit);

-----------------------------------------

Without the /proc/sys file, I can build it and install it.
The kernel version is 2.6.21-1.3194.fc7.
Anyone get some idea?

Richard.Yang 07-31-2009 01:33 AM

oh, my god

I change this

hello_table_header = register_sysctl_table(hello_table);

to

hello_table_header = register_sysctl_table(hello_table, 0);

Then it works!

And then I try this

register_sysctl_table(hello_table);
no return value. And also works.

Stange.

Richard.Yang 07-31-2009 08:31 AM

I did this on another platform, 2.6.25.5-1.1-pae.

While this don't support two parameters. And after I insert this kernel module, I couldn't see the /proc/sys/kernel/yw-test file.

So bad...


All times are GMT -5. The time now is 08:32 AM.