Skip to contentSkip to conversation

Create proc entry under /proc/sys/kernel

DISCUSSION RuoMu Hu 2 participants 4 messages Jun 8, 2008 TTY layer and serial drivers

lore
Share & tools
lore

RuoMu Hu

author
#0 lore raw

Hi!

Is it possible to create a proc entry under /proc/sys/kernel directly by create_proc_read_entry in the way shown below?

test_pde = create_proc_read_entry("/proc/sys/kernel/test", 0, NULL,

                                   test_read_proc, NULL);

if (test_pde == NULL) {
printk(KERN_ERR "Failed to create the test proc file.\n"); return -ENOMEM;
}

I'm using this in my kernel module but create_proc_read_entry always returns fail, while there's no problem creating proc entries directly under /proc. The kernel source I'm building my kernel module against is 2.6.25.4.

Any idea?

Thanks
Romu

#1 lore raw
Quoted 2 lines · RuoMu Hu

Is it possible to create a proc entry under /proc/sys/kernel directly by create_proc_read_entry in the way shown below?

No longer.

Quoted 11 lines

test_pde = create_proc_read_entry("/proc/sys/kernel/test", 0, NULL,

                                   test_read_proc, NULL);
if (test_pde == NULL) {
   printk(KERN_ERR "Failed to create the test proc file.\n");
   return -ENOMEM;
}

I'm using this in my kernel module but create_proc_read_entry always returns fail, while there's no problem creating proc entries directly under /proc. The kernel source I'm building my kernel module against is 2.6.25.4.

Use register_sysctl_table() for sysctls.

author
#2 lore raw
Quoted 15 lines · Alexey Dobriyan
Quoted 2 lines · RuoMu Hu

Is it possible to create a proc entry under /proc/sys/kernel directly by create_proc_read_entry in the way shown below?

No longer.

Quoted 7 lines

test_pde = create_proc_read_entry("/proc/sys/kernel/test", 0, NULL,

                                   test_read_proc, NULL);
if (test_pde == NULL) {
   printk(KERN_ERR "Failed to create the test proc file.\n");
   return -ENOMEM;
}
Quoted 5 lines
Quoted 2 lines

I'm using this in my kernel module but create_proc_read_entry always returns fail, while there's no problem creating proc entries directly under /proc. The kernel source I'm building my kernel module against is 2.6.25.4.

Use register_sysctl_table() for sysctls.

Thank you for your hint, it really helped me.

Another question: Is it possible to add an entry under /proc/sys/kernel by register_sysctl_table() without modifying kernel source (adding an entry to the kern_table[] array in kernel/sysctl.c)?

Best regards,
Romu

#3 lore raw
Quoted 23 lines · RuoMu Hu
Quoted 22 lines · Alexey Dobriyan
Quoted 3 lines · RuoMu Hu

Is it possible to create a proc entry under /proc/sys/kernel directly by create_proc_read_entry in the way shown below?

No longer.

Quoted 12 lines

test_pde = create_proc_read_entry("/proc/sys/kernel/test", 0, NULL,

                                   test_read_proc, NULL);
if (test_pde == NULL) {
   printk(KERN_ERR "Failed to create the test proc file.\n");
   return -ENOMEM;
}

I'm using this in my kernel module but create_proc_read_entry always returns fail, while there's no problem creating proc entries directly under /proc. The kernel source I'm building my kernel module against is 2.6.25.4.

Quoted 8 lines
Quoted 2 lines

Use register_sysctl_table() for sysctls.

Thank you for your hint, it really helped me.

Another question: Is it possible to add an entry under /proc/sys/kernel by register_sysctl_table() without modifying kernel source (adding an entry to the kern_table[] array in kernel/sysctl.c)?

Yes.

grep for register_sysctl_table and you'll see how.