LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
Search this Thread
Old 07-31-2009, 01:10 AM   #1
Richard.Yang
Member
 
Registered: Sep 2008
Posts: 106

Rep: Reputation: 16
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?
 
Old 07-31-2009, 01:33 AM   #2
Richard.Yang
Member
 
Registered: Sep 2008
Posts: 106

Original Poster
Rep: Reputation: 16
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.
 
Old 07-31-2009, 08:31 AM   #3
Richard.Yang
Member
 
Registered: Sep 2008
Posts: 106

Original Poster
Rep: Reputation: 16
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...
 
  


Reply

Tags
proc


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to pass structure as function arguments ssg14j Programming 2 08-20-2005 09:59 PM
How to import arguments to system() function skie_knite007 Programming 5 03-25-2005 08:49 PM
Passing Arguments into the Thread Function George_gk Programming 2 01-31-2005 05:03 AM
C Function Arguments jpbarto Programming 6 04-23-2004 01:59 PM
Function accept() and its arguments. krajzega Programming 1 01-20-2004 01:26 AM


All times are GMT -5. The time now is 07:58 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration